duckdb 0.3.2-dev524.0 → 0.3.2-dev528.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb.cpp +76 -94
- package/src/duckdb.hpp +2 -2
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -27298,11 +27298,9 @@ struct RowOperations {
|
|
|
27298
27298
|
//! Swizzles the base pointer of each row to offset within heap block
|
|
27299
27299
|
static void SwizzleHeapPointer(const RowLayout &layout, data_ptr_t row_ptr, const data_ptr_t heap_base_ptr,
|
|
27300
27300
|
const idx_t count);
|
|
27301
|
-
//!
|
|
27302
|
-
static void
|
|
27303
|
-
|
|
27304
|
-
//! Unswizzles offsets back to pointers to blobs
|
|
27305
|
-
static void UnswizzleColumns(const RowLayout &layout, const data_ptr_t base_row_ptr, const idx_t count);
|
|
27301
|
+
//! Unswizzles all offsets back to pointers
|
|
27302
|
+
static void UnswizzlePointers(const RowLayout &layout, const data_ptr_t base_row_ptr,
|
|
27303
|
+
const data_ptr_t base_heap_ptr, const idx_t count);
|
|
27306
27304
|
};
|
|
27307
27305
|
|
|
27308
27306
|
} // namespace duckdb
|
|
@@ -27538,46 +27536,44 @@ namespace duckdb {
|
|
|
27538
27536
|
|
|
27539
27537
|
void RowOperations::SwizzleColumns(const RowLayout &layout, const data_ptr_t base_row_ptr, const idx_t count) {
|
|
27540
27538
|
const idx_t row_width = layout.GetRowWidth();
|
|
27541
|
-
|
|
27542
|
-
|
|
27543
|
-
|
|
27544
|
-
|
|
27545
|
-
|
|
27546
|
-
|
|
27539
|
+
data_ptr_t heap_row_ptrs[STANDARD_VECTOR_SIZE];
|
|
27540
|
+
idx_t done = 0;
|
|
27541
|
+
while (done != count) {
|
|
27542
|
+
const idx_t next = MinValue<idx_t>(count - done, STANDARD_VECTOR_SIZE);
|
|
27543
|
+
const data_ptr_t row_ptr = base_row_ptr + done * row_width;
|
|
27544
|
+
// Load heap row pointers
|
|
27545
|
+
data_ptr_t heap_ptr_ptr = row_ptr + layout.GetHeapPointerOffset();
|
|
27546
|
+
for (idx_t i = 0; i < next; i++) {
|
|
27547
|
+
heap_row_ptrs[i] = Load<data_ptr_t>(heap_ptr_ptr);
|
|
27548
|
+
heap_ptr_ptr += row_width;
|
|
27547
27549
|
}
|
|
27548
|
-
|
|
27549
|
-
|
|
27550
|
-
|
|
27551
|
-
|
|
27552
|
-
|
|
27553
|
-
for (idx_t i = 0; i < count; i++) {
|
|
27554
|
-
const string_t str = Load<string_t>(row_ptr + col_offset);
|
|
27555
|
-
if (!str.IsInlined()) {
|
|
27556
|
-
// Load the pointer to the start of the row in the heap
|
|
27557
|
-
data_ptr_t heap_row_ptr = Load<data_ptr_t>(row_ptr + heap_pointer_offset);
|
|
27558
|
-
// This is where the pointer that points to the heap is stored in the RowLayout
|
|
27559
|
-
data_ptr_t col_ptr = row_ptr + col_offset + string_pointer_offset;
|
|
27560
|
-
// Load the pointer to the data of this column in the same heap row
|
|
27561
|
-
data_ptr_t heap_col_ptr = Load<data_ptr_t>(col_ptr);
|
|
27562
|
-
// Overwrite the column data pointer with the within-row offset (pointer arithmetic)
|
|
27563
|
-
Store<idx_t>(heap_col_ptr - heap_row_ptr, col_ptr);
|
|
27564
|
-
}
|
|
27565
|
-
row_ptr += row_width;
|
|
27550
|
+
// Loop through the blob columns
|
|
27551
|
+
for (idx_t col_idx = 0; col_idx < layout.ColumnCount(); col_idx++) {
|
|
27552
|
+
auto physical_type = layout.GetTypes()[col_idx].InternalType();
|
|
27553
|
+
if (TypeIsConstantSize(physical_type)) {
|
|
27554
|
+
continue;
|
|
27566
27555
|
}
|
|
27567
|
-
|
|
27568
|
-
|
|
27569
|
-
|
|
27570
|
-
|
|
27571
|
-
|
|
27572
|
-
|
|
27573
|
-
|
|
27574
|
-
|
|
27575
|
-
|
|
27576
|
-
|
|
27577
|
-
|
|
27578
|
-
|
|
27556
|
+
data_ptr_t col_ptr = row_ptr + layout.GetOffsets()[col_idx];
|
|
27557
|
+
if (physical_type == PhysicalType::VARCHAR) {
|
|
27558
|
+
data_ptr_t string_ptr = col_ptr + sizeof(uint32_t) + string_t::PREFIX_LENGTH;
|
|
27559
|
+
for (idx_t i = 0; i < next; i++) {
|
|
27560
|
+
if (Load<uint32_t>(col_ptr) > string_t::INLINE_LENGTH) {
|
|
27561
|
+
// Overwrite the string pointer with the within-row offset (if not inlined)
|
|
27562
|
+
Store<idx_t>(Load<data_ptr_t>(string_ptr) - heap_row_ptrs[i], string_ptr);
|
|
27563
|
+
}
|
|
27564
|
+
col_ptr += row_width;
|
|
27565
|
+
string_ptr += row_width;
|
|
27566
|
+
}
|
|
27567
|
+
} else {
|
|
27568
|
+
// Non-varchar blob columns
|
|
27569
|
+
for (idx_t i = 0; i < next; i++) {
|
|
27570
|
+
// Overwrite the column data pointer with the within-row offset
|
|
27571
|
+
Store<idx_t>(Load<data_ptr_t>(col_ptr) - heap_row_ptrs[i], col_ptr);
|
|
27572
|
+
col_ptr += row_width;
|
|
27573
|
+
}
|
|
27579
27574
|
}
|
|
27580
27575
|
}
|
|
27576
|
+
done += next;
|
|
27581
27577
|
}
|
|
27582
27578
|
}
|
|
27583
27579
|
|
|
@@ -27593,59 +27589,48 @@ void RowOperations::SwizzleHeapPointer(const RowLayout &layout, data_ptr_t row_p
|
|
|
27593
27589
|
}
|
|
27594
27590
|
}
|
|
27595
27591
|
|
|
27596
|
-
void RowOperations::
|
|
27597
|
-
|
|
27598
|
-
const idx_t row_width = layout.GetRowWidth();
|
|
27599
|
-
row_ptr += layout.GetHeapPointerOffset();
|
|
27600
|
-
for (idx_t i = 0; i < count; i++) {
|
|
27601
|
-
idx_t heap_row_offset = Load<idx_t>(row_ptr);
|
|
27602
|
-
Store<data_ptr_t>(heap_base_ptr + heap_row_offset, row_ptr);
|
|
27603
|
-
row_ptr += row_width;
|
|
27604
|
-
}
|
|
27605
|
-
}
|
|
27606
|
-
|
|
27607
|
-
void RowOperations::UnswizzleColumns(const RowLayout &layout, const data_ptr_t base_row_ptr, const idx_t count) {
|
|
27592
|
+
void RowOperations::UnswizzlePointers(const RowLayout &layout, const data_ptr_t base_row_ptr,
|
|
27593
|
+
const data_ptr_t base_heap_ptr, const idx_t count) {
|
|
27608
27594
|
const idx_t row_width = layout.GetRowWidth();
|
|
27609
|
-
|
|
27610
|
-
|
|
27611
|
-
|
|
27612
|
-
|
|
27613
|
-
|
|
27614
|
-
|
|
27615
|
-
|
|
27616
|
-
|
|
27617
|
-
|
|
27618
|
-
|
|
27619
|
-
|
|
27620
|
-
|
|
27621
|
-
|
|
27622
|
-
|
|
27623
|
-
|
|
27624
|
-
|
|
27625
|
-
|
|
27626
|
-
|
|
27627
|
-
|
|
27628
|
-
|
|
27629
|
-
|
|
27595
|
+
data_ptr_t heap_row_ptrs[STANDARD_VECTOR_SIZE];
|
|
27596
|
+
idx_t done = 0;
|
|
27597
|
+
while (done != count) {
|
|
27598
|
+
const idx_t next = MinValue<idx_t>(count - done, STANDARD_VECTOR_SIZE);
|
|
27599
|
+
const data_ptr_t row_ptr = base_row_ptr + done * row_width;
|
|
27600
|
+
// Restore heap row pointers
|
|
27601
|
+
data_ptr_t heap_ptr_ptr = row_ptr + layout.GetHeapPointerOffset();
|
|
27602
|
+
for (idx_t i = 0; i < next; i++) {
|
|
27603
|
+
heap_row_ptrs[i] = base_heap_ptr + Load<idx_t>(heap_ptr_ptr);
|
|
27604
|
+
Store<data_ptr_t>(heap_row_ptrs[i], heap_ptr_ptr);
|
|
27605
|
+
heap_ptr_ptr += row_width;
|
|
27606
|
+
}
|
|
27607
|
+
// Loop through the blob columns
|
|
27608
|
+
for (idx_t col_idx = 0; col_idx < layout.ColumnCount(); col_idx++) {
|
|
27609
|
+
auto physical_type = layout.GetTypes()[col_idx].InternalType();
|
|
27610
|
+
if (TypeIsConstantSize(physical_type)) {
|
|
27611
|
+
continue;
|
|
27612
|
+
}
|
|
27613
|
+
data_ptr_t col_ptr = row_ptr + layout.GetOffsets()[col_idx];
|
|
27614
|
+
if (physical_type == PhysicalType::VARCHAR) {
|
|
27615
|
+
data_ptr_t string_ptr = col_ptr + sizeof(uint32_t) + string_t::PREFIX_LENGTH;
|
|
27616
|
+
for (idx_t i = 0; i < next; i++) {
|
|
27617
|
+
if (Load<uint32_t>(col_ptr) > string_t::INLINE_LENGTH) {
|
|
27618
|
+
// Overwrite the string offset with the pointer (if not inlined)
|
|
27619
|
+
Store<data_ptr_t>(heap_row_ptrs[i] + Load<idx_t>(string_ptr), string_ptr);
|
|
27620
|
+
}
|
|
27621
|
+
col_ptr += row_width;
|
|
27622
|
+
string_ptr += row_width;
|
|
27623
|
+
}
|
|
27624
|
+
} else {
|
|
27625
|
+
// Non-varchar blob columns
|
|
27626
|
+
for (idx_t i = 0; i < next; i++) {
|
|
27630
27627
|
// Overwrite the column data offset with the pointer
|
|
27631
|
-
Store<data_ptr_t>(
|
|
27628
|
+
Store<data_ptr_t>(heap_row_ptrs[i] + Load<idx_t>(col_ptr), col_ptr);
|
|
27629
|
+
col_ptr += row_width;
|
|
27632
27630
|
}
|
|
27633
|
-
row_ptr += row_width;
|
|
27634
|
-
}
|
|
27635
|
-
} else {
|
|
27636
|
-
// Replace the offset with the pointer
|
|
27637
|
-
for (idx_t i = 0; i < count; i++) {
|
|
27638
|
-
// Load the pointer to the start of the row in the heap
|
|
27639
|
-
data_ptr_t heap_row_ptr = Load<data_ptr_t>(row_ptr + heap_pointer_offset);
|
|
27640
|
-
// This is where the pointer that points to the heap is stored in the RowLayout
|
|
27641
|
-
data_ptr_t col_ptr = row_ptr + col_offset;
|
|
27642
|
-
// Load the offset to the data of this column in the same heap row
|
|
27643
|
-
idx_t heap_col_offset = Load<idx_t>(col_ptr);
|
|
27644
|
-
// Overwrite the column data offset with the pointer
|
|
27645
|
-
Store<data_ptr_t>(heap_row_ptr + heap_col_offset, col_ptr);
|
|
27646
|
-
row_ptr += row_width;
|
|
27647
27631
|
}
|
|
27648
27632
|
}
|
|
27633
|
+
done += next;
|
|
27649
27634
|
}
|
|
27650
27635
|
}
|
|
27651
27636
|
|
|
@@ -32716,8 +32701,7 @@ void SortedData::Unswizzle() {
|
|
|
32716
32701
|
auto &heap_block = heap_blocks[i];
|
|
32717
32702
|
auto data_handle_p = buffer_manager.Pin(data_block.block);
|
|
32718
32703
|
auto heap_handle_p = buffer_manager.Pin(heap_block.block);
|
|
32719
|
-
RowOperations::
|
|
32720
|
-
RowOperations::UnswizzleColumns(layout, data_handle_p->Ptr(), data_block.count);
|
|
32704
|
+
RowOperations::UnswizzlePointers(layout, data_handle_p->Ptr(), heap_handle_p->Ptr(), data_block.count);
|
|
32721
32705
|
state.heap_blocks.push_back(move(heap_block));
|
|
32722
32706
|
state.pinned_blocks.push_back(move(heap_handle_p));
|
|
32723
32707
|
}
|
|
@@ -32963,9 +32947,7 @@ void PayloadScanner::Scan(DataChunk &chunk) {
|
|
|
32963
32947
|
}
|
|
32964
32948
|
// Unswizzle the offsets back to pointers (if needed)
|
|
32965
32949
|
if (!sorted_data.layout.AllConstant() && global_sort_state.external) {
|
|
32966
|
-
RowOperations::
|
|
32967
|
-
next);
|
|
32968
|
-
RowOperations::UnswizzleColumns(sorted_data.layout, data_ptr, next);
|
|
32950
|
+
RowOperations::UnswizzlePointers(sorted_data.layout, data_ptr, read_state.payload_heap_handle->Ptr(), next);
|
|
32969
32951
|
}
|
|
32970
32952
|
// Update state indices
|
|
32971
32953
|
read_state.entry_idx += next;
|
package/src/duckdb.hpp
CHANGED
|
@@ -10,8 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
10
10
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
|
-
#define DUCKDB_SOURCE_ID "
|
|
14
|
-
#define DUCKDB_VERSION "0.3.2-
|
|
13
|
+
#define DUCKDB_SOURCE_ID "0546552f6"
|
|
14
|
+
#define DUCKDB_VERSION "0.3.2-dev528"
|
|
15
15
|
//===----------------------------------------------------------------------===//
|
|
16
16
|
// DuckDB
|
|
17
17
|
//
|