Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply checkstyle to all modules #154

Merged
merged 4 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public class ByteBufferBenchmark {
@State(Scope.Benchmark)
public static class BenchmarkState {

@Param({"ONHEAP","OFFHEAP"})
@Param({"ONHEAP", "OFFHEAP"})
String heap;

ByteBuffer byteBuffer;

int bytes = 1024*1024*1024;
final int bytes = 1024 * 1024 * 1024;

@Setup()
public void setup() {
Expand All @@ -58,7 +58,7 @@ public void setup() {
@Threads(1)
@Benchmark
public void put(Blackhole blackhole, BenchmarkState state) {
for (int i=0; i < state.bytes; ++i) {
for (int i = 0; i < state.bytes; ++i) {
state.byteBuffer.put(i, (byte) i);
}
}
Expand All @@ -71,7 +71,7 @@ public void put(Blackhole blackhole, BenchmarkState state) {
@Threads(1)
@Benchmark
public void get(Blackhole blackhole, BenchmarkState state) {
for (int i=0; i < state.bytes; ++i) {
for (int i = 0; i < state.bytes; ++i) {
blackhole.consume(state.byteBuffer.get(i));
}
}
Expand Down
14 changes: 7 additions & 7 deletions benchmarks/jmh/src/main/java/com/yahoo/oak/GetBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

public class GetBenchmark {

static public final int KEY_SIZE_BYTES = 64;
static public final int VALUE_SIZE_BYTES = 64;
public static final int KEY_SIZE_BYTES = 64;
public static final int VALUE_SIZE_BYTES = 64;

@State(Scope.Benchmark)
public static class BenchmarkState {
Expand All @@ -49,14 +49,14 @@ public void setup() {
oakMap = builder.build();

keys = new ArrayList<>(numRows);
for(int i = 0; i< numRows; ++i) {
String key = String.format("%0$" + KEY_SIZE_BYTES/Character.BYTES +"s",
for (int i = 0; i < numRows; ++i) {
String key = String.format("%0$" + KEY_SIZE_BYTES / Character.BYTES + "s",
String.valueOf(i));

String val = String.format("%0$-" + VALUE_SIZE_BYTES/Character.BYTES +"s",
String val = String.format("%0$-" + VALUE_SIZE_BYTES / Character.BYTES + "s",
String.valueOf(i));

oakMap.zc().put(key,val);
oakMap.zc().put(key, val);
keys.add(key);
}
}
Expand All @@ -75,7 +75,7 @@ public static class ThreadState {
@Fork(value = 1)
@Threads(8)
@Benchmark
public void get(Blackhole blackhole,BenchmarkState state,ThreadState threadState) {
public void get(Blackhole blackhole, BenchmarkState state, ThreadState threadState) {
String key = state.keys.get(threadState.i++ % state.numRows);
String val = state.oakMap.get(key);
blackhole.consume(val);
Expand Down
14 changes: 7 additions & 7 deletions benchmarks/jmh/src/main/java/com/yahoo/oak/PutBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

public class PutBenchmark {

static public final int KEY_SIZE_BYTES = 64;
static public final int VALUE_SIZE_BYTES = 64;
public static final int KEY_SIZE_BYTES = 64;
public static final int VALUE_SIZE_BYTES = 64;

@State(Scope.Benchmark)
public static class BenchmarkState {
Expand Down Expand Up @@ -73,11 +73,11 @@ public static class ThreadState {
public void setup() {

rows = new ArrayList<>(numRows);
for(int i = 0; i< numRows; ++i) {
String key = String.format("%0$" + KEY_SIZE_BYTES/Character.BYTES +"s",
for (int i = 0; i < numRows; ++i) {
String key = String.format("%0$" + KEY_SIZE_BYTES / Character.BYTES + "s",
String.valueOf(i) + Thread.currentThread().getId());

String val = String.format("%0$-" + VALUE_SIZE_BYTES/Character.BYTES +"s",
String val = String.format("%0$-" + VALUE_SIZE_BYTES / Character.BYTES + "s",
String.valueOf(i) + Thread.currentThread().getId());

rows.add(new AbstractMap.SimpleImmutableEntry<>(key, val));
Expand All @@ -93,7 +93,7 @@ public void setup() {
@Fork(value = 1)
@Threads(8)
@Benchmark
public void put(Blackhole blackhole,BenchmarkState state,ThreadState threadState) {
public void put(Blackhole blackhole, BenchmarkState state, ThreadState threadState) {
for (int i = 0; i < threadState.numRows; ++i) {
Map.Entry<String, String> pair = threadState.rows.get(i);
state.oakMap.zc().put(pair.getKey(), pair.getValue());
Expand All @@ -108,7 +108,7 @@ public void put(Blackhole blackhole,BenchmarkState state,ThreadState threadState
@Fork(value = 1)
@Threads(8)
@Benchmark
public void putIfAbsent(Blackhole blackhole,BenchmarkState state,ThreadState threadState) {
public void putIfAbsent(Blackhole blackhole, BenchmarkState state, ThreadState threadState) {
for (int i = 0; i < threadState.numRows; ++i) {
Map.Entry<String, String> pair = threadState.rows.get(i);
state.oakMap.zc().put(pair.getKey(), pair.getValue());
Expand Down
15 changes: 7 additions & 8 deletions benchmarks/jmh/src/main/java/com/yahoo/oak/ScanBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@
@Fork(value = 1)
@Threads(8)
@State(Scope.Benchmark)
public class ScanBenchmark
{
public class ScanBenchmark {

static public final int KEY_SIZE_BYTES = 4;
static public final int VALUE_SIZE_BYTES = 4;
public static final int KEY_SIZE_BYTES = 4;
public static final int VALUE_SIZE_BYTES = 4;

private OakMap<String, String> oakMap;

Expand All @@ -54,11 +53,11 @@ public void setup() {
OakMapBuilder<String, String> builder = OakCommonBuildersFactory.getDefaultStringBuilder();
oakMap = builder.build();

for(int i = 0; i< numRows; ++i) {
String key = String.format("%0$" + KEY_SIZE_BYTES/Character.BYTES +"s",
for (int i = 0; i < numRows; ++i) {
String key = String.format("%0$" + KEY_SIZE_BYTES / Character.BYTES + "s",
String.valueOf(i) + Thread.currentThread().getId());

String val = String.format("%0$-" + VALUE_SIZE_BYTES/Character.BYTES +"s",
String val = String.format("%0$-" + VALUE_SIZE_BYTES / Character.BYTES + "s",
String.valueOf(i) + Thread.currentThread().getId());

oakMap.zc().put(key, val);
Expand All @@ -83,7 +82,7 @@ public void scan(Blackhole blackhole) {

@Benchmark
public void bufferViewScan(Blackhole blackhole) {
Iterator<OakUnscopedBuffer> iterator = oakMap.zc().keySet().iterator();
Iterator<OakUnscopedBuffer> iterator = oakMap.zc().keySet().iterator();
while (iterator.hasNext()) {
OakUnscopedBuffer val = iterator.next();
blackhole.consume(val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

package com.yahoo.oak;

import com.yahoo.oak.synchrobench.contention.abstractions.CompositionalOakMap;
import com.yahoo.oak.synchrobench.MyBuffer;
import com.yahoo.oak.synchrobench.contention.abstractions.CompositionalOakMap;

import java.util.Iterator;
import java.util.concurrent.ConcurrentSkipListMap;
Expand Down Expand Up @@ -49,7 +49,7 @@ public void computeOak(K key) {
@Override
public void putIfAbsentComputeIfPresentOak(K key, V value) {

skipListMap.merge(key, value, (old,v) -> {
skipListMap.merge(key, value, (old, v) -> {
synchronized (old) {
old.buffer.putLong(1, ~old.buffer.getLong(1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

package com.yahoo.oak;

import com.yahoo.oak.synchrobench.MyBuffer;
import com.yahoo.oak.synchrobench.contention.abstractions.CompositionalOakMap;
import com.yahoo.oak.synchrobench.contention.benchmark.Parameters;
import com.yahoo.oak.synchrobench.MyBuffer;

import java.util.Iterator;

Expand All @@ -23,7 +23,7 @@ public class OakMyBufferMap<K extends MyBuffer, V extends MyBuffer> implements C

public OakMyBufferMap() {
ma = new NativeMemoryAllocator(OAK_MAX_OFF_MEMORY);
if (Parameters.detailedStats) {
if (Parameters.confDetailedStats) {
ma.collectStats();
}
minKey = new MyBuffer(Integer.BYTES);
Expand All @@ -42,7 +42,7 @@ public long allocated() {

@Override
public boolean getOak(K key) {
if (Parameters.zeroCopy) {
if (Parameters.confZeroCopy) {
return oak.zc().get(key) != null;
}
return oak.get(key) != null;
Expand All @@ -60,7 +60,7 @@ public boolean putIfAbsentOak(K key, V value) {

@Override
public void removeOak(K key) {
if (Parameters.zeroCopy) {
if (Parameters.confZeroCopy) {
oak.zc().remove(key);
} else {
oak.remove(key);
Expand Down Expand Up @@ -103,8 +103,8 @@ public boolean descendOak(K from, int length) {

private boolean createAndScanView(OakMap<MyBuffer, MyBuffer> subMap, int length) {
Iterator iter;
if (Parameters.zeroCopy) {
if (Parameters.streamIteration) {
if (Parameters.confZeroCopy) {
if (Parameters.confStreamIteration) {
iter = subMap.zc().entryStreamSet().iterator();
} else {
iter = subMap.zc().entrySet().iterator();
Expand All @@ -130,7 +130,7 @@ public void clear() {
oak.close();

ma = new NativeMemoryAllocator(OAK_MAX_OFF_MEMORY);
if (Parameters.detailedStats) {
if (Parameters.confDetailedStats) {
ma.collectStats();
}
minKey = new MyBuffer(Integer.BYTES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

package com.yahoo.oak;

import com.yahoo.oak.synchrobench.MyBuffer;
import com.yahoo.oak.synchrobench.contention.abstractions.CompositionalOakMap;
import com.yahoo.oak.synchrobench.contention.benchmark.Parameters;
import com.yahoo.oak.synchrobench.MyBuffer;

import java.nio.ByteBuffer;
import java.util.Comparator;
Expand All @@ -29,8 +29,7 @@ public class OffHeapList<K extends MyBuffer, V extends MyBuffer> implements Comp

public OffHeapList() {

comparator = (o1, o2) ->
{
comparator = (o1, o2) -> {
//TODO YONIGO - what if key gets dfeleted?
if (o1 instanceof MyBuffer) {

Expand Down Expand Up @@ -78,7 +77,7 @@ public OffHeapList() {
@Override
public boolean getOak(K key) {
Cell value = skipListMap.get(key);
if (Parameters.zeroCopy) {
if (Parameters.confZeroCopy) {
return value != null && value.value != null;
} else {
if (value != null && value.value != null) {
Expand Down Expand Up @@ -185,7 +184,7 @@ private boolean iterate(Iterator<Map.Entry<Object, Cell>> iter, int length) {
Map.Entry<Object, Cell> cell = iter.next();
//only if cell is not null value is not deleted or not set yet.
if (cell.getValue().value.get() != null) {
if (!Parameters.zeroCopy) {
if (!Parameters.confZeroCopy) {
MyBuffer des = MyBuffer.deserialize(cell.getValue().value.get());
//YONIGO - I just do this so that hopefully jvm doesnt optimize out the deserialize
if (des != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

import com.yahoo.oak.OakComparator;
import com.yahoo.oak.OakScopedReadBuffer;
import com.yahoo.oak.OakSerializer;
import com.yahoo.oak.OakScopedWriteBuffer;
import com.yahoo.oak.OakSerializer;
import com.yahoo.oak.common.intbuffer.OakIntBufferComparator;
import com.yahoo.oak.common.intbuffer.OakIntBufferSerializer;

import java.nio.ByteBuffer;

public class MyBuffer implements Comparable<MyBuffer> {

private final static int DATA_POS = 0;
private static final int DATA_POS = 0;

public final int capacity;
public final ByteBuffer buffer;
Expand All @@ -38,17 +38,17 @@ public int compareTo(MyBuffer o) {

public static void serialize(MyBuffer inputBuffer, OakScopedWriteBuffer targetBuffer) {
// In the serialized buffer, the first integer signifies the size.
int targetPos = 0;
targetBuffer.putInt(targetPos, inputBuffer.capacity);
targetPos += Integer.BYTES;
int targetPos = 0;
targetBuffer.putInt(targetPos, inputBuffer.capacity);
targetPos += Integer.BYTES;
OakIntBufferSerializer.copyBuffer(inputBuffer.buffer, DATA_POS, inputBuffer.capacity / Integer.BYTES,
targetBuffer, targetPos);
targetBuffer, targetPos);
}

public static MyBuffer deserialize(OakScopedReadBuffer inputBuffer) {
int inputPos = 0;
int capacity = inputBuffer.getInt(inputPos);
inputPos += Integer.BYTES;
int inputPos = 0;
int capacity = inputBuffer.getInt(inputPos);
inputPos += Integer.BYTES;
MyBuffer ret = new MyBuffer(capacity);
OakIntBufferSerializer.copyBuffer(inputBuffer, inputPos, capacity / Integer.BYTES, ret.buffer, DATA_POS);
return ret;
Expand All @@ -60,26 +60,28 @@ private static int compareBuffers(ByteBuffer buff1, int pos1, int cap1, ByteBuff
buff2, pos2, cap2 / Integer.BYTES);
}

private static int compareBuffers(ByteBuffer buff1, int pos1, int cap1, OakScopedReadBuffer buff2, int pos2, int cap2) {
private static int compareBuffers(ByteBuffer buff1, int pos1, int cap1, OakScopedReadBuffer buff2,
int pos2, int cap2) {
return OakIntBufferComparator.compare(buff1, pos1, cap1 / Integer.BYTES,
buff2, pos2, cap2 / Integer.BYTES);
}

private static int compareBuffers(OakScopedReadBuffer buff1, int pos1, int cap1, OakScopedReadBuffer buff2, int pos2, int cap2) {

private static int compareBuffers(OakScopedReadBuffer buff1, int pos1, int cap1, OakScopedReadBuffer buff2,
int pos2, int cap2) {
return OakIntBufferComparator.compare(buff1, pos1, cap1 / Integer.BYTES, buff2, pos2, cap2 / Integer.BYTES);
}

public static int compareBuffers(OakScopedReadBuffer buffer1, OakScopedReadBuffer buffer2) {
// In the serialized buffer, the first integer signifies the size.
int cap1 = buffer1.getInt(0);
int cap2 = buffer2.getInt(0);
int cap1 = buffer1.getInt(0);
int cap2 = buffer2.getInt(0);
return compareBuffers(buffer1, Integer.BYTES, cap1, buffer2, Integer.BYTES, cap2);
}

public static int compareBuffers(MyBuffer key1, OakScopedReadBuffer buffer2) {
// In the serialized buffer, the first integer signifies the size.
int cap2 = buffer2.getInt(0);
return compareBuffers(key1.buffer, DATA_POS, key1.capacity, buffer2, Integer.BYTES, cap2);
int cap2 = buffer2.getInt(0);
return compareBuffers(key1.buffer, DATA_POS, key1.capacity, buffer2, Integer.BYTES, cap2);
}

public static int compareBuffers(MyBuffer key1, MyBuffer key2) {
Expand Down Expand Up @@ -112,12 +114,12 @@ public int compareKeys(MyBuffer key1, MyBuffer key2) {

@Override
public int compareSerializedKeys(OakScopedReadBuffer serializedKey1, OakScopedReadBuffer serializedKey2) {
return compareBuffers( serializedKey1, serializedKey2);
return compareBuffers(serializedKey1, serializedKey2);
}

@Override
public int compareKeyAndSerializedKey(MyBuffer key, OakScopedReadBuffer serializedKey) {
return compareBuffers(key, serializedKey);
return compareBuffers(key, serializedKey);
}
};
}
Loading