Interface ByteRange

  • All Superinterfaces:
    java.lang.Comparable<ByteRange>
    All Known Subinterfaces:
    PositionedByteRange
    All Known Implementing Classes:
    AbstractByteRange, AbstractPositionedByteRange, SimpleByteRange, SimplePositionedByteRange, SimplePositionedMutableByteRange

    public interface ByteRange
    extends java.lang.Comparable<ByteRange>
    Lightweight, reusable class for specifying ranges of byte[]'s.

    ByteRange maintains an underlying byte[] and a viewport into that byte[] as a range of bytes. The ByteRange is a mutable, reusable object, so the underlying byte[] can be modified after instantiation. This is done using the set(byte[]) and unset() methods. Direct access to the byte[] is also available via getBytes(). The viewport is defined by an offset into the byte[] and a length. The range of bytes is 0-indexed, and is accessed by index via the get(int) and put(int, byte) methods.

    This interface differs from ByteBuffer:

  • On-heap bytes only
  • Raw byte access only; does not encode other primitives.
  • Implements equals(Object), #hashCode(), and #compareTo(ByteRange) so that it can be used in standard java Collections. Comparison operations are lexicographic, which is native to HBase.
  • Allows the addition of simple core methods like the deep and shallow copy methods.
  • Can be reused in tight loops like a major compaction which can save significant amounts of garbage. (Without reuse, we throw off garbage like this thing.)
  • Mutable, and always evaluates #equals(Object), #hashCode(), and #compareTo(ByteRange) based on the current contents.

    Can contain convenience methods for comparing, printing, cloning, spawning new arrays, copying to other arrays, etc. Please place non-core methods into ByteRangeUtils.