private static ByteBuf getFromIndex(final Buffer buffer, final int index) {
        if (buffer.nioBufferCount() == 1) {
            // Heap and direct buffers usually take a single buffer
            // It will create a new ByteBuf using the same backing byte array
            return Unpooled.wrappedBuffer(buffer.nioBuffer(index, buffer.capacity() - index));
        }

        // Use a wrapper or composite buffer
        return Unpooled.wrappedBuffer(buffer.nioBuffers(index, buffer.capacity() - index));
    }
Represents a factory to create {@link Buffer} instances from wrapped {@link ByteBuf} instances.
gremlin-util/src/main/java/org/apache/tinkerpop/gremlin/util/ser/NettyBufferFactory.java