Skip to content

Commit

Permalink
Merge pull request brianfrankcooper#7 from smkniazi/RONDB-363
Browse files Browse the repository at this point in the history
RONDB-363 & RONDB-336
  • Loading branch information
smkniazi authored May 22, 2023
2 parents 82e1473 + be4da6b commit aea0333
Show file tree
Hide file tree
Showing 72 changed files with 863 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

@Override
public Status scan(String table, String startkey, int recordcount,
Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
Expand Down
6 changes: 6 additions & 0 deletions aerospike/src/main/java/site/ycsb/db/AerospikeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

@Override
public Status scan(String table, String start, int count, Set<String> fields,
Vector<HashMap<String, ByteIterator>> result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

/**
* Update a record in the database. Any field/value pairs in the specified
* values HashMap will be written into the record with the specified record
Expand Down
6 changes: 6 additions & 0 deletions asynchbase/src/main/java/site/ycsb/db/AsyncHBaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

@Override
public Status scan(String table, String startkey, int recordcount,
Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
Expand Down
6 changes: 6 additions & 0 deletions azurecosmos/src/main/java/site/ycsb/db/AzureCosmosClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

/**
* Perform a range scan for a set of records in the database. Each field/value
* pair from the result will be stored in a HashMap.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

@Override
public Status scan(String table, String startkey, int recordcount,
Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
Expand Down
6 changes: 6 additions & 0 deletions cassandra/src/main/java/site/ycsb/db/CassandraCQLClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

/**
* Perform a range scan for a set of records in the database. Each field/value
* pair from the result will be stored in a HashMap.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

private Status scanUsingQuery(
String table, String startKey, int recordCount, Set<String> fields,
Vector<HashMap<String, ByteIterator>> result) {
Expand Down
7 changes: 7 additions & 0 deletions core/src/main/java/site/ycsb/BasicDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}


@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

/**
* Perform a range scan for a set of records in the database. Each field/value pair from the result will be stored
* in a HashMap.
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/site/ycsb/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ public void cleanup() throws DBException {
public abstract Status batchRead(String table, List<String> keys, List<Set<String>> fields,
HashMap<String /*key*/, HashMap<String/*field*/, ByteIterator>> result);

/**
* Batch update records.
*
* @param table The name of the table
* @param keys record keys
* @param values A list of HashMaps of field/value pairs to update in the record
* @return The result of the operation.
*/
public abstract Status batchUpdate(String table, List<String> keys, List<Map<String, ByteIterator>> values);

/**
* Perform a range scan for a set of records in the database. Each field/value pair from the result will be stored
* in a HashMap.
Expand Down
14 changes: 14 additions & 0 deletions core/src/main/java/site/ycsb/DBWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
}
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
try (final TraceScope span = tracer.newScope(scopeStringRead)) {
long ist = measurements.getIntendedStartTimeNs();
long st = System.nanoTime();
Status res = db.batchUpdate(table, keys, values);
long en = System.nanoTime();
measure("BATCH_UPDATE", res, ist, st, en);
measurements.reportStatus("BATCH_UPDATE", res);
return res;
}
}

/**
* Perform a range scan for a set of records in the database.
* Each field/value pair from the result will be stored in a HashMap.
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/site/ycsb/GoodBadUglyDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

/**
* Perform a range scan for a set of records in the database. Each field/value pair from the result will be stored
* in a HashMap.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ public class OneMeasurementHdrHistogram extends OneMeasurement {
private final List<Double> percentiles;

private final int readBatchSize;
private final int updateBatchSize;

public OneMeasurementHdrHistogram(String name, Properties props) {
super(name);
percentiles = getPercentileValues(props.getProperty(PERCENTILES_PROPERTY, PERCENTILES_PROPERTY_DEFAULT));
verbose = Boolean.valueOf(props.getProperty(VERBOSE_PROPERTY, String.valueOf(false)));
readBatchSize =Integer.valueOf(props.getProperty(CoreWorkload.READ_BATCH_SIZE_PROPERTY,
CoreWorkload.READ_BATCH_SIZE_PROPERTY_DEFAULT));
updateBatchSize =Integer.valueOf(props.getProperty(CoreWorkload.UPDATE_BATCH_SIZE_PROPERTY,
CoreWorkload.UPDATE_BATCH_SIZE_PROPERTY_DEFAULT));
boolean shouldLog = Boolean.parseBoolean(props.getProperty("hdrhistogram.fileoutput", "false"));
if (!shouldLog) {
log = null;
Expand Down Expand Up @@ -127,6 +130,11 @@ public void exportMeasurements(MeasurementsExporter exporter) throws IOException
prepend = "Batch";
}

if (getName().compareTo("BATCH_UPDATE") == 0) {
exporter.write(getName(), "BatchSize", updateBatchSize);
prepend = "Batch";
}

exporter.write(getName(), prepend+"Operations", totalHistogram.getTotalCount());
exporter.write(getName(), prepend+"AverageLatency(us)", totalHistogram.getMean());
exporter.write(getName(), prepend+"MinLatency(us)", totalHistogram.getMinValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,16 @@ public class OneMeasurementHistogram extends OneMeasurement {
private int max;

private final int readBatchSize;
private final int updateBatchSize;

public OneMeasurementHistogram(String name, Properties props) {
super(name);
buckets = Integer.parseInt(props.getProperty(BUCKETS, BUCKETS_DEFAULT));
verbose = Boolean.valueOf(props.getProperty(VERBOSE_PROPERTY, String.valueOf(false)));
readBatchSize = Integer.valueOf(props.getProperty(CoreWorkload.READ_BATCH_SIZE_PROPERTY,
CoreWorkload.READ_BATCH_SIZE_PROPERTY_DEFAULT));
updateBatchSize = Integer.valueOf(props.getProperty(CoreWorkload.UPDATE_BATCH_SIZE_PROPERTY,
CoreWorkload.UPDATE_BATCH_SIZE_PROPERTY_DEFAULT));
histogram = new long[buckets];
histogramoverflow = 0;
operations = 0;
Expand Down Expand Up @@ -131,6 +134,9 @@ public void exportMeasurements(MeasurementsExporter exporter) throws IOException
if (getName().compareTo("BATCH_READ") == 0) {
exporter.write(getName(), "BatchSize", readBatchSize);
}
if (getName().compareTo("BATCH_UPDATE") == 0) {
exporter.write(getName(), "BatchSize", updateBatchSize);
}
exporter.write(getName(), "Operations", operations);
exporter.write(getName(), "AverageLatency(us)", mean);
exporter.write(getName(), "LatencyVariance(us)", variance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ public class OneMeasurementTimeSeries extends OneMeasurement {
private int min = -1;
private int max = -1;
private final int readBatchSize;
private final int updateBatchSize;

public OneMeasurementTimeSeries(String name, Properties props) {
super(name);
granularity = Integer.parseInt(props.getProperty(GRANULARITY, GRANULARITY_DEFAULT));
measurements = new Vector<>();
readBatchSize = Integer.valueOf(props.getProperty(CoreWorkload.READ_BATCH_SIZE_PROPERTY,
CoreWorkload.READ_BATCH_SIZE_PROPERTY_DEFAULT));
updateBatchSize = Integer.valueOf(props.getProperty(CoreWorkload.UPDATE_BATCH_SIZE_PROPERTY,
CoreWorkload.UPDATE_BATCH_SIZE_PROPERTY_DEFAULT));
}

private synchronized void checkEndOfUnit(boolean forceend) {
Expand Down Expand Up @@ -128,6 +131,11 @@ public void exportMeasurements(MeasurementsExporter exporter) throws IOException
exporter.write(getName(), "BatchSize", readBatchSize);
prepend = "Batch";
}

if (getName().compareTo("BATCH_UPDATE") == 0) {
exporter.write(getName(), "BatchSize", updateBatchSize);
prepend = "Batch";
}
exporter.write(getName(), prepend+"Operations", operations);
exporter.write(getName(), prepend+"AverageLatency(us)", (((double) totallatency) / ((double) operations)));
exporter.write(getName(), prepend+"MinLatency(us)", min);
Expand Down
49 changes: 48 additions & 1 deletion core/src/main/java/site/ycsb/workloads/CoreWorkload.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ public class CoreWorkload extends Workload {
*/
public static final String READ_BATCH_SIZE_PROPERTY_DEFAULT = "1";

/**
* The name of the property for the size of update batches.
*/
public static final String UPDATE_BATCH_SIZE_PROPERTY = "updateBatchSize";

/**
* The default update batch.
*/
public static final String UPDATE_BATCH_SIZE_PROPERTY_DEFAULT = "1";

/**
* The name of the property for the proportion of transactions that are updates.
*/
Expand Down Expand Up @@ -380,6 +390,7 @@ public class CoreWorkload extends Workload {
protected int insertionRetryLimit;
protected int insertionRetryInterval;
protected int readBatchSize;
protected int updateBatchSize;

private Measurements measurements = Measurements.getMeasurements();

Expand Down Expand Up @@ -562,6 +573,11 @@ public void init(Properties p) throws WorkloadException {
if (readBatchSize <= 0) {
throw new WorkloadException("Invalid read batch size \"" + readBatchSize + "\"");
}
updateBatchSize = Integer.parseInt(p.getProperty(
UPDATE_BATCH_SIZE_PROPERTY, UPDATE_BATCH_SIZE_PROPERTY_DEFAULT));
if (updateBatchSize <= 0) {
throw new WorkloadException("Invalid update batch size \"" + updateBatchSize + "\"");
}
}

/**
Expand Down Expand Up @@ -685,7 +701,11 @@ public boolean doTransaction(DB db, Object threadstate) {
}
break;
case "UPDATE":
doTransactionUpdate(db);
if (updateBatchSize == 1){
doTransactionUpdate(db);
} else {
doTransactionBatchUpdate(db);
}
break;
case "INSERT":
doTransactionInsert(db);
Expand Down Expand Up @@ -893,6 +913,33 @@ public void doTransactionUpdate(DB db) {
db.update(table, keyname, values);
}

public void doTransactionBatchUpdate(DB db) {
LinkedList<String> keys = new LinkedList<>();
LinkedList<Map<String, ByteIterator>> allValues = new LinkedList<>();

for (int i = 0; i < updateBatchSize; i++) {
// choose a random key
long keynum = nextKeynum();

String keyname = CoreWorkload.buildKeyName(keynum, zeropadding, orderedinserts);

HashMap<String, ByteIterator> values;

if (writeallfields) {
// new data for all the fields
values = buildValues(keyname);
} else {
// update a random field
values = buildSingleValue(keyname);
}

keys.add(keyname);
allValues.add(values);
}

db.batchUpdate(table, keys, allValues);
}

public void doTransactionInsert(DB db) {
// choose the next key
long keynum = transactioninsertkeysequence.nextValue();
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/site/ycsb/workloads/RestWorkload.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public void init(Properties p) throws WorkloadException {
if (readBatchSize <= 0) {
throw new WorkloadException("Invalid read batch size \"" + readBatchSize + "\"");
}
updateBatchSize = Integer.parseInt(p.getProperty(
UPDATE_BATCH_SIZE_PROPERTY, UPDATE_BATCH_SIZE_PROPERTY_DEFAULT));
if (updateBatchSize <= 0) {
throw new WorkloadException("Invalid update batch size \"" + updateBatchSize + "\"");
}
}

public static DiscreteGenerator createOperationGenerator(final Properties p) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
return Status.OK;
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
return Status.OK;
}

@Override
public Status scan(String table, String startkey, int recordcount,
Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
Expand Down
6 changes: 6 additions & 0 deletions couchbase/src/main/java/site/ycsb/db/CouchbaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

@Override
public Status scan(final String table, final String startkey, final int recordcount, final Set<String> fields,
final Vector<HashMap<String, ByteIterator>> result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ public Status batchRead(String table, List<String> keys, List<Set<String>> field
throw new UnsupportedOperationException("Batch reads are not yet supported");
}

@Override
public Status batchUpdate(String table, List<String> keys,
List<Map<String, ByteIterator>> values) {
throw new UnsupportedOperationException("Batch updates are not yet supported");
}

/**
* Performs the {@link #read(String, String, Set, Map)} operation via Key/Value ("get").
*
Expand Down
Loading

0 comments on commit aea0333

Please sign in to comment.