Class BytesStreamOutput

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Direct Known Subclasses:

public class BytesStreamOutput extends BytesStream
A @link StreamOutput that uses BigArrays to acquire pages of bytes, which avoids frequent reallocation & copying of the internal data.
  • Field Details

  • Constructor Details

    • BytesStreamOutput

      public BytesStreamOutput()
      Create a non recycling BytesStreamOutput with an initial capacity of 0.
    • BytesStreamOutput

      public BytesStreamOutput(int expectedSize)
      Create a non recycling BytesStreamOutput with enough initial pages acquired to satisfy the capacity given by expected size.
      expectedSize - the expected maximum size of the stream in bytes.
    • BytesStreamOutput

      protected BytesStreamOutput(int expectedSize, BigArrays bigArrays)
  • Method Details

    • position

      public long position()
      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
      b - the bytes to write
      offset - the offset in the byte array
      length - the number of bytes to write
    • reset

      public void reset()
      Specified by:
      reset in class StreamOutput
    • 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
    • seek

      public void seek(long position)
      seek in class StreamOutput
    • skip

      public void skip(int length)
    • close

      public void close()
      Description copied from class: StreamOutput
      Closes this stream to further operations.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class StreamOutput
    • size

      public int size()
      Returns the current size of the buffer.
      the value of the count field, which is the number of valid bytes in this output stream.
      See Also:
    • bytes

      public BytesReference bytes()
      Specified by:
      bytes in class BytesStream
    • copyBytes

      public BytesReference copyBytes()
      Like bytes() but copies the bytes to a freshly allocated buffer.
      copy of the bytes in this instances
    • ramBytesUsed

      public long ramBytesUsed()
      Returns the number of bytes used by the underlying ByteArray
      See Also:
      • Accountable.ramBytesUsed()
    • ensureCapacity

      protected void ensureCapacity(long offset)