Integrated changes due to review bei ankgup87

This commit is contained in:
fyrz 2014-10-26 13:27:43 +01:00
parent b8ce526487
commit a1bae76c87
2 changed files with 10 additions and 1 deletions

View File

@ -92,7 +92,11 @@ public class ReadOptions extends RocksObject {
*/
public ReadOptions setSnapshot(Snapshot snapshot) {
assert(isInitialized());
setSnapshot(nativeHandle_, snapshot.nativeHandle_);
if (snapshot != null) {
setSnapshot(nativeHandle_, snapshot.nativeHandle_);
} else {
setSnapshot(nativeHandle_, 0l);
}
return this;
}
private native void setSnapshot(long handle, long snapshotHandle);

View File

@ -69,6 +69,11 @@ public class SnapshotTest
// null
assert(db.get(readOptions, "newkey".getBytes())
== null);
// setting null to snapshot in ReadOptions leads
// to no Snapshot being used.
readOptions.setSnapshot(null);
assert(new String(db.get(readOptions,
"newkey".getBytes())).equals("newvalue"));
// release Snapshot
db.releaseSnapshot(snapshot);
// Close database