DatabaseEntry val = new DatabaseEntry();
// cursor stores the next key and value in the above mutable objects.
OperationStatus stat = cursor.getNext(key, val, LockMode.READ_UNCOMMITTED);
if (stat == OperationStatus.SUCCESS) {
next = new KeyValDocument(key.getData(), val.getData());
} else {
next = null;
close();
}
}
private void initCursor() {
if (cursor == null) {
cursor = db.openCursor(null, null);
cacheNext();
}
}
public boolean hasNext() {
initCursor();
return next != null;
}
public KeyValDocument next() {
initCursor();
if (next == null) { throw new RuntimeException("No key/value pair available"); }
KeyValDocument ret = next;
cacheNext(); // caches up n + 1,
return ret; // return the old.
}
public void remove() {