Polars Shares Columns Instead of Copying Them: Arc, Bytes and Reference Counting
Column bytes live in refcounted buffers; sharing a column clones handles, and the Arrow FFI imports foreign memory by keeping the C array alive as the buffer’s owner.
Column bytes live in refcounted buffers; sharing a column clones handles, and the Arrow FFI imports foreign memory by keeping the C array alive as the buffer’s owner.
The View type packs a 4-byte length, 4-byte prefix, buffer index and offset into 16 bytes, and inlines any string of 12 bytes or less directly into those bytes.
Arrow’s RowConverter encodes each key column into a byte layout where lexicographic row order equals byte order, turning a multi-column sort key comparison into a single memcmp.
The buffer layer of Polars is deliberately dumb: an immutable (ptr, length) view over a hand-rolled refcounted storage, with all growth pushed into the mutable builders.
A dictionary column is a pre-built hash cache: DataFusion hashes each distinct dictionary value once, scatters those hashes to the keys, and memoizes value-index to group-slot so …