Skip to content

Commit e5f5008

Browse files
committed
Merge branch 'cursorget' of git://github.com/svegaxmr/lmdbjava into svegaxmr-cursorget
2 parents 46e1781 + 7a70355 commit e5f5008

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

src/main/java/org/lmdbjava/Cursor.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,37 @@ public boolean first() {
125125
return seek(MDB_FIRST);
126126
}
127127

128+
/**
129+
* Reposition the key/value buffers based on the passed key and operation.
130+
*
131+
* @param key to search for
132+
* @param data to search for
133+
* @param op options for this operation
134+
* @return false if key not found
135+
*/
136+
public boolean get(final T key, final T data, final SeekOp op) {
137+
if (SHOULD_CHECK) {
138+
requireNonNull(key);
139+
requireNonNull(op);
140+
checkNotClosed();
141+
txn.checkReady();
142+
}
143+
kv.keyIn(key);
144+
kv.valIn(data);
145+
146+
final int rc = LIB.mdb_cursor_get(ptrCursor, kv.pointerKey(), kv
147+
.pointerVal(), op.getCode());
148+
149+
if (rc == MDB_NOTFOUND) {
150+
return false;
151+
}
152+
153+
checkRc(rc);
154+
kv.keyOut();
155+
kv.valOut();
156+
return true;
157+
}
158+
128159
/**
129160
* Reposition the key/value buffers based on the passed key and operation.
130161
*

0 commit comments

Comments
 (0)