More customizable allocators

This commit is contained in:
Andrea Cavalli 2021-05-05 00:07:18 +02:00
parent 5b89be8ee0
commit 63beb1931e
2 changed files with 4 additions and 3 deletions

View File

@ -105,6 +105,7 @@ public class LLLocalDictionary implements LLDictionary {
* Default: true
*/
private static final boolean USE_DIRECT_BUFFER_BOUNDS = true;
private static final int INITIAL_DIRECT_READ_BYTE_BUF_SIZE_BYTES = 4096;
static {
boolean assertionsEnabled = false;
@ -235,7 +236,7 @@ public class LLLocalDictionary implements LLDictionary {
ByteBuffer keyNioBuffer = LLUtils.toDirect(key);
assert keyNioBuffer.isDirect();
// Create a direct result buffer because RocksDB works only with direct buffers
ByteBuf resultBuf = alloc.directBuffer();
ByteBuf resultBuf = alloc.directBuffer(LLLocalDictionary.INITIAL_DIRECT_READ_BYTE_BUF_SIZE_BYTES);
try {
int valueSize;
int assertionReadData = -1;

View File

@ -110,7 +110,7 @@ public interface SerializerFixedBinaryLength<A, B> extends Serializer<A, B> {
@Override
public @NotNull ByteBuf serialize(@NotNull Integer deserialized) {
ByteBuf buf = allocator.directBuffer(Integer.BYTES);
ByteBuf buf = allocator.buffer(Integer.BYTES);
return buf.writeInt(deserialized);
}
@ -139,7 +139,7 @@ public interface SerializerFixedBinaryLength<A, B> extends Serializer<A, B> {
@Override
public @NotNull ByteBuf serialize(@NotNull Long deserialized) {
ByteBuf buf = allocator.directBuffer(Long.BYTES);
ByteBuf buf = allocator.buffer(Long.BYTES);
return buf.writeLong(deserialized);
}