package granary

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Granary_encoding.Null_bitmapSource

Bitmap helpers for null-mask encoding.

Used by Granary_columnar.Col for columnar null bitmaps. Intended to also replace the inline bitmap logic in Granary_encoding.Row once the API is adapted (see issue #372).

Sourcemodule Bigarray = Bigarray

pack_bits bits n packs the first n elements of bits into a big-endian bitmask byte string. Each byte encodes 8 entries: bit 0 of byte 0 = bits0, bit 1 = bits1, etc.

Sourceval pack_bits_into : Buffer.t -> (int, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t -> int -> unit

pack_bits_into buf bits n writes a packed bitmask directly into buf, one byte per 8 entries, without materialising an intermediate Bytes.t.

Sourceval unpack_bits : bytes -> int -> int -> (int, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t

unpack_bits buf off n reads ceil(n/8) bytes from buf starting at off and unpacks them into a fresh bigarray of length n.

Sourceval pack_bits_of_bools : (int -> bool) -> int -> bytes

pack_bits_of_bools is_null n packs the predicate is_null applied to indices 0, n-1 into a big-endian bitmask byte string. Each byte encodes 8 entries: bit 0 of byte 0 = is_null(0), bit 1 = is_null(1), etc.

Sourceval unpack_bits_to_bools : bytes -> int -> int -> bool array

unpack_bits_to_bools buf off n reads ceil(n/8) bytes from buf at off and returns a bool array of length n where element i is true iff bit i of the bitmask is set.