Class NettyBufferFactory
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.driver.ser.NettyBufferFactory
-
- All Implemented Interfaces:
BufferFactory<io.netty.buffer.ByteBuf>
public class NettyBufferFactory extends Object implements BufferFactory<io.netty.buffer.ByteBuf>
Represents a factory to createBuffer
instances from wrappedByteBuf
instances.
-
-
Constructor Summary
Constructors Constructor Description NettyBufferFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Buffer
create(io.netty.buffer.ByteBuf value)
Creates a newBuffer
given aBufferFactory
instance.static void
readRaw(Buffer buffer, Consumer<io.netty.buffer.ByteBuf> consumer)
Utility method to allow reading from the underlying bytes using a NettyByteBuf
instance for interoperability, advancing the reader index of theBuffer
after the consumer is called.Buffer
wrap(ByteBuffer value)
Wraps a NIO buffer.static void
writeRaw(Buffer buffer, Consumer<io.netty.buffer.ByteBuf> consumer)
Allows writing from the underlying bytes using a NettyByteBuf
instance for interoperability, advancing the writer index of theBuffer
after the consumer is called.
-
-
-
Method Detail
-
create
public Buffer create(io.netty.buffer.ByteBuf value)
Description copied from interface:BufferFactory
Creates a newBuffer
given aBufferFactory
instance.- Specified by:
create
in interfaceBufferFactory<io.netty.buffer.ByteBuf>
- Returns:
-
wrap
public Buffer wrap(ByteBuffer value)
Description copied from interface:BufferFactory
Wraps a NIO buffer.- Specified by:
wrap
in interfaceBufferFactory<io.netty.buffer.ByteBuf>
-
readRaw
public static void readRaw(Buffer buffer, Consumer<io.netty.buffer.ByteBuf> consumer)
Utility method to allow reading from the underlying bytes using a NettyByteBuf
instance for interoperability, advancing the reader index of theBuffer
after the consumer is called. Note that theByteBuf
used by the consumer should not be released by the caller. In case the providedBuffer
instance is not aNettyBuffer
, it will create aByteBuf
wrapper for the consumer to use, releasing it after use.
-
writeRaw
public static void writeRaw(Buffer buffer, Consumer<io.netty.buffer.ByteBuf> consumer)
Allows writing from the underlying bytes using a NettyByteBuf
instance for interoperability, advancing the writer index of theBuffer
after the consumer is called. Note that theByteBuf
used by the consumer should not be released by the caller. In case the providedBuffer
instance is not aNettyBuffer
, it will create aByteBuf
wrapper for the consumer to use, releasing it after use.
-
-