Skip to main content

Module binary

Module binary 

Source
Expand description

GenericBinaryArray — the variable-length byte column, in its Binary (32-bit offsets) and LargeBinary (64-bit offsets) forms.

§Layout

  offsets  [o0, o1, o2, … , oN]     N + 1 entries, non-decreasing
  values   ├──v0──┼───v1───┼─v2─┤   one flat byte region
  validity  1      0        1        optional, one bit per value

Slicing narrows the offset buffer and leaves the value region alone, so a sliced array’s first offset is not zero. That is legal Arrow and it is what keeps slicing O(1): no bytes move and no offsets are rewritten. validate_offsets therefore accepts any non-decreasing, in-range offset sequence rather than insisting on a leading zero.

use astrs_data::array::{Array, BinaryArray};

let blobs = BinaryArray::from_opt_iter([Some(&b"aa"[..]), None, Some(&b"cccc"[..])]);
assert_eq!(blobs.len(), 3);
assert_eq!(blobs.get(0), Some(&b"aa"[..]));
assert_eq!(blobs.get(1), None);
assert_eq!(blobs.value_length(2), Some(4));

let tail = blobs.slice(2, 1);
assert_eq!(tail.get(0), Some(&b"cccc"[..]));

Structs§

GenericBinaryArray
A column of variable-length byte strings.

Type Aliases§

BinaryArray
Binary column — variable-length bytes with 32-bit offsets.
LargeBinaryArray
LargeBinary column — variable-length bytes with 64-bit offsets.