Objects: use bytebuffer to read

a little less GC pressure
This commit is contained in:
2025-04-18 13:21:04 +02:00
parent 59fa5dcf28
commit a6a4101bb0

View File

@@ -360,13 +360,12 @@ public class LmdbObjectPersistentStore implements ObjectPersistentStore {
throw new NoSuchElementException("No more elements");
}
// TODO: Right now with java serialization it doesn't matter, it's all copied to arrays anyway
// var val = _cursor.val();
// var bbDirect = UninitializedByteBuffer.allocateUninitialized(val.remaining());
// bbDirect.put(val);
// bbDirect.flip();
// var bs = UnsafeByteOperations.unsafeWrap(bbDirect);
// var ret = Pair.of(JObjectKey.fromByteBuffer(_cursor.key()), bs);
var ret = Pair.of(JObjectKey.fromByteBuffer(_cursor.key()), ByteString.copyFrom(_cursor.val()));
var val = _cursor.val();
var bbDirect = UninitializedByteBuffer.allocateUninitialized(val.remaining());
bbDirect.put(val);
bbDirect.flip();
var bs = UnsafeByteOperations.unsafeWrap(bbDirect);
var ret = Pair.of(JObjectKey.fromByteBuffer(_cursor.key()), bs);
if (_goingForward)
_hasNext = _cursor.next();
else