Class CompositeBytesReference

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

public final class CompositeBytesReference extends AbstractBytesReference
A composite BytesReference that allows joining multiple bytes references into one without copying. Note, toBytesRef() will materialize all pages in this BytesReference.
  • Method Details

    • of

      public static BytesReference of(BytesReference... references)
    • 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.
    • 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()
      Description copied from interface: BytesReference
      Converts to Lucene BytesRef.
    • iterator

      public org.apache.lucene.util.BytesRefIterator iterator()
      Description copied from interface: BytesReference
      Returns a BytesRefIterator for this BytesReference. This method allows access to the internal pages of this reference without copying them. Use with care!
      Specified by:
      iterator in interface BytesReference
      Overrides:
      iterator in class AbstractBytesReference
      See Also:
      • BytesRefIterator
    • writeTo

      public void writeTo(OutputStream os) throws IOException
      Description copied from interface: BytesReference
      Writes the bytes directly to the output stream.
      Specified by:
      writeTo in interface BytesReference
      Overrides:
      writeTo in class AbstractBytesReference
      Throws:
      IOException
    • ramBytesUsed

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