Package org.apache.lucene.store

# Class ByteBuffersDataInput

java.lang.Object
org.apache.lucene.store.DataInput
org.apache.lucene.store.ByteBuffersDataInput

All Implemented Interfaces:
  `Cloneable`, `RandomAccessInput`, `Accountable`

public final class ByteBuffersDataInput extends DataInput implements Accountable, RandomAccessInput
A `DataInput` implementing `RandomAccessInput` and reading data from a list of `ByteBuffer`s.

- ## Field Summary

  ### Fields inherited from interface org.apache.lucene.util.Accountable

  `NULL_ACCOUNTABLE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ByteBuffersDataInput(List<ByteBuffer> buffers)`
  Read data from a set of contiguous buffers.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `length()`
  The number of bytes in the file.
  `long`
  `position()`
  `long`
  `ramBytesUsed()`
  Return the memory usage of this object in bytes.
  `byte`
  `readByte()`
  Reads and returns a single byte.
  `byte`
  `readByte(long pos)`
  Reads a byte at the given position in the file
  `void`
  `readBytes(byte[] arr, int off, int len)`
  Reads a specified number of bytes into an array at the specified offset.
  `void`
  `readBytes(long pos, byte[] bytes, int offset, int len)`
  Reads a specified number of bytes starting at a given position into an array at the specified offset.
  `void`
  `readBytes(ByteBuffer buffer, int len)`
  Reads exactly `len` bytes into the given buffer.
  `void`
  `readFloats(float[] arr, int off, int len)`
  Reads a specified number of floats into an array at the specified offset.
  `int`
  `readInt()`
  Reads four bytes and returns an int (LE byte order).
  `int`
  `readInt(long pos)`
  Reads an integer (LE byte order) at the given position in the file
  `long`
  `readLong()`
  Reads eight bytes and returns a long (LE byte order).
  `long`
  `readLong(long pos)`
  Reads a long (LE byte order) at the given position in the file
  `void`
  `readLongs(long[] arr, int off, int len)`
  Read a specified number of longs.
  `short`
  `readShort()`
  Reads two bytes and returns a short (LE byte order).
  `short`
  `readShort(long pos)`
  Reads a short (LE byte order) at the given position in the file
  `void`
  `seek(long position)`
  `void`
  `skipBytes(long numBytes)`
  Skip over `numBytes` bytes.
  `ByteBuffersDataInput`
  `slice(long offset, long length)`
  `String`
  `toString()`

  ### Methods inherited from class org.apache.lucene.store.DataInput

  `clone, readBytes, readGroupVInt, readInts, readMapOfStrings, readSetOfStrings, readString, readVInt, readVLong, readZInt, readZLong`

  ### Methods inherited from class java.lang.Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.apache.lucene.util.Accountable

  `getChildResources`

  ### Methods inherited from interface org.apache.lucene.store.RandomAccessInput

  `isLoaded, prefetch`

- ## Constructor Details

  - ### ByteBuffersDataInput

    public ByteBuffersDataInput(List<ByteBuffer> buffers)
    Read data from a set of contiguous buffers. All data buffers except for the last one must have an identical remaining number of bytes in the buffer (that is a power of two). The last buffer can be of an arbitrary remaining length.

- ## Method Details

  - ### 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`

  - ### readByte

    public byte readByte() throws EOFException
    Description copied from class: `DataInput`
    Reads and returns a single byte.
    Specified by:
      `readByte` in class `DataInput`
    Throws:
      `EOFException`
    See Also:
      - `DataOutput.writeByte(byte)`

  - ### readBytes

    public void readBytes(ByteBuffer buffer, int len) throws EOFException
    Reads exactly `len` bytes into the given buffer. The buffer must have enough remaining limit.

    If there are fewer than `len` bytes in the input, `EOFException` is thrown.

    Throws:
      `EOFException`

  - ### readBytes

    public void readBytes(byte[] arr, int off, int len) throws EOFException
    Description copied from class: `DataInput`
    Reads a specified number of bytes into an array at the specified offset.
    Specified by:
      `readBytes` in class `DataInput`
    Parameters:
      `arr` - the array to read bytes into
      `off` - the offset in the array to start storing bytes
      `len` - the number of bytes to read
    Throws:
      `EOFException`
    See Also:
      - `DataOutput.writeBytes(byte[],int)`

  - ### readShort

    public short readShort() throws IOException
    Description copied from class: `DataInput`
    Reads two bytes and returns a short (LE byte order).
    Overrides:
      `readShort` in class `DataInput`
    Throws:
      `IOException`
    See Also:
      - `DataOutput.writeShort(short)`
      - `BitUtil.VH_LE_SHORT`

  - ### readInt

    public int readInt() throws IOException
    Description copied from class: `DataInput`
    Reads four bytes and returns an int (LE byte order).
    Overrides:
      `readInt` in class `DataInput`
    Throws:
      `IOException`
    See Also:
      - `DataOutput.writeInt(int)`
      - `BitUtil.VH_LE_INT`

  - ### readLong

    public long readLong() throws IOException
    Description copied from class: `DataInput`
    Reads eight bytes and returns a long (LE byte order).
    Overrides:
      `readLong` in class `DataInput`
    Throws:
      `IOException`
    See Also:
      - `DataOutput.writeLong(long)`
      - `BitUtil.VH_LE_LONG`

  - ### length

    public long length()
    Description copied from interface: `RandomAccessInput`
    The number of bytes in the file.
    Specified by:
      `length` in interface `RandomAccessInput`

  - ### readByte

    public byte readByte(long pos)
    Description copied from interface: `RandomAccessInput`
    Reads a byte at the given position in the file
    Specified by:
      `readByte` in interface `RandomAccessInput`
    See Also:
      - `DataInput.readByte()`

  - ### readBytes

    public void readBytes(long pos, byte[] bytes, int offset, int len) throws IOException
    Description copied from interface: `RandomAccessInput`
    Reads a specified number of bytes starting at a given position into an array at the specified offset.
    Specified by:
      `readBytes` in interface `RandomAccessInput`
    Throws:
      `IOException`
    See Also:
      - `DataInput.readBytes(byte[], int, int)`

  - ### readShort

    public short readShort(long pos)
    Description copied from interface: `RandomAccessInput`
    Reads a short (LE byte order) at the given position in the file
    Specified by:
      `readShort` in interface `RandomAccessInput`
    See Also:
      - `DataInput.readShort()`
      - `BitUtil.VH_LE_SHORT`

  - ### readInt

    public int readInt(long pos)
    Description copied from interface: `RandomAccessInput`
    Reads an integer (LE byte order) at the given position in the file
    Specified by:
      `readInt` in interface `RandomAccessInput`
    See Also:
      - `DataInput.readInt()`
      - `BitUtil.VH_LE_INT`

  - ### readLong

    public long readLong(long pos)
    Description copied from interface: `RandomAccessInput`
    Reads a long (LE byte order) at the given position in the file
    Specified by:
      `readLong` in interface `RandomAccessInput`
    See Also:
      - `DataInput.readLong()`
      - `BitUtil.VH_LE_LONG`

  - ### readFloats

    public void readFloats(float[] arr, int off, int len) throws EOFException
    Description copied from class: `DataInput`
    Reads a specified number of floats into an array at the specified offset.
    Overrides:
      `readFloats` in class `DataInput`
    Parameters:
      `arr` - the array to read bytes into
      `off` - the offset in the array to start storing floats
      `len` - the number of floats to read
    Throws:
      `EOFException`

  - ### readLongs

    public void readLongs(long[] arr, int off, int len) throws EOFException
    Description copied from class: `DataInput`
    Read a specified number of longs.
    Overrides:
      `readLongs` in class `DataInput`
    Throws:
      `EOFException`

  - ### position

    public long position()

  - ### seek

    public void seek(long position) throws EOFException
    Throws:
      `EOFException`

  - ### skipBytes

    public void skipBytes(long numBytes) throws IOException
    Description copied from class: `DataInput`
    Skip over `numBytes` bytes. This method may skip bytes in whatever way is most optimal, and may not have the same behavior as reading the skipped bytes. In general, negative `numBytes` are not supported.
    Specified by:
      `skipBytes` in class `DataInput`
    Throws:
      `IOException`

  - ### slice

    public ByteBuffersDataInput slice(long offset, long length)

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`