| 153 | } |
| 154 | |
| 155 | void JoinBuilder::PublishRuntimeFilters(const std::vector<FilterContext>& filter_ctxs, |
| 156 | RuntimeState* runtime_state, float minmax_filter_threshold, int64_t num_build_rows) { |
| 157 | VLOG(3) << name() << " publishing " |
| 158 | << filter_ctxs.size() << " filters."; |
| 159 | int32_t num_enabled_filters = 0; |
| 160 | for (const FilterContext& ctx : filter_ctxs) { |
| 161 | BloomFilter* bloom_filter = nullptr; |
| 162 | if (ctx.local_bloom_filter != nullptr) { |
| 163 | bloom_filter = ctx.local_bloom_filter; |
| 164 | ++num_enabled_filters; |
| 165 | } else if (ctx.local_min_max_filter != nullptr) { |
| 166 | /// Apply the column min/max stats (if applicable) to shut down the min/max |
| 167 | /// filter early by setting always true flag for the filter. Do this only if |
| 168 | /// the min/max filter is too close in area to the column stats of all target |
| 169 | /// scan columns. |
| 170 | const TRuntimeFilterDesc& filter_desc = ctx.filter->filter_desc(); |
| 171 | VLOG(3) << "Check out the usefulness of the local minmax filter:" |
| 172 | << " id=" << ctx.filter->id() |
| 173 | << ", filter details=" << ctx.local_min_max_filter->DebugString() |
| 174 | << ", column stats:" |
| 175 | << " low=" << PrintTColumnValue(filter_desc.targets[0].low_value) |
| 176 | << ", high=" << PrintTColumnValue(filter_desc.targets[0].high_value) |
| 177 | << ", threshold=" << minmax_filter_threshold |
| 178 | << ", #targets=" << filter_desc.targets.size(); |
| 179 | bool all_overlap = true; |
| 180 | for (const auto& target_desc : filter_desc.targets) { |
| 181 | if (!FilterContext::ShouldRejectFilterBasedOnColumnStats( |
| 182 | target_desc, ctx.local_min_max_filter, minmax_filter_threshold)) { |
| 183 | all_overlap = false; |
| 184 | break; |
| 185 | } |
| 186 | } |
| 187 | if (all_overlap) { |
| 188 | ctx.local_min_max_filter->SetAlwaysTrue(); |
| 189 | VLOG(3) << "The local minmax filter is set to always true:" |
| 190 | << " id=" << ctx.filter->id(); |
| 191 | } |
| 192 | |
| 193 | if (!ctx.local_min_max_filter->AlwaysTrue()) { |
| 194 | ++num_enabled_filters; |
| 195 | } |
| 196 | } else if (ctx.local_in_list_filter != nullptr) { |
| 197 | if (!ctx.local_in_list_filter->AlwaysTrue()) { |
| 198 | ++num_enabled_filters; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | runtime_state->filter_bank()->UpdateFilterFromLocal(ctx.filter->id(), |
| 203 | bloom_filter, ctx.local_min_max_filter, ctx.local_in_list_filter); |
| 204 | |
| 205 | if (ctx.local_min_max_filter != nullptr) { |
| 206 | VLOG(3) << name() << " published min/max filter: " |
| 207 | << " id=" << ctx.filter->id() |
| 208 | << ", details=" << ctx.local_min_max_filter->DebugString(); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | if (filter_ctxs.size() > 0) { |
nothing calls this directly
no test coverage detected