jankotek / mapdb

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap-memory. It is a fast and easy to use embedded Java database engine.
https://mapdb.org
Apache License 2.0
4.87k stars 872 forks source link

Simplest way to get value as byte buffer with only 1 memory copy operation #961

Open pranasblk opened 4 years ago

pranasblk commented 4 years ago

I've noticed even using regular value serializer SerializerArray would cause multiple copies of underlying raw bytes. Ideally I'd like to get only 1 copy for thread safety.

What's the simplest way to get byte[]/ByteBuffer for key with minimum number (1) memory copy operations from DirectStore?

I've done some code checks and looks like it's doable by creating custom deserializer. Is it safe to assume, what DataInput2.internalByteBuffer will have copy already ready if it's retrieved from DirectStore or there are more copies of memory one should be aware of?

Thanks!