ihb2032/MoonFrame/column does not have a README file

    Bitmap

    pub struct Bitmap {
    bits : Bytes
    offset : Int
    len : Int
    } derive(
    Debug
    )

    Apache Arrow compatible validity bitmap.

    Bits are packed into bytes, 1 bit per row, 1 = valid, 0 = null. Logical slot i lives at physical bit offset + i: byte bits[(offset + i) / 8], bit position (offset + i) % 8, where bit 0 is the least-significant bit of the byte. offset is 0 for every bitmap a constructor builds (each packs a tight buffer of exactly ⌈len / 8⌉ bytes, with the trailing bits past len kept zero); a zero-copy slice instead shares its parent's buffer and advances offset, so a view's buffer may be longer than ⌈len / 8⌉ bytes and hold sibling bits outside [offset, offset + len). Bytes is immutable, so sharing one buffer across views is safe. Equality is logical — over the [offset, offset + len) window — and null_count counts only that window.

    The convention 1 = valid matches the Apache Arrow specification (and arrow-rs, pyarrow); note that some MoonBit ecosystem libraries (e.g. smallbearrr/pandas) use the opposite convention.
    impl Eq for Bitmap

    Bitmap::all_null

    fn Bitmap::all_null(len : Int) -> Bitmap

    All len slots marked null. A negative len clamps to 0, exactly as in all_valid (and for the same reason).

    Bitmap::all_valid

    fn Bitmap::all_valid(len : Int) -> Bitmap

    All len slots marked valid. A negative len clamps to 0 (an empty bitmap): these two constructors are the only place a caller-supplied length becomes a bitmap's len, and a negative len stored verbatim would desynchronise len from the (empty) buffer — null_count's tail-byte read would then index past it and abort, the one failure mode the never-abort rule forbids.

    Bitmap::bit_and

    Bitwise AND across two bitmaps of the same logical length — a public utility for combining two validity masks into one. Named bit_and because and is a reserved keyword in MoonBit. Raises LengthMismatch if the lengths differ.

    Bitmap::from_bools

    fn Bitmap::from_bools(values : Array[Bool]) -> Bitmap

    true ↦ valid, false ↦ null.

    Bitmap::from_options

    fn[T] Bitmap::from_options(values : Array[T?]) -> Bitmap

    Some(_) ↦ valid, None ↦ null. Works for any element type because only the Some/None shape is inspected.

    Bitmap::is_null

    fn Bitmap::is_null(self : Bitmap, index : Int) -> Bool raise
    DataError

    true when slot index is null (bit is 0). Out-of-bounds raise IndexOutOfBounds.

    Bitmap::is_valid

    fn Bitmap::is_valid(self : Bitmap, index : Int) -> Bool raise
    DataError

    true when slot index is valid (bit is 1). Out-of-bounds raise IndexOutOfBounds.

    Bitmap::is_valid_total

    fn Bitmap::is_valid_total(self : Bitmap, index : Int) -> Bool

    true when slot index is valid (bit 1), total: an out-of-range index yields false instead of raising. The single-slot counterpart of is_valid, for the in-bounds-guaranteed row gathers that read one slot at a time off the source mask rather than materialising the whole Array[Bool] — so a per-group gather costs O(gathered), not O(source).

    Bitmap::len

    fn Bitmap::len(self : Bitmap) -> Int

    Number of logical slots (not bytes).

    Bitmap::null_count

    fn Bitmap::null_count(self : Bitmap) -> Int

    Number of null (0) bits in the logical range [offset, offset + len).

    When offset == 0 the window is byte-aligned at the front, so the full bytes [0, len / 8) are popcounted whole (one popcount_byte per 8 slots) and only the final partial byte is masked down to its in-window bits [0, len % 8). That mask is essential: a zero-copy slice view shares its parent's buffer, so the bits past len in that last byte may be live sibling bits — popcounting them unmasked would over-count valids (and a constructor-built bitmap keeps those bits zero, so the mask is a no-op there). An offset != 0 view has no byte-aligned start, so it counts its window bit by bit.

    Bitmap::slice

    fn Bitmap::slice(self : Bitmap, start : Int, length : Int) -> Bitmap raise
    DataError

    Half-open [start, start + length) slice as a zero-copy view: the result shares this bitmap's underlying buffer and only advances offset by start, so a slice is O(1) with no repacking. Safe because Bytes is immutable. Errors:
    • IndexOutOfBounds(start) if start < 0 or start > len.
    • IndexOutOfBounds(start + length) if start + length > len.
    • InvalidOperation if length < 0.

    Bitmap::take

    fn Bitmap::take(self : Bitmap, indices : Array[Int]) -> Bitmap raise
    DataError

    Gather: produce a new bitmap whose i-th bit is self[indices[i]]. Any out-of-bounds index raise IndexOutOfBounds(idx). Unlike slice, an arbitrary gather can't be expressed as a contiguous view, so take repacks into a fresh tight buffer (reading each source bit through this bitmap's offset).

    Bitmap::to_bools

    fn Bitmap::to_bools(self : Bitmap) -> Array[Bool]

    Materialise the validity mask as a dense Array[Bool] (true = valid), one entry per logical slot in [0, len).

    This is the total counterpart to is_valid for the common case of scanning every slot in order. A loop that has already bounded its index to [0, len) reads the returned array directly (mask[i], the same trust level as the parallel data[i] access) instead of threading a per-element Result through every iteration — which would otherwise force either an unwrap (a panic path) or an unreachable Err arm.

    BuiltinColumn

    pub struct BuiltinColumn {
    data : ColumnData
    validity : Bitmap
    } derive(Eq,
    Debug
    )

    Apache Arrow style columnar storage used by Series in v0.1.

    The column splits values from validity. data is a typed array of raw values (no Option boxing); validity is a bit-packed Bitmap where 1 = valid, 0 = null, matching Arrow's binary layout. Null slots in data carry a per-dtype placeholder (Int = 0, Float = 0.0, Bool = false, String = ""); public methods always consult validity before reading data, so the placeholder never leaks.

    As of v0.3 a ColumnStorage abstraction (plus a NumericColumn for unboxed-numeric fast paths) sits above this layer at the Series backend seam (see storage.mbt); it leaves BuiltinColumn's own public API unchanged — a Series simply holds one of the two backends behind it.

    Numeric columns are 64-bit: the Int variant stores Int64 and the Float variant stores Double, matching Scalar's payloads and the pandas / polars int64 / float64 defaults so reductions neither silently overflow nor lose precision.

    BuiltinColumn::bool_values

    Like int_values but for Bool columns.

    BuiltinColumn::cast

    Cast by target dtype — the single public cross-dtype conversion. Int truncates / parses, Float promotes / parses (per the file-private to_int / to_float helpers this dispatches to), and String renders every dtype through the total to_string_column. Bool and Null targets are unsupported and raise Unsupported.

    BuiltinColumn::data

    The raw backing storage, discriminated by dtype. ColumnData is pub(all), so callers in other packages (sort, stats) match on the concrete element type once and read values totally, rather than cascading through the *_values accessors and unwrap-ing the final branch the type system can't see is exhaustive. The element arrays are shared (read-only), matching int_values / float_values / etc.

    BuiltinColumn::dtype

    The column's logical DataType, read from the data arm.

    BuiltinColumn::float_values

    Like int_values but for Float columns.

    BuiltinColumn::from_bool_options

    fn BuiltinColumn::from_bool_options(values : Array[Bool?]) -> BuiltinColumn

    Build a Bool column where None entries are nulls. None slots receive false as the data placeholder.

    BuiltinColumn::from_bools

    fn BuiltinColumn::from_bools(values : Array[Bool]) -> BuiltinColumn

    Build a Bool column from raw values (no nulls). values is copied, so the column owns its data and is unaffected by later mutation of the array.

    BuiltinColumn::from_float_options

    fn BuiltinColumn::from_float_options(values : Array[Double?]) -> BuiltinColumn

    Build a Float column where None entries are nulls. None slots receive 0.0 as the data placeholder.

    BuiltinColumn::from_floats

    fn BuiltinColumn::from_floats(values : Array[Double]) -> BuiltinColumn

    Build a Float column from raw values (no nulls). values is copied, so the column owns its data and is unaffected by later mutation of the array.

    BuiltinColumn::from_int_options

    fn BuiltinColumn::from_int_options(values : Array[Int64?]) -> BuiltinColumn

    Build an Int column where None entries are nulls. None slots receive 0 as the data placeholder; public APIs never expose it.

    BuiltinColumn::from_ints

    fn BuiltinColumn::from_ints(values : Array[Int64]) -> BuiltinColumn

    Build an Int column from raw values (no nulls). values is copied, so the column owns its data and is unaffected by later mutation of the array.

    BuiltinColumn::from_string_options

    fn BuiltinColumn::from_string_options(values : Array[String?]) -> BuiltinColumn

    Build a String column where None entries are nulls. None slots receive "" as the data placeholder.

    BuiltinColumn::from_strings

    fn BuiltinColumn::from_strings(values : Array[String]) -> BuiltinColumn

    Build a String column from raw values (no nulls). values is copied, so the column owns its data and is unaffected by later mutation of the array.

    BuiltinColumn::get

    Read a single cell as a Scalar. Out-of-bounds index raise IndexOutOfBounds.

    BuiltinColumn::int_values

    Return the underlying raw data array and validity bitmap (no Option boxing). Data at null slots is a placeholder — always consult validity before reading. raise TypeMismatch when the column is not an Int column.

    BuiltinColumn::is_empty

    fn BuiltinColumn::is_empty(self : BuiltinColumn) -> Bool

    true when the column has no cells.

    BuiltinColumn::is_null

    fn BuiltinColumn::is_null(self : BuiltinColumn, index : Int) -> Bool raise
    DataError

    raise IndexOutOfBounds if index is outside [0, len).

    BuiltinColumn::len

    fn BuiltinColumn::len(self : BuiltinColumn) -> Int

    Number of cells.

    BuiltinColumn::null_count

    fn BuiltinColumn::null_count(self : BuiltinColumn) -> Int

    Number of null cells (the count of zero bits in validity).

    BuiltinColumn::placeholders_normalized

    fn BuiltinColumn::placeholders_normalized(self : BuiltinColumn) -> Bool

    Whether every null slot's data holds this dtype's canonical placeholder (Int = 0, Float = 0.0, Bool = false, String = ""). The constructors, casts, and row transforms all write these, so a null slot's value never leaks through data() / the *_values accessors — and, since BuiltinColumn derives Eq over the raw data array (null slots included), two logically equal columns that differed only in a null slot's placeholder would otherwise compare unequal. Surfaced as a predicate so a test can assert the invariant directly instead of trusting each write site by hand. Total — a bounded scan over the validity mask; the data match is wildcard-free, so a future dtype must supply its placeholder here.

    BuiltinColumn::slice

    Half-open [start, end) slice. Requires 0 <= start <= end <= len.

    Errors (checked in this order):
    • IndexOutOfBounds(start) when start < 0.
    • IndexOutOfBounds(end) when end > len.
    • InvalidOperation("slice start > end: ...") when start > end.

    start > len is not a separate case: it can only occur together with end > len (→ IndexOutOfBounds(end)) or start > end (→ InvalidOperation), both already rejected above.

    BuiltinColumn::string_values

    Like int_values but for String columns.

    BuiltinColumn::take

    Gather: produce a new column whose i-th entry is self[indices[i]]. Any out-of-bounds index raise IndexOutOfBounds(idx).

    BuiltinColumn::to_string_column

    fn BuiltinColumn::to_string_column(self : BuiltinColumn) -> BuiltinColumn

    Convert to String. Each valid cell is rendered with the same value-form used by Scalar::to_string (e.g. Int(42) → "42", Bool(true) → "true"). Null slots get an empty placeholder and remain null in the validity bitmap.

    Total: every dtype has a value-form rendering, so there is no failure path. Unlike to_int / to_float (which can fail on out-of-range or malformed input) this never raises.

    BuiltinColumn::validity

    fn BuiltinColumn::validity(self : BuiltinColumn) -> Bitmap

    The validity bitmap (1 = valid). Paired with data for callers that read every slot in order: validity().to_bools() materialises the mask once so a bounded loop indexes it totally, instead of catching a per-slot is_valid raise. The bitmap is shared (read-only).

    ColumnData

    pub(all) enum ColumnData {
    Int(Array[Int64])
    Float(Array[Double])
    Bool(Array[Bool])
    String(Array[String])
    } derive(Eq,
    Debug
    )

    Backing storage discriminated by dtype. The element type is the raw value; nullability is tracked in the enclosing column's validity bitmap.

    ColumnStorage

    pub(all) enum ColumnStorage {
    Builtin(BuiltinColumn)
    Numeric(NumericColumn)
    } derive(
    Debug
    )

    A column behind one of the pluggable backends. Builtin is the general-purpose Arrow column (any dtype, nullable); Numeric is the all-valid unboxed numeric fast path.
    impl Eq for ColumnStorage

    ColumnStorage::bool_values

    Like int_values but for Bool columns. A Numeric column is never Bool, so its arm always raise TypeMismatch.

    ColumnStorage::cast

    Cast to target — the single cross-dtype conversion — routing through to_builtin() so BuiltinColumn's cast machine is reused rather than duplicated on the Numeric arm. The result is Builtin-backed; re-converge with to_numeric() if a numeric target should land back on the fast path. Supported targets and failure modes match BuiltinColumn::cast.

    ColumnStorage::data

    The raw backing storage, discriminated by dtype. Forwarded so the col.storage().data() reads in group_by / join / sort keep compiling unchanged after the Series.storage flip.

    This returns the column's live backing array (no copy), and ColumnData is pub(all) so the engine can match it across packages. Treat the array as read-only: mutating it in place would corrupt the column (and any other column that shares the buffer through zero-copy conversion such as to_numeric). Columns are logically immutable; this accessor exists for reading, not editing.

    ColumnStorage::dtype

    The column's logical DataType, forwarded to the active backend.

    ColumnStorage::float_values

    Like int_values but for Float columns.

    ColumnStorage::from_builtin

    fn ColumnStorage::from_builtin(column : BuiltinColumn) -> ColumnStorage

    Wrap a BuiltinColumn (any dtype, possibly nullable).

    ColumnStorage::from_numeric

    fn ColumnStorage::from_numeric(column : NumericColumn) -> ColumnStorage

    Wrap an all-valid NumericColumn.

    ColumnStorage::get

    Read a single cell as a Scalar. Out-of-bounds index raise IndexOutOfBounds.

    ColumnStorage::int_values

    Raw Int64 array + validity bitmap (the Numeric arm synthesises an all-valid one). raise TypeMismatch on a non-Int column.

    ColumnStorage::is_empty

    fn ColumnStorage::is_empty(self : ColumnStorage) -> Bool

    true when the column has no cells.

    ColumnStorage::is_null

    fn ColumnStorage::is_null(self : ColumnStorage, index : Int) -> Bool raise
    DataError

    Whether cell index is null. Out-of-bounds index raiseIndexOutOfBounds. The Numeric arm is structurally always valid (its is_null only does the bounds check), so the two backends agree on the diagnostic.

    ColumnStorage::kind

    Which backend is in use — the discriminant Series::storage_kind surfaces (S3).

    ColumnStorage::len

    fn ColumnStorage::len(self : ColumnStorage) -> Int

    Number of cells, forwarded to the active backend.

    ColumnStorage::null_count

    fn ColumnStorage::null_count(self : ColumnStorage) -> Int

    Number of null cells — always 0 on the Numeric arm — forwarded to the active backend.

    ColumnStorage::slice

    Half-open [start, end) slice, keeping the backend: a sub-range of an all-valid Numeric column is itself all-valid, so it stays Numeric (no bitmap to repack). Bounds diagnostics match BuiltinColumn::slice / NumericColumn::slice.

    ColumnStorage::slice_total

    fn ColumnStorage::slice_total(self : ColumnStorage, start : Int, end : Int) -> ColumnStorage

    Total [start, end) slice — the no-raise counterpart of slice. Keeps the backend and shares the validity buffer (zero-copy view) on the Builtin arm, exactly as slice does, but out-of-range bounds are clamped into [0, len] (with end lifted to at least start) so it is genuinely total: it never raises and never aborts on a stray index. This is the single slice path behind the total row transforms head / tail / DataFrame::slice, which validate their window once against nrows before slicing each column — so the clamp is a no-op for them, while keeping this public entry abort-free for any other caller (feedback_lib_no_abort).

    ColumnStorage::string_values

    Like int_values but for String columns. A Numeric column is never String, so its arm always raise TypeMismatch.

    ColumnStorage::take

    Gather: output cell i is self[indices[i]], keeping the backend (a gather of an all-valid Numeric column is still all-valid). Any out-of-bounds index raise IndexOutOfBounds(idx).

    ColumnStorage::to_builtin

    fn ColumnStorage::to_builtin(self : ColumnStorage) -> BuiltinColumn

    The column as a BuiltinColumn (the general-purpose Arrow backend). Total: a Builtin is already one; a Numeric widens losslessly via NumericColumn::to_builtin (an all-valid bitmap is synthesised). The escape hatch the cross-dtype transforms route through.

    ColumnStorage::to_numeric

    Move an all-valid Int / Float column onto the Numeric fast-path backend. An already-Numeric column is returned as-is. A Builtin column converts only when it can do so without loss:
    • raise InvalidOperation when it carries any null (a NumericColumn has no validity bitmap, so nulls cannot be represented);
    • raise TypeMismatch when its dtype is Bool / String (the fast path is numeric-only).

    The null-free Int / Float arms reuse the raw data array (it is the true data, every slot being valid), so the move allocates no new buffer.

    ColumnStorage::to_string_column

    fn ColumnStorage::to_string_column(self : ColumnStorage) -> BuiltinColumn

    Render every cell to its String value-form, yielding a String BuiltinColumn. Total — every dtype has a value-form rendering. The result is non-numeric so it is necessarily a BuiltinColumn.

    ColumnStorage::validity

    fn ColumnStorage::validity(self : ColumnStorage) -> Bitmap

    The validity bitmap (1 = valid). The Numeric arm has no stored bitmap, so it synthesises an all-valid one sized to the column — the one point the two backends diverge. Forwarded so the col.storage().validity().to_bools() reads in drop_nulls / group_by / join / sort keep compiling unchanged after the flip.

    NumericColumn

    pub struct NumericColumn {
    data : NumericData
    } derive(Eq,
    Debug
    )

    Unboxed, all-valid numeric column — the null_count == 0 fast path.

    Unlike BuiltinColumn (which always pairs data with a validity Bitmap), NumericColumn carries no bitmap at all: every slot is a present value by construction, so there is nothing to mask. The moment a null enters the picture the column is materialised back into a BuiltinColumn (to_builtin, total + lossless). This mirrors Arrow / Polars, where a buffer with null_count == 0 skips the validity check on the hot path.

    The win is twofold and measurable (see numeric_test.mbt):
    1. construction / sub-views allocate no validity Bytes: from_int64s / from_doubles are just the data array, and slice / take repack only the data — BuiltinColumn additionally allocates (from_ints) or repacks (slice / take) a Bitmap;
    2. reductions read the raw array with no validity().to_bools() materialisation and no per-slot if valid[i] branch that Series' reductions run: sum / mean are a tight fold over the array, and min / max share one fold_extremum pass whose only per-slot test is the Float NaN-skip (a no-op on the Int arm).

    The accessor surface is named identically to BuiltinColumn's numeric accessors so ColumnStorage::Numeric can forward to it verbatim (S2) and the Series.storage flip (S3) stays mechanical. The reductions (sum / mean / min / max) match Series' own semantics (BuiltinColumn carries none of its own), and Series::sum / mean / min / max dispatch straight here on a Numeric-backed column — so the bitmap-free fold is the path actually taken for an all-valid numeric Series, not just a parallel implementation. Cross-dtype transforms (cast / to_int / to_float) are intentionally absent: a caller that needs them goes through to_builtin() and lets BuiltinColumn do the work, keeping this type's surface to the fast-path operations that actually benefit from the missing bitmap.

    NumericColumn::bool_values

    Always raise TypeMismatch — a NumericColumn is numeric by construction, so it never holds Bool cells. Present so ColumnStorage::bool_values can forward to both arms uniformly.

    NumericColumn::data

    The raw backing storage as a ColumnData, so callers (and the ColumnStorage::Numeric arm) read values through the same total data() surface BuiltinColumn exposes. The element array is shared (read-only).

    NumericColumn::dtype

    The column's logical DataType — Int or Float (a NumericColumn is numeric by construction).

    NumericColumn::float_values

    Like int_values but for Float columns. raise TypeMismatch when this is an Int column.

    NumericColumn::from_doubles

    fn NumericColumn::from_doubles(values : Array[Double]) -> NumericColumn

    Build a Float column from raw values. As with from_int64s there is no null path and no validity Bitmap. NaN is a perfectly valid stored value here — it is not a missing marker (only an absent slot is, and this column has none) — and it participates in reductions exactly as Polars treats it: propagating through sum / mean, skipped by min / max. values is copied, so the column owns its data.

    NumericColumn::from_floats

    fn NumericColumn::from_floats(values : Array[Double]) -> NumericColumn

    Alias of from_doubles under the spelling the rest of the library uses for a raw Array[Double] (BuiltinColumn::from_floats / Series::from_floats), so the storage seam reads uniformly at every layer.

    NumericColumn::from_int64s

    fn NumericColumn::from_int64s(values : Array[Int64]) -> NumericColumn

    Build an Int column from raw values. There is no null path — if any cell may be missing, build a BuiltinColumn (from_int_options) and keep the column Builtin instead. No validity Bitmap is allocated. values is copied, so the column owns its data.

    NumericColumn::from_ints

    fn NumericColumn::from_ints(values : Array[Int64]) -> NumericColumn

    Alias of from_int64s under the spelling the rest of the library uses for a raw Array[Int64] (BuiltinColumn::from_ints / Series::from_ints), so the storage seam reads uniformly at every layer.

    NumericColumn::get

    Read a single cell as a Scalar. Out-of-bounds index raise IndexOutOfBounds. No null branch: a slot in [0, len) is always a present value, so the read skips the validity check BuiltinColumn::get must perform.

    NumericColumn::int_values

    Return the raw Int64 array paired with an all-valid Bitmap sized to the column, matching BuiltinColumn::int_values' (data, validity) shape so the two are interchangeable through ColumnStorage. The bitmap is synthesised on demand — the column stores none. raise TypeMismatch when this is a Float column.

    NumericColumn::is_empty

    fn NumericColumn::is_empty(self : NumericColumn) -> Bool

    true when the column has no cells.

    NumericColumn::is_null

    fn NumericColumn::is_null(self : NumericColumn, index : Int) -> Bool raise
    DataError

    Whether cell index is null — structurally always false for an all-valid column. Out-of-bounds index raise IndexOutOfBounds; the bounds check is the method's only real work. It mirrors BuiltinColumn::is_null's diagnostic so the two are interchangeable through ColumnStorage.

    NumericColumn::len

    fn NumericColumn::len(self : NumericColumn) -> Int

    Number of cells.

    NumericColumn::max

    Maximum cell as a Scalar. Mirrors min with > for <; the Float NaN-skip and empty rules are identical. Total.

    NumericColumn::mean

    Arithmetic mean of every cell, as a Double (matching Series::mean).

    The denominator is the cell count len — every slot is present, so there is no non-null count to compute. A Float NaN propagates through the sum to a NaN mean (Polars semantics).

    raise InvalidOperation on an empty column: the mean of zero values is undefined (0 / 0), a genuine failure mode (unlike sum's identity), so the raise is real rather than an impossible one — it does not leave a dead arm.

    NumericColumn::min

    Minimum cell as a Scalar, by the dtype's natural order. Total, matching Series::min:
    • Empty column → Scalar::Null.
    • Float NaN is skipped (treated as missing for the extremum, as in sort and Polars' regular min — distinct from sum / mean, where it propagates). An all-NaN Float column → Scalar::Null.

    NumericColumn::null_count

    fn NumericColumn::null_count(_self : NumericColumn) -> Int

    Always 0: an all-valid column has no nulls by construction. Total — no bitmap to popcount, the answer is structural.

    NumericColumn::slice

    Half-open [start, end) slice. Requires 0 <= start <= end <= len, with the same diagnostics (and check order) as BuiltinColumn::slice:
    • IndexOutOfBounds(start) when start < 0.
    • IndexOutOfBounds(end) when end > len.
    • InvalidOperation("slice start > end: ...") when start > end.

    Stays a NumericColumn — a sub-range of an all-valid column is itself all-valid, so there is no bitmap to slice (the win over BuiltinColumn::slice, which repacks one).

    NumericColumn::string_values

    Always raise TypeMismatch — a NumericColumn never holds String cells. Present so ColumnStorage::string_values forwards uniformly.

    NumericColumn::sum

    Sum of every cell.

    • Int → Scalar::Int, accumulated in 64-bit Int64 (sums past the 32-bit ceiling do not overflow).
    • Float → Scalar::Float, accumulated in Double; a NaN cell propagates (Polars semantics — NaN is a value, not missing).
    • Empty → the additive identity (Scalar::Int(0) / Scalar::Float(0.0)).

    Total. There is no missing value to skip and no non-numeric dtype to reject, so — unlike Series::sum, which raises TypeMismatch for Bool / String — this never fails. Keeping it total rather than propagating an impossible raise avoids a dead Err arm that would break 100% coverage (feedback_lib_no_abort).

    NumericColumn::take

    Gather: produce a new column whose i-th entry is self[indices[i]]. Any out-of-bounds index raise IndexOutOfBounds(idx), matching BuiltinColumn::take. Stays a NumericColumn (no bitmap to gather).

    NumericColumn::to_builtin

    fn NumericColumn::to_builtin(self : NumericColumn) -> BuiltinColumn

    Widen to a BuiltinColumn with an all-valid validity bitmap. Total and lossless: the data array is reused (the source column owns it and is immutable, so the two may safely share it) and Bitmap::all_valid(len) records that every slot is present. The widening is value-preserving — it equals BuiltinColumn::from_ints / from_floats on the same data (proven in numeric_test.mbt). It reuses the array via a struct literal rather than from_ints / from_floats, which now defensively copy.

    NumericColumn::to_string_column

    fn NumericColumn::to_string_column(self : NumericColumn) -> BuiltinColumn

    Render every cell to its String value-form, yielding a String BuiltinColumn (a numeric column cannot stay Numeric once stringified). Total: an all-valid numeric column has no null placeholder and no non-renderable cell, so this routes through to_builtin and reuses BuiltinColumn::to_string_column rather than duplicating the rendering.

    NumericData

    pub(all) enum NumericData {
    Int(Array[Int64])
    Float(Array[Double])
    } derive(Eq,
    Debug
    )

    Backing storage for NumericColumn, discriminated by dtype. The element type is the raw value; there is no nullability to track (every slot is valid). Numeric only — Bool / String columns are always backed by a BuiltinColumn, so NumericData has just the two numeric arms.

    StorageKind

    pub(all) enum StorageKind {
    Builtin
    Numeric
    } derive(Eq,
    Debug
    )

    Which backend a ColumnStorage (or Series) currently uses. ArrowLike from the original moonframe.txt draft is intentionally absent — post-P3.5 Builtin is the Arrow layout (data + validity bitmap, 1 = valid), so a separate variant would be an empty shell.