Permalink
Browse files

Apply patch submitted in #7: Optimize for when values are not found.

  • Loading branch information...
1 parent d38e549 commit c6c2a888eb755be1a05168776a59d77c50c7e674 @chirino chirino committed Feb 6, 2013
Showing with 13 additions and 2 deletions.
  1. +13 −2 leveldbjni/src/main/java/org/fusesource/leveldbjni/internal/NativeDB.java
@@ -304,8 +304,19 @@ public void write(NativeWriteOptions options, NativeWriteBatch updates) throws D
assertAllocated();
NativeStdString result = new NativeStdString();
try {
- checkStatus(DBJNI.Get(self, options, keySlice, result.pointer()));
- return result.toByteArray();
+ long s = DBJNI.Get(self, options, keySlice, result.pointer());
+ NativeStatus status = new NativeStatus(s);
+ try {
+ if(status.isOk()) {
+ return result.toByteArray();
+ }
+ if(status.isNotFound()) {
+ return null;
+ }
+ throw new DBException(status.toString(), status.isNotFound());
+ } finally {
+ status.delete();
+ }
} finally {
result.delete();
}

0 comments on commit c6c2a88

Please sign in to comment.