| 95 | } |
| 96 | |
| 97 | pub fn fold(&mut self, coord: &[CoordValue], attrs: &[CellValue]) { |
| 98 | for (i, c) in coord.iter().take(self.arity).enumerate() { |
| 99 | let lo_replaces = self.dim_mins[i].as_ref().is_none_or(|cur| coord_lt(c, cur)); |
| 100 | if lo_replaces { |
| 101 | self.dim_mins[i] = Some(c.clone()); |
| 102 | } |
| 103 | let hi_replaces = self.dim_maxs[i].as_ref().is_none_or(|cur| coord_lt(cur, c)); |
| 104 | if hi_replaces { |
| 105 | self.dim_maxs[i] = Some(c.clone()); |
| 106 | } |
| 107 | } |
| 108 | for (i, a) in attrs.iter().take(self.n_attrs).enumerate() { |
| 109 | self.attr_total[i] += 1; |
| 110 | match a { |
| 111 | CellValue::Null => self.attr_nulls[i] += 1, |
| 112 | CellValue::Int64(v) => { |
| 113 | fold_numeric(&mut self.attr_min[i], &mut self.attr_max[i], *v as f64) |
| 114 | } |
| 115 | CellValue::Float64(v) => { |
| 116 | fold_numeric(&mut self.attr_min[i], &mut self.attr_max[i], *v) |
| 117 | } |
| 118 | CellValue::String(s) => { |
| 119 | self.attr_is_categorical[i] = true; |
| 120 | self.attr_distinct[i].insert(s.as_bytes().to_vec()); |
| 121 | } |
| 122 | CellValue::Bytes(b) => { |
| 123 | self.attr_is_categorical[i] = true; |
| 124 | self.attr_distinct[i].insert(b.clone()); |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | self.nnz += 1; |
| 129 | } |
| 130 | |
| 131 | pub fn build(self) -> TileMBR { |
| 132 | let dim_mins = self.dim_mins.iter().map(coord_to_bound).collect(); |