ByteArray (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.io.file.tfile, class: ByteArray

Package org.apache.hadoop.io.file.tfile

# Class ByteArray

java.lang.Object
org.apache.hadoop.io.file.tfile.ByteArray

All Implemented Interfaces:
  `RawComparable`

@Private @Unstable public final class ByteArray extends Object implements RawComparable
Adaptor class to wrap byte-array backed objects (including java byte array) as RawComparable objects.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ByteArray(byte[] buffer)`
  Wrap a whole byte array as a RawComparable.
  `ByteArray(byte[] buffer, int offset, int len)`
  Wrap a partial byte array as a RawComparable.
  `ByteArray(BytesWritable other)`
  Constructing a ByteArray from a `BytesWritable`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `byte[]`
  `buffer()`
  Get the underlying byte array.
  `int`
  `offset()`
  Get the offset of the first byte in the byte array.
  `int`
  `size()`
  Get the size of the byte range in the byte array.

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

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

- ## Constructor Details

  - ### ByteArray

    public ByteArray(BytesWritable other)
    Constructing a ByteArray from a `BytesWritable`.
    Parameters:
      `other` - other.

  - ### ByteArray

    public ByteArray(byte[] buffer)
    Wrap a whole byte array as a RawComparable.
    Parameters:
      `buffer` - the byte array buffer.

  - ### ByteArray

    public ByteArray(byte[] buffer, int offset, int len)
    Wrap a partial byte array as a RawComparable.
    Parameters:
      `buffer` - the byte array buffer.
      `offset` - the starting offset
      `len` - the length of the consecutive bytes to be wrapped.

- ## Method Details

  - ### buffer

    public byte[] buffer()
    Description copied from interface: `RawComparable`
    Get the underlying byte array.
    Specified by:
      `buffer` in interface `RawComparable`
    Returns:
      the underlying buffer.

  - ### offset

    public int offset()
    Description copied from interface: `RawComparable`
    Get the offset of the first byte in the byte array.
    Specified by:
      `offset` in interface `RawComparable`
    Returns:
      the offset in the buffer.

  - ### size

    public int size()
    Description copied from interface: `RawComparable`
    Get the size of the byte range in the byte array.
    Specified by:
      `size` in interface `RawComparable`
    Returns:
      the size of the byte array.