diff --git a/src/main/java/org/lmdbjava/Cursor.java b/src/main/java/org/lmdbjava/Cursor.java index 2c6bd7e0..1b3c6430 100644 --- a/src/main/java/org/lmdbjava/Cursor.java +++ b/src/main/java/org/lmdbjava/Cursor.java @@ -125,6 +125,37 @@ public boolean first() { return seek(MDB_FIRST); } + /** + * Reposition the key/value buffers based on the passed key and operation. + * + * @param key to search for + * @param data to search for + * @param op options for this operation + * @return false if key not found + */ + public boolean get(final T key, final T data, final SeekOp op) { + if (SHOULD_CHECK) { + requireNonNull(key); + requireNonNull(op); + checkNotClosed(); + txn.checkReady(); + } + kv.keyIn(key); + kv.valIn(data); + + final int rc = LIB.mdb_cursor_get(ptrCursor, kv.pointerKey(), kv + .pointerVal(), op.getCode()); + + if (rc == MDB_NOTFOUND) { + return false; + } + + checkRc(rc); + kv.keyOut(); + kv.valOut(); + return true; + } + /** * Reposition the key/value buffers based on the passed key and operation. *