From dca9938c6da6efd174eb2dc93dd132bee82bbfe9 Mon Sep 17 00:00:00 2001 From: Mark Raasveldt Date: Thu, 17 Oct 2024 16:36:59 +0200 Subject: [PATCH] Add extra order condition to test --- .../vector_operations/is_distinct_from.cpp | 38 ------------------- .../operator/order/physical_top_n.cpp | 8 ++-- .../common/operator/comparison_operators.hpp | 14 ------- .../vector_operations/vector_operations.hpp | 11 ------ test/sql/pivot/pivot_example.test | 2 +- 5 files changed, 5 insertions(+), 68 deletions(-) diff --git a/src/common/vector_operations/is_distinct_from.cpp b/src/common/vector_operations/is_distinct_from.cpp index 09fb1bec06e..d66f6a8fc43 100644 --- a/src/common/vector_operations/is_distinct_from.cpp +++ b/src/common/vector_operations/is_distinct_from.cpp @@ -502,16 +502,6 @@ idx_t PositionComparator::Final(Vector &left, Vector & return VectorOperations::DistinctGreaterThan(right, left, &sel, count, true_sel, false_sel, null_mask); } -template <> -idx_t PositionComparator::Final(Vector &left, Vector &right, - const SelectionVector &sel, idx_t count, - optional_ptr true_sel, - optional_ptr false_sel, - optional_ptr null_mask) { - // DistinctGreaterThan has NULLs last - return VectorOperations::DistinctGreaterThan(right, left, &sel, count, true_sel, false_sel, null_mask); -} - template <> idx_t PositionComparator::Final(Vector &left, Vector &right, const SelectionVector &sel, idx_t count, optional_ptr true_sel, @@ -520,16 +510,6 @@ idx_t PositionComparator::Final(Vector &left, Vecto return VectorOperations::DistinctGreaterThan(left, right, &sel, count, true_sel, false_sel, null_mask); } -template <> -idx_t PositionComparator::Final(Vector &left, Vector &right, - const SelectionVector &sel, idx_t count, - optional_ptr true_sel, - optional_ptr false_sel, - optional_ptr null_mask) { - // DistinctLessThan has NULLs last - return VectorOperations::DistinctLessThan(right, left, &sel, count, true_sel, false_sel, null_mask); -} - using StructEntries = vector>; static void ExtractNestedSelection(const SelectionVector &slice_sel, const idx_t count, const SelectionVector &sel, @@ -1198,15 +1178,6 @@ idx_t VectorOperations::DistinctGreaterThan(Vector &left, Vector &right, optiona null_mask); } -// true := A > B with nulls being minimal -idx_t VectorOperations::DistinctGreaterThanNullsFirst(Vector &left, Vector &right, - optional_ptr sel, idx_t count, - optional_ptr true_sel, - optional_ptr false_sel, - optional_ptr null_mask) { - return TemplatedDistinctSelectOperation(left, right, sel, count, true_sel, - false_sel, null_mask); -} // true := A >= B with nulls being maximal idx_t VectorOperations::DistinctGreaterThanEquals(Vector &left, Vector &right, optional_ptr sel, idx_t count, optional_ptr true_sel, @@ -1224,15 +1195,6 @@ idx_t VectorOperations::DistinctLessThan(Vector &left, Vector &right, optional_p null_mask); } -// true := A < B with nulls being minimal -idx_t VectorOperations::DistinctLessThanNullsFirst(Vector &left, Vector &right, optional_ptr sel, - idx_t count, optional_ptr true_sel, - optional_ptr false_sel, - optional_ptr null_mask) { - return TemplatedDistinctSelectOperation(right, left, sel, count, true_sel, - false_sel, nullptr); -} - // true := A <= B with nulls being maximal idx_t VectorOperations::DistinctLessThanEquals(Vector &left, Vector &right, optional_ptr sel, idx_t count, optional_ptr true_sel, diff --git a/src/execution/operator/order/physical_top_n.cpp b/src/execution/operator/order/physical_top_n.cpp index 1828e3b056b..1b3ae11aed7 100644 --- a/src/execution/operator/order/physical_top_n.cpp +++ b/src/execution/operator/order/physical_top_n.cpp @@ -95,8 +95,8 @@ class TopNHeap { return MaxValue(STANDARD_VECTOR_SIZE * 5ULL, 2ULL * heap_size); } - idx_t MaxHeapSize() const { - return ReduceThreshold() + STANDARD_VECTOR_SIZE; + idx_t HeapAllocSize() const { + return MinValue(STANDARD_VECTOR_SIZE * 100ULL, ReduceThreshold()) + STANDARD_VECTOR_SIZE; } }; @@ -117,7 +117,7 @@ TopNHeap::TopNHeap(ClientContext &context, Allocator &allocator, const vector sort_keys_type {LogicalType::BLOB}; sort_keys.Initialize(allocator, sort_keys_type); - heap_data.Initialize(allocator, payload_types, MaxHeapSize()); + heap_data.Initialize(allocator, payload_types, HeapAllocSize()); payload_chunk.Initialize(allocator, payload_types); sort_chunk.Initialize(allocator, sort_types); } @@ -243,7 +243,7 @@ void TopNHeap::Reduce() { // we have too many values in the heap - reduce them StringHeap new_sort_heap; DataChunk new_payload_chunk; - new_payload_chunk.Initialize(allocator, payload_types, MaxHeapSize()); + new_payload_chunk.Initialize(allocator, payload_types, HeapAllocSize()); SelectionVector new_payload_sel(heap.size()); for (idx_t i = 0; i < heap.size(); i++) { diff --git a/src/include/duckdb/common/operator/comparison_operators.hpp b/src/include/duckdb/common/operator/comparison_operators.hpp index f1a6f6eb33c..1a05f243650 100644 --- a/src/include/duckdb/common/operator/comparison_operators.hpp +++ b/src/include/duckdb/common/operator/comparison_operators.hpp @@ -107,13 +107,6 @@ struct DistinctGreaterThan { } }; -struct DistinctGreaterThanNullsFirst { - template - static inline bool Operation(const T &left, const T &right, bool left_null, bool right_null) { - return DistinctGreaterThan::Operation(left, right, right_null, left_null); - } -}; - struct DistinctGreaterThanEquals { template static inline bool Operation(const T &left, const T &right, bool left_null, bool right_null) { @@ -128,13 +121,6 @@ struct DistinctLessThan { } }; -struct DistinctLessThanNullsFirst { - template - static inline bool Operation(const T &left, const T &right, bool left_null, bool right_null) { - return DistinctGreaterThan::Operation(right, left, left_null, right_null); - } -}; - struct DistinctLessThanEquals { template static inline bool Operation(const T &left, const T &right, bool left_null, bool right_null) { diff --git a/src/include/duckdb/common/vector_operations/vector_operations.hpp b/src/include/duckdb/common/vector_operations/vector_operations.hpp index bd772fcad3b..57861f0731e 100644 --- a/src/include/duckdb/common/vector_operations/vector_operations.hpp +++ b/src/include/duckdb/common/vector_operations/vector_operations.hpp @@ -130,17 +130,6 @@ struct VectorOperations { optional_ptr false_sel, optional_ptr null_mask = nullptr); - // true := A > B with nulls being minimal - static idx_t DistinctGreaterThanNullsFirst(Vector &left, Vector &right, optional_ptr sel, - idx_t count, optional_ptr true_sel, - optional_ptr false_sel, - optional_ptr null_mask = nullptr); - // true := A < B with nulls being minimal - static idx_t DistinctLessThanNullsFirst(Vector &left, Vector &right, optional_ptr sel, - idx_t count, optional_ptr true_sel, - optional_ptr false_sel, - optional_ptr null_mask = nullptr); - //===--------------------------------------------------------------------===// // Nested Comparisons //===--------------------------------------------------------------------===// diff --git a/test/sql/pivot/pivot_example.test b/test/sql/pivot/pivot_example.test index 5f128bb0195..64a009e0e5d 100644 --- a/test/sql/pivot/pivot_example.test +++ b/test/sql/pivot/pivot_example.test @@ -201,6 +201,6 @@ UNPIVOT PivotedCities ON 2000, 2010, 2020 ORDER BY ALL LIMIT 1 NL Amsterdam 2000 1005 query IIII -UNPIVOT PivotedCities ON 2000, 2010, 2020 ORDER BY 1 LIMIT 1 OFFSET 1 +UNPIVOT PivotedCities ON 2000, 2010, 2020 ORDER BY 1, 3 LIMIT 1 OFFSET 1 ---- NL Amsterdam 2010 1065