Skip to content

Commit

Permalink
Merge pull request brianfrankcooper#558 from allanbank/pr-522
Browse files Browse the repository at this point in the history
[mongodb] Update to use BATCHED_OK Status for batched inserts.
  • Loading branch information
allanbank committed Dec 26, 2015
2 parents 6032ff1 + 7438fd6 commit 3442025
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public final Status insert(final String table, final String key,
batchedWriteCount += 1;

if (batchedWriteCount < batchSize) {
return Status.OK;
return OptionsSupport.BATCHED_OK;
}

long count = collection.write(batchedWrite);
Expand Down
4 changes: 3 additions & 1 deletion mongodb/src/main/java/com/yahoo/ycsb/db/MongoDbClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import java.util.concurrent.atomic.AtomicInteger;

/**
* MongoDB asynchronous client for YCSB framework using the MongoDB Inc. <a
* MongoDB binding for YCSB framework using the MongoDB Inc. <a
* href="http://docs.mongodb.org/ecosystem/drivers/java/">driver</a>
* <p>
* See the <code>README.md</code> for configuration information.
Expand Down Expand Up @@ -285,6 +285,8 @@ public Status insert(String table, String key,
collection.insertMany(bulkInserts, INSERT_UNORDERED);
}
bulkInserts.clear();
} else {
return OptionsSupport.BATCHED_OK;
}
}
return Status.OK;
Expand Down
9 changes: 9 additions & 0 deletions mongodb/src/main/java/com/yahoo/ycsb/db/OptionsSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@

import java.util.Properties;

import com.yahoo.ycsb.Status;

/**
* OptionsSupport provides methods for handling legacy options.
*
* @author rjm
*/
public final class OptionsSupport {

/**
* Status used for operations that have not been send to the server and have
* only been batched by the client.
*/
public static final Status BATCHED_OK = new Status("BATCHED_OK",
"The operation has been batched by the binding.");

/** Value for an unavailable property. */
private static final String UNAVAILABLE = "n/a";

Expand Down

0 comments on commit 3442025

Please sign in to comment.