Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/operators/physical_probe_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ OperatorResultType PhysicalProbeFilter::ExecuteInternal(ExecutionContext &contex
(unsigned long long)build_col.table_index, (unsigned long long)build_col.column_index,
build_table.c_str());
state.bloom_filters.push_back(bf);
state.sel_vector.emplace_back(STANDARD_VECTOR_SIZE);
break; // found the filter for this column
}
}
Expand Down Expand Up @@ -131,7 +132,6 @@ OperatorResultType PhysicalProbeFilter::ExecuteInternal(ExecutionContext &contex

// apply bloom filters
idx_t result_count = row_num;
auto &sel = state.sel;

unique_ptr<ScopedTimer> probe_timer;
if (profiling_stats) {
Expand Down Expand Up @@ -171,7 +171,8 @@ OperatorResultType PhysicalProbeFilter::ExecuteInternal(ExecutionContext &contex
// }

// lookup directly into selection vector
result_count = bf->LookupSel(input, sel, {bound_column_indices[i]}, state.bit_vector.data());

result_count = bf->LookupSel(input, state.sel_vector[i], {bound_column_indices[i]}, state.bit_vector.data());

// early exit if no rows passed
if (result_count == 0) {
Expand All @@ -185,20 +186,15 @@ OperatorResultType PhysicalProbeFilter::ExecuteInternal(ExecutionContext &contex

// apply filter if we filtered rows
if (result_count < row_num) {
input.Slice(sel, result_count);
input.Slice(state.sel_vector[i], result_count);
row_num = result_count;
}
}

// stop probe timer before output work
probe_timer.reset();

// optimization: if all rows passed, just reference input (zero-copy)
if (result_count == row_num) {
chunk.Reference(input);
} else {
chunk.Slice(input, sel, result_count);
}
chunk.Reference(input);

if (profiling_stats) {
profiling_stats->rows_in.fetch_add(original_row_num, std::memory_order_relaxed);
Expand Down
5 changes: 2 additions & 3 deletions src/operators/physical_probe_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ class PhysicalCreateFilter;

class PhysicalProbeFilterState : public CachingOperatorState {
public:
PhysicalProbeFilterState()
: bloom_filters_initialized(false), sel(STANDARD_VECTOR_SIZE), bit_vector((STANDARD_VECTOR_SIZE + 7) / 8) {
PhysicalProbeFilterState() : bloom_filters_initialized(false), bit_vector((STANDARD_VECTOR_SIZE + 7) / 8) {
}

vector<shared_ptr<PTBloomFilter>> bloom_filters;
bool bloom_filters_initialized;

// reusable buffers to avoid per-chunk heap allocations
SelectionVector sel;
vector<SelectionVector> sel_vector;
vector<uint8_t> bit_vector;
};

Expand Down
Loading