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.

### Constructor Summary

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

### Method Summary

All Methods Instance Methods Concrete Methods
`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(ByteBuffer buffer, int len)` Reads exactly `len` bytes into the given buffer.
`int` `readInt(long pos)` Reads an integer at the given position in the file
`long` `readLong(long pos)` Reads a long at the given position in the file
`short` `readShort(long pos)` Reads a short at the given position in the file
`void` `seek(long position)`
`long` `size()`
`ByteBuffersDataInput` `slice(long offset, long length)`
`String` `toString()`

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

`clone, readBytes, readInt, readLELongs, readLong, readMapOfStrings, readSetOfStrings, readShort, readString, readVInt, readVLong, readZInt, readZLong, skipBytes`

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

### Constructor Detail

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

#### size

    public long size()

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

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

#### readShort

    public short readShort(long pos)

Description copied from interface: `RandomAccessInput`
Reads a short at the given position in the file

Specified by:
  `readShort` in interface `RandomAccessInput`
See Also:
  `DataInput.readShort()`

#### readInt

    public int readInt(long pos)

Description copied from interface: `RandomAccessInput`
Reads an integer at the given position in the file

Specified by:
  `readInt` in interface `RandomAccessInput`
See Also:
  `DataInput.readInt()`

#### readLong

    public long readLong(long pos)

Description copied from interface: `RandomAccessInput`
Reads a long at the given position in the file

Specified by:
  `readLong` in interface `RandomAccessInput`
See Also:
  `DataInput.readLong()`

#### position

    public long position()

#### seek

    public void seek(long position)
              throws EOFException

Throws:
  `EOFException`

#### slice

    public ByteBuffersDataInput slice(long offset,
                                      long length)

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`