Class ByteBufferReference

java.lang.Object
org.elasticsearch.common.bytes.AbstractBytesReference
org.elasticsearch.common.bytes.ByteBufferReference
All Implemented Interfaces:
java.lang.Comparable<BytesReference>, BytesReference, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment

public class ByteBufferReference
extends AbstractBytesReference
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 Buffer.position() and Buffer.limit() at construction time. If the position or limit of the underlying byte buffer is changed, those changes will not be reflected in this reference. Any changes to the underlying data in the byte buffer will be reflected in this reference.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent

    org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
  • Field Summary

    Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent

    EMPTY_PARAMS
  • Method Summary

    Modifier and Type Method Description
    byte get​(int index)
    Returns the byte at the specified index.
    int getInt​(int index)
    Returns the integer read from the 4 bytes (BE) starting at the given index.
    int indexOf​(byte marker, int from)
    Finds the index of the first occurrence of the given marker between within the given bounds.
    int length()
    The length.
    long ramBytesUsed()
    The amount of memory used by this BytesReference
    BytesReference slice​(int from, int length)
    Slice the bytes from the from index up to length.
    org.apache.lucene.util.BytesRef toBytesRef()
    This will return a bytes ref composed of the bytes.

    Methods inherited from class org.elasticsearch.common.bytes.AbstractBytesReference

    compareTo, equals, hashCode, iterator, streamInput, toXContent, utf8ToString, writeTo

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment

    isFragment
  • Method Details

    • get

      public byte get​(int index)
      Description copied from interface: BytesReference
      Returns the byte at the specified index. Need to be between 0 and length.
    • getInt

      public int getInt​(int index)
      Description copied from interface: BytesReference
      Returns the integer read from the 4 bytes (BE) starting at the given index.
      Specified by:
      getInt in interface BytesReference
      Overrides:
      getInt in class AbstractBytesReference
    • indexOf

      public int indexOf​(byte marker, int from)
      Description copied from interface: BytesReference
      Finds the index of the first occurrence of the given marker between within the given bounds.
      Specified by:
      indexOf in interface BytesReference
      Overrides:
      indexOf in class AbstractBytesReference
      Parameters:
      marker - marker byte to search
      from - lower bound for the index to check (inclusive)
      Returns:
      first index of the marker or -1 if not found
    • length

      public int length()
      Description copied from interface: BytesReference
      The length.
    • slice

      public BytesReference slice​(int from, int length)
      Description copied from interface: BytesReference
      Slice the bytes from the from index up to length.
    • 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.
      Returns:
      the bytes ref
    • ramBytesUsed

      public long ramBytesUsed()
      Description copied from interface: BytesReference
      The amount of memory used by this BytesReference