From a11ce4a6465bc45bf1b53944c59cf4b55f4d812e Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Wed, 5 May 2021 17:31:21 +0200 Subject: [PATCH] Add missing methods --- .../it/cavallium/dbengine/client/CompositeDatabase.java | 3 +++ src/main/java/it/cavallium/dbengine/database/LLUtils.java | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/cavallium/dbengine/client/CompositeDatabase.java b/src/main/java/it/cavallium/dbengine/client/CompositeDatabase.java index bbbc5ac..5d0291b 100644 --- a/src/main/java/it/cavallium/dbengine/client/CompositeDatabase.java +++ b/src/main/java/it/cavallium/dbengine/client/CompositeDatabase.java @@ -1,5 +1,6 @@ package it.cavallium.dbengine.client; +import io.netty.buffer.ByteBufAllocator; import reactor.core.publisher.Mono; public interface CompositeDatabase { @@ -9,4 +10,6 @@ public interface CompositeDatabase { Mono takeSnapshot() throws SnapshotException; Mono releaseSnapshot(CompositeSnapshot snapshot) throws SnapshotException; + + ByteBufAllocator getAllocator(); } diff --git a/src/main/java/it/cavallium/dbengine/database/LLUtils.java b/src/main/java/it/cavallium/dbengine/database/LLUtils.java index 90c5db6..8916eaf 100644 --- a/src/main/java/it/cavallium/dbengine/database/LLUtils.java +++ b/src/main/java/it/cavallium/dbengine/database/LLUtils.java @@ -307,7 +307,7 @@ public class LLUtils { } */ - public static ByteBuf convertToDirectByteBuf(AbstractByteBufAllocator alloc, ByteBuf buffer) { + public static ByteBuf convertToDirectByteBuf(ByteBufAllocator alloc, ByteBuf buffer) { ByteBuf result; ByteBuf directCopyBuf = alloc.buffer(buffer.capacity(), buffer.maxCapacity()); directCopyBuf.writeBytes(buffer, 0, buffer.writerIndex()); @@ -319,6 +319,12 @@ public class LLUtils { return result; } + public static ByteBuf fromByteArray(ByteBufAllocator alloc, byte[] array) { + ByteBuf result = alloc.buffer(array.length); + result.writeBytes(array); + return result; + } + @NotNull public static ByteBuf readDirectNioBuffer(ByteBufAllocator alloc, ToIntFunction reader) { var buffer = readNullableDirectNioBuffer(alloc, reader);