Add missing methods

This commit is contained in:
Andrea Cavalli 2021-05-05 17:31:21 +02:00
parent a4deeee6d5
commit a11ce4a646
2 changed files with 10 additions and 1 deletions

View File

@ -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<CompositeSnapshot> takeSnapshot() throws SnapshotException;
Mono<Void> releaseSnapshot(CompositeSnapshot snapshot) throws SnapshotException;
ByteBufAllocator getAllocator();
}

View File

@ -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<ByteBuffer> reader) {
var buffer = readNullableDirectNioBuffer(alloc, reader);