Class BytesRefStreamOutput

java.lang.Object
java.io.OutputStream
org.elasticsearch.common.io.stream.StreamOutput
org.elasticsearch.common.io.stream.BytesRefStreamOutput
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, org.apache.lucene.util.Accountable

public class BytesRefStreamOutput extends StreamOutput implements org.apache.lucene.util.Accountable
A @link StreamOutput that is backed by a BytesRef. This is useful for small data, for larger or unknown sizes use BytesStreamOutput instead. Compared to BytesStreamOutput this class avoids copying the bytes ref. Compared to BytesRefBuilder this class supports writing all the rich data types that StreamOutput supports.
  • Constructor Details

    • BytesRefStreamOutput

      public BytesRefStreamOutput()
  • Method Details

    • get

      public org.apache.lucene.util.BytesRef get()
    • position

      public long position()
      Overrides:
      position in class StreamOutput
    • writeByte

      public void writeByte(byte b)
      Description copied from class: StreamOutput
      Writes a single byte.
      Specified by:
      writeByte in class StreamOutput
    • writeBytes

      public void writeBytes(byte[] b, int offset, int length)
      Description copied from class: StreamOutput
      Writes an array of bytes.
      Specified by:
      writeBytes in class StreamOutput
      Parameters:
      b - the bytes to write
      offset - the offset in the byte array
      length - the number of bytes to write
    • flush

      public void flush()
      Description copied from class: StreamOutput
      Forces any buffered output to be written.
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in class StreamOutput
    • close

      public void close()
      Closes this stream to further operations. This is a no-op, as the underlying BytesRefBuilder has no IO resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class StreamOutput
    • reset

      public void reset()
    • ramBytesUsed

      public long ramBytesUsed()
      Specified by:
      ramBytesUsed in interface org.apache.lucene.util.Accountable