Class NettyBufferFactory

java.lang.Object
org.apache.tinkerpop.gremlin.util.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 create Buffer instances from wrapped ByteBuf instances.
  • Constructor Details

    • NettyBufferFactory

      public NettyBufferFactory()
  • Method Details

    • create

      public Buffer create(io.netty.buffer.ByteBuf value)
      Description copied from interface: BufferFactory
      Creates a new Buffer given a BufferFactory instance.
      Specified by:
      create in interface BufferFactory<io.netty.buffer.ByteBuf>
      Returns:
    • wrap

      public Buffer wrap(ByteBuffer value)
      Description copied from interface: BufferFactory
      Wraps a NIO buffer.
      Specified by:
      wrap in interface BufferFactory<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 Netty ByteBuf instance for interoperability, advancing the reader index of the Buffer after the consumer is called. Note that the ByteBuf used by the consumer should not be released by the caller. In case the provided Buffer instance is not a NettyBuffer, it will create a ByteBuf 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 Netty ByteBuf instance for interoperability, advancing the writer index of the Buffer after the consumer is called. Note that the ByteBuf used by the consumer should not be released by the caller. In case the provided Buffer instance is not a NettyBuffer, it will create a ByteBuf wrapper for the consumer to use, releasing it after use.