Class BinaryValues

java.lang.Object
dev.hardwood.reader.BinaryValues

@Experimental public final class BinaryValues extends Object

The values of a BYTE_ARRAY, FIXED_LEN_BYTE_ARRAY or INT96 leaf in a ColumnReader's batch, from ColumnReader.getBinaryValues(). Value i is the i-th leaf value, i in [0, size()). A null value has length 0 (see ColumnReader.getLeafValidity()), and getBinary(int) returns an empty array for it.

Value i occupies [start(i), end(i)) of buffer(i). A loop over a value's bytes reads that range of the array:

BinaryValues values = column.getBinaryValues();
for (int i = 0; i < values.size(); i++) {
    byte[] buffer = values.buffer(i);
    for (int p = values.start(i); p < values.end(i); p++) {
        consume(buffer[p]);
    }
}

buffer(i) is an array value i can be read from. Do not write to it: the array of a dictionary-encoded value holds the dictionary's entries, which every batch drawing on that dictionary reads, so a write changes values of earlier and later batches as well. Values may or may not share an array, within a batch or across batches, and nothing is promised about which array a value is read from or about bytes outside its range.

This API is Experimental: it may change in future releases without prior deprecation.

  • Method Details

    • size

      public int size()
      The number of values, ColumnReader.getValueCount().
    • buffer

      public byte[] buffer(int i)
      The array value i is read from.
      Throws:
      IndexOutOfBoundsException - if i is not in [0, size())
    • start

      public int start(int i)
      Where value i starts in buffer(int), inclusive.
      Throws:
      IndexOutOfBoundsException - if i is not in [0, size())
    • end

      public int end(int i)
      Where value i ends in buffer(int), exclusive.
      Throws:
      IndexOutOfBoundsException - if i is not in [0, size())
    • length

      public int length(int i)
      The length of value i in bytes.
      Throws:
      IndexOutOfBoundsException - if i is not in [0, size())
    • copyTo

      public void copyTo(int i, byte[] dst, int dstOffset)
      Copies value i into dst, from dstOffset on.
      Throws:
      IndexOutOfBoundsException - if i is not in [0, size()), or the value does not fit in dst from dstOffset on
    • contentEquals

      public boolean contentEquals(int i, byte[] other, int offset, int length)
      Whether value i equals the bytes [offset, offset + length) of other.
      Throws:
      IndexOutOfBoundsException - if i is not in [0, size()), or the range is not within other
      IllegalArgumentException - if length is negative
    • getBinary

      public byte[] getBinary(int i)
      A copy of value i.
      Throws:
      IndexOutOfBoundsException - if i is not in [0, size())