| 129 | } |
| 130 | |
| 131 | pub fn build(self) -> TileMBR { |
| 132 | let dim_mins = self.dim_mins.iter().map(coord_to_bound).collect(); |
| 133 | let dim_maxs = self.dim_maxs.iter().map(coord_to_bound).collect(); |
| 134 | let mut attr_stats = Vec::with_capacity(self.n_attrs); |
| 135 | for i in 0..self.n_attrs { |
| 136 | let s = if self.attr_total[i] == self.attr_nulls[i] { |
| 137 | AttrStats::AllNull { |
| 138 | null_count: self.attr_nulls[i], |
| 139 | } |
| 140 | } else if self.attr_is_categorical[i] { |
| 141 | AttrStats::Categorical { |
| 142 | distinct: self.attr_distinct[i].len() as u32, |
| 143 | null_count: self.attr_nulls[i], |
| 144 | } |
| 145 | } else { |
| 146 | // Numeric branch is reached only when at least one |
| 147 | // non-null numeric cell was folded (the if/else above |
| 148 | // excludes all-null and categorical), so attr_min / |
| 149 | // attr_max are populated. |
| 150 | AttrStats::Numeric { |
| 151 | min: self.attr_min[i].expect("numeric branch implies min is set"), |
| 152 | max: self.attr_max[i].expect("numeric branch implies max is set"), |
| 153 | null_count: self.attr_nulls[i], |
| 154 | } |
| 155 | }; |
| 156 | attr_stats.push(s); |
| 157 | } |
| 158 | TileMBR { |
| 159 | dim_mins, |
| 160 | dim_maxs, |
| 161 | nnz: self.nnz, |
| 162 | attr_stats, |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | fn coord_lt(a: &CoordValue, b: &CoordValue) -> bool { |