Skip to content

Commit

Permalink
Switch to using gather instead of using a specialized method for scan…
Browse files Browse the repository at this point in the history
…ning the full column
  • Loading branch information
Mytherin committed Nov 15, 2024
1 parent 0290e22 commit 9b3b739
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 60 deletions.
56 changes: 0 additions & 56 deletions src/common/row_operations/row_gather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,60 +178,4 @@ void RowOperations::Gather(Vector &rows, const SelectionVector &row_sel, Vector
}
}

template <class T>
static void TemplatedFullScanLoop(Vector &rows, Vector &col, idx_t count, idx_t col_offset, idx_t col_no) {
// Precompute mask indexes
idx_t entry_idx;
idx_t idx_in_entry;
ValidityBytes::GetEntryIndex(col_no, entry_idx, idx_in_entry);

auto ptrs = FlatVector::GetData<data_ptr_t>(rows);
auto data = FlatVector::GetData<T>(col);
// auto &col_mask = FlatVector::Validity(col);

for (idx_t i = 0; i < count; i++) {
auto row = ptrs[i];
data[i] = Load<T>(row + col_offset);
ValidityBytes row_mask(row);
if (!row_mask.RowIsValid(row_mask.GetValidityEntry(entry_idx), idx_in_entry)) {
throw InternalException("Null value comparisons not implemented for perfect hash table yet");
// col_mask.SetInvalid(i);
}
}
}

void RowOperations::FullScanColumn(const TupleDataLayout &layout, Vector &rows, Vector &col, idx_t count,
idx_t col_no) {
const auto col_offset = layout.GetOffsets()[col_no];
col.SetVectorType(VectorType::FLAT_VECTOR);
switch (col.GetType().InternalType()) {
case PhysicalType::UINT8:
TemplatedFullScanLoop<uint8_t>(rows, col, count, col_offset, col_no);
break;
case PhysicalType::UINT16:
TemplatedFullScanLoop<uint16_t>(rows, col, count, col_offset, col_no);
break;
case PhysicalType::UINT32:
TemplatedFullScanLoop<uint32_t>(rows, col, count, col_offset, col_no);
break;
case PhysicalType::UINT64:
TemplatedFullScanLoop<uint64_t>(rows, col, count, col_offset, col_no);
break;
case PhysicalType::INT8:
TemplatedFullScanLoop<int8_t>(rows, col, count, col_offset, col_no);
break;
case PhysicalType::INT16:
TemplatedFullScanLoop<int16_t>(rows, col, count, col_offset, col_no);
break;
case PhysicalType::INT32:
TemplatedFullScanLoop<int32_t>(rows, col, count, col_offset, col_no);
break;
case PhysicalType::INT64:
TemplatedFullScanLoop<int64_t>(rows, col, count, col_offset, col_no);
break;
default:
throw NotImplementedException("Unimplemented type for RowOperations::FullScanColumn");
}
}

} // namespace duckdb
3 changes: 2 additions & 1 deletion src/execution/operator/join/perfect_hash_join_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ bool PerfectHashJoinExecutor::FullScanHashTable(LogicalType &key_type) {

// Scan the build keys in the hash table
Vector build_vector(key_type, key_count);
RowOperations::FullScanColumn(ht.layout, tuples_addresses, build_vector, key_count, 0);
data_collection.Gather(tuples_addresses, *FlatVector::IncrementalSelectionVector(), key_count, 0, build_vector,
*FlatVector::IncrementalSelectionVector(), nullptr);

// Now fill the selection vector using the build keys and create a sequential vector
// TODO: add check for fast pass when probe is part of build domain
Expand Down
3 changes: 2 additions & 1 deletion src/execution/operator/join/physical_hash_join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,8 @@ void JoinFilterPushdownInfo::PushFilters(ClientContext &context, JoinHashTable &

// Scan the build keys in the hash table
Vector build_vector(ht.layout.GetTypes()[build_idx], key_count);
RowOperations::FullScanColumn(ht.layout, tuples_addresses, build_vector, key_count, build_idx);
data_collection.Gather(tuples_addresses, *FlatVector::IncrementalSelectionVector(), key_count,
build_idx, build_vector, *FlatVector::IncrementalSelectionVector(), nullptr);

// generate the OR-clause
vector<Value> in_list;
Expand Down
2 changes: 0 additions & 2 deletions src/include/duckdb/common/row_operations/row_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ struct RowOperations {
static void Gather(Vector &rows, const SelectionVector &row_sel, Vector &col, const SelectionVector &col_sel,
const idx_t count, const RowLayout &layout, const idx_t col_no, const idx_t build_size = 0,
data_ptr_t heap_ptr = nullptr);
//! Full Scan an entire columns
static void FullScanColumn(const TupleDataLayout &layout, Vector &rows, Vector &col, idx_t count, idx_t col_idx);

//===--------------------------------------------------------------------===//
// Comparison Operators
Expand Down

0 comments on commit 9b3b739

Please sign in to comment.