Class GrowableByteArrayDataOutput

java.lang.Object
org.apache.lucene.store.DataOutput
org.apache.lucene.store.GrowableByteArrayDataOutput
All Implemented Interfaces:
Accountable

public final class GrowableByteArrayDataOutput extends DataOutput implements Accountable
A DataOutput that can be used to build a byte[].
  • Field Details

    • MIN_UTF8_SIZE_TO_ENABLE_DOUBLE_PASS_ENCODING

      static final int MIN_UTF8_SIZE_TO_ENABLE_DOUBLE_PASS_ENCODING
      Minimum utf8 byte size of a string over which double pass over string is to save memory during encode
      See Also:
    • bytes

      private byte[] bytes
      The bytes
    • length

      private int length
      The length
    • scratchBytes

      private byte[] scratchBytes
  • Constructor Details

    • GrowableByteArrayDataOutput

      public GrowableByteArrayDataOutput(int cp)
      Create a GrowableByteArrayDataOutput with the given initial capacity.
  • Method Details

    • writeByte

      public void writeByte(byte b)
      Description copied from class: DataOutput
      Writes a single byte.

      The most primitive data type is an eight-bit byte. Files are accessed as sequences of bytes. All other data types are defined as sequences of bytes, so file formats are byte-order independent.

      Specified by:
      writeByte in class DataOutput
      See Also:
    • writeBytes

      public void writeBytes(byte[] b, int off, int len)
      Description copied from class: DataOutput
      Writes an array of bytes.
      Specified by:
      writeBytes in class DataOutput
      Parameters:
      b - the bytes to write
      off - the offset in the byte array
      len - the number of bytes to write
      See Also:
    • writeString

      public void writeString(String string) throws IOException
      Description copied from class: DataOutput
      Writes a string.

      Writes strings as UTF-8 encoded bytes. First the length, in bytes, is written as a VInt, followed by the bytes.

      Overrides:
      writeString in class DataOutput
      Throws:
      IOException
      See Also:
    • getBytes

      public byte[] getBytes()
    • getPosition

      public int getPosition()
    • reset

      public void reset()
    • ramBytesUsed

      public long ramBytesUsed()
      Description copied from interface: Accountable
      Return the memory usage of this object in bytes. Negative values are illegal.
      Specified by:
      ramBytesUsed in interface Accountable