Class ByteBufferReference

  • All Implemented Interfaces:
    java.lang.Comparable<BytesReference>, ToXContent, ToXContentFragment

    public class ByteBufferReference
    extends BytesReference
    This is a BytesReference backed by a ByteBuffer. The byte buffer can either be a heap or direct byte buffer. The reference is composed of the space between the ByteBuffer.position(int) and ByteBuffer.limit(int) at construction time. If the position or limit of the underlying byte buffer is changed, those changes will not be reflected in this reference. However, modifying the limit or position of the underlying byte buffer is not recommended as those can be used during ByteBuffer.get() bounds checks. Use ByteBuffer.duplicate() at creation time if you plan on modifying the markers of the underlying byte buffer. Any changes to the underlying data in the byte buffer will be reflected.
    • Constructor Detail

      • ByteBufferReference

        public ByteBufferReference​(java.nio.ByteBuffer buffer)
    • Method Detail

      • get

        public byte get​(int index)
        Description copied from class: BytesReference
        Returns the byte at the specified index. Need to be between 0 and length.
        Specified by:
        get in class BytesReference
      • toBytesRef

        public org.apache.lucene.util.BytesRef toBytesRef()
        This will return a bytes ref composed of the bytes. If this is a direct byte buffer, the bytes will have to be copied.
        Specified by:
        toBytesRef in class BytesReference
        Returns:
        the bytes ref