formualizer_eval/
stripes.rs

1// no imports required
2
3/// Typed numeric stripe passed to reductions and maps
4pub struct NumericChunk<'a> {
5    pub data: &'a [f64],
6    pub validity: Option<ValidityMask<'a>>, // None => all valid
7}
8
9/// Validity bitmask for elementwise operations
10pub enum ValidityMask<'a> {
11    Bits(&'a [u64]),
12    Bools(&'a [bool]),
13}
14
15/// Heterogeneous cell chunk for elementwise mapping.
16pub enum CellChunk<'a> {
17    /// Mixed values provided as `LiteralValue` slice
18    Mixed(&'a [formualizer_common::LiteralValue]),
19    /// Numeric-only chunk (optional fast path for elementwise numeric)
20    Numbers(&'a [f64]),
21}
22
23impl<'a> NumericChunk<'a> {
24    pub fn len(&self) -> usize {
25        self.data.len()
26    }
27    pub fn is_empty(&self) -> bool {
28        self.data.is_empty()
29    }
30}
31
32#[cfg(test)]
33mod tests {
34    use super::*;
35
36    #[test]
37    fn basic_numeric_chunk_properties() {
38        let buf = [1.0, 2.0, 3.0];
39        let ch = NumericChunk {
40            data: &buf,
41            validity: None,
42        };
43        assert_eq!(ch.len(), 3);
44        assert!(!ch.is_empty());
45    }
46}