| 151 | } |
| 152 | |
| 153 | void PerColumnStats::Update(const string& ndv, int64_t num_new_rows, double new_avg_width, |
| 154 | int32_t max_new_width, int64_t num_new_nulls, int64_t num_new_trues, |
| 155 | int64_t num_new_falses, const impala::TColumnValue& low_value_new, |
| 156 | const impala::TColumnValue& high_value_new) { |
| 157 | DCHECK_EQ(intermediate_ndv.size(), ndv.size()) << "Incompatible intermediate NDVs"; |
| 158 | DCHECK_GE(num_new_rows, 0); |
| 159 | DCHECK_GE(max_new_width, 0); |
| 160 | DCHECK_GE(new_avg_width, 0); |
| 161 | DCHECK_GE(num_new_nulls, -1); // '-1' needed to be backward compatible |
| 162 | DCHECK_GE(num_trues, 0); |
| 163 | DCHECK_GE(num_falses, 0); |
| 164 | for (int j = 0; j < ndv.size(); ++j) { |
| 165 | intermediate_ndv[j] = ::max(intermediate_ndv[j], ndv[j]); |
| 166 | } |
| 167 | // Earlier the 'num_nulls' were initialized and persisted with '-1', this condition |
| 168 | // ensures metadata backward compatibility between releases |
| 169 | if (num_nulls >= 0) { |
| 170 | if (num_new_nulls >= 0) { |
| 171 | num_nulls += num_new_nulls; |
| 172 | } else { |
| 173 | num_nulls = -1; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | num_trues += num_new_trues; |
| 178 | num_falses += num_new_falses; |
| 179 | max_width = ::max(max_width, max_new_width); |
| 180 | total_width += (new_avg_width * num_new_rows); |
| 181 | num_rows += num_new_rows; |
| 182 | |
| 183 | UpdateLowValue(low_value_new); |
| 184 | UpdateHighValue(high_value_new); |
| 185 | } |
| 186 | |
| 187 | void PerColumnStats::Finalize() { |
| 188 | ndv_estimate = AggregateFunctions::HllFinalEstimate( |