Skip to content

Commit

Permalink
Issue Netflix#57 - addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pencal committed Dec 11, 2017
1 parent 4e66606 commit 66618ec
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,7 @@ public void shutdown() throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -204,12 +199,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<String> writeBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,7 @@ public String writeSingle(String key) throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -146,12 +141,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<String> writeBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

private BoundStatement getBStmtTable1(String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,7 @@ public String writeSingle(String key) throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -87,12 +82,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<String> writeBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,7 @@ public String writeSingle(String key) throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -164,12 +159,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<String> writeBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,7 @@ public String writeSingle(String key) throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -150,12 +145,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<String> writeBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

Expand All @@ -47,7 +48,14 @@ public boolean process(NdBenchDriver driver,
boolean isAutoTuneEnabled) {
try {
Long startTime = System.nanoTime();
List<String> value = client.readBulk(keys);
List<String> value = new ArrayList<>(keys.size());
if (keys.size() > 1) {
// bulk
value.addAll(client.readBulk(keys));
} else {
// single
value.add(client.readSingle(keys.get(0)));
}
monitor.recordReadLatency((System.nanoTime() - startTime)/1000);
if (value != null) {
monitor.incCacheHit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

Expand All @@ -49,7 +50,15 @@ public boolean process(NdBenchDriver driver,
boolean isAutoTuneEnabled) {
try {
Long startTime = System.nanoTime();
List<W> result = client.writeBulk(keys);
List<W> result;
if (keys.size() > 1) {
// bulk
result = client.writeBulk(keys);
} else {
// single
result = new ArrayList<>(1);
result.add(client.writeSingle(keys.get(0)));
}
stats.recordWriteLatency((System.nanoTime() - startTime)/1000);

if (isAutoTuneEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,7 @@ public String writeSingle(String key) throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -129,12 +124,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<String> writeBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,7 @@ public String writeSingle(String key) throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -145,12 +140,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<String> writeBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,7 @@ public String writeSingle(String key) throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -131,12 +126,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<String> writeBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,7 @@ public String writeSingle(String key) throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -112,12 +107,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<String> writeBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,7 @@ public String writeSingle(String key) throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -146,12 +141,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<String> writeBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,7 @@ public String readSingle(String key) throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -202,12 +197,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<WriteResult> writeBulk(final List<String> keys) throws Exception {
List<WriteResult> responses = new ArrayList<>(keys.size());
for (String key : keys) {
WriteResult response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,7 @@ public String writeSingle(final String key) throws Exception {
* @throws Exception
*/
public List<String> readBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = readSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

/**
Expand All @@ -129,12 +124,7 @@ public List<String> readBulk(final List<String> keys) throws Exception {
* @throws Exception
*/
public List<String> writeBulk(final List<String> keys) throws Exception {
List<String> responses = new ArrayList<>(keys.size());
for (String key : keys) {
String response = writeSingle(key);
responses.add(response);
}
return responses;
throw new UnsupportedOperationException("bulk operation is not supported");
}

public void shutdown() throws Exception {
Expand Down
Loading

0 comments on commit 66618ec

Please sign in to comment.