Skip to content

Commit c3a6ed0

Browse files
authored
Merge pull request #157 from poyrazK/perf/group-by-optimization
perf: DirectIndexAgg for low-cardinality integer GROUP BY
2 parents fa275e2 + f19c174 commit c3a6ed0

9 files changed

Lines changed: 946 additions & 49 deletions

File tree

benchmarks/duckdb_comparison_bench.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct CloudSQLContext {
5454
txn_manager = std::make_unique<transaction::TransactionManager>(*lock_manager, *catalog, *bpm);
5555
executor = std::make_unique<QueryExecutor>(*catalog, *bpm, *lock_manager, *txn_manager);
5656
executor->set_local_only(true);
57+
executor->set_storage_manager(storage.get()); // Enable use_vectorized for large scans
5758

5859
// Create lineitem table (TPC-H schema, simplified)
5960
CreateTableStatement create_stmt;

include/executor/types.hpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ class ColumnVector {
243243
size_ = 0;
244244
null_bitmap_.clear();
245245
}
246+
247+
/**
248+
* @brief Steals data from another column vector by swapping internal buffers.
249+
* After steal(), 'other' is emptied and 'this' holds the original data from 'other'.
250+
* Throws std::runtime_error if types are incompatible.
251+
*/
252+
virtual void steal(ColumnVector&& other) = 0;
246253
};
247254

248255
/**
@@ -328,6 +335,14 @@ class NumericVector : public ColumnVector {
328335
ColumnVector::clear();
329336
data_.clear();
330337
}
338+
339+
void steal(ColumnVector&& other) override {
340+
auto* other_num = dynamic_cast<NumericVector<T>*>(&other);
341+
if (!other_num) throw std::runtime_error("NumericVector::steal: type mismatch");
342+
data_.swap(other_num->data_);
343+
null_bitmap_.swap(other_num->null_bitmap_);
344+
std::swap(size_, other_num->size_);
345+
}
331346
};
332347

333348
/**
@@ -392,6 +407,14 @@ class StringVector : public ColumnVector {
392407
ColumnVector::clear();
393408
data_.clear();
394409
}
410+
411+
void steal(ColumnVector&& other) override {
412+
auto* other_str = dynamic_cast<StringVector*>(&other);
413+
if (!other_str) throw std::runtime_error("StringVector::steal: type mismatch");
414+
data_.swap(other_str->data_);
415+
null_bitmap_.swap(other_str->null_bitmap_);
416+
std::swap(size_, other_str->size_);
417+
}
395418
};
396419

397420
/**

0 commit comments

Comments
 (0)