duckdb 0.7.2-dev832.0 → 0.7.2-dev886.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/src/catalog/catalog.cpp +21 -5
- package/src/duckdb/src/catalog/default/default_functions.cpp +3 -0
- package/src/duckdb/src/catalog/duck_catalog.cpp +34 -7
- package/src/duckdb/src/common/box_renderer.cpp +109 -23
- package/src/duckdb/src/common/types/value.cpp +0 -93
- package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +3 -0
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +5 -8
- package/src/duckdb/src/function/scalar/date/date_part.cpp +2 -2
- package/src/duckdb/src/function/scalar/date/date_trunc.cpp +2 -2
- package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +1 -1
- package/src/duckdb/src/function/scalar/list/list_lambdas.cpp +4 -0
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +8 -8
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +3 -0
- package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/box_renderer.hpp +8 -2
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +0 -31
- package/src/duckdb/src/include/duckdb/optimizer/filter_pushdown.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats.hpp +9 -52
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats_union.hpp +62 -0
- package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +6 -3
- package/src/duckdb/src/include/duckdb/storage/table/column_data_checkpointer.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +5 -3
- package/src/duckdb/src/include/duckdb/storage/table/persistent_table_data.hpp +4 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +6 -3
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +5 -3
- package/src/duckdb/src/include/duckdb/storage/table/row_group_segment_tree.hpp +37 -0
- package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +8 -1
- package/src/duckdb/src/include/duckdb/storage/table/segment_base.hpp +4 -3
- package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +271 -26
- package/src/duckdb/src/optimizer/filter_pushdown.cpp +11 -7
- package/src/duckdb/src/optimizer/pushdown/pushdown_left_join.cpp +1 -10
- package/src/duckdb/src/optimizer/pushdown/pushdown_mark_join.cpp +1 -1
- package/src/duckdb/src/optimizer/pushdown/pushdown_single_join.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_array_access.cpp +11 -0
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +31 -6
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +22 -4
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +1 -1
- package/src/duckdb/src/storage/checkpoint/table_data_reader.cpp +3 -11
- package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +6 -0
- package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -0
- package/src/duckdb/src/storage/compression/numeric_constant.cpp +2 -2
- package/src/duckdb/src/storage/data_table.cpp +1 -1
- package/src/duckdb/src/storage/statistics/numeric_stats.cpp +145 -83
- package/src/duckdb/src/storage/statistics/numeric_stats_union.cpp +65 -0
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +1 -6
- package/src/duckdb/src/storage/table/column_data.cpp +29 -35
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +5 -5
- package/src/duckdb/src/storage/table/column_segment.cpp +8 -7
- package/src/duckdb/src/storage/table/list_column_data.cpp +2 -1
- package/src/duckdb/src/storage/table/persistent_table_data.cpp +2 -1
- package/src/duckdb/src/storage/table/row_group.cpp +9 -9
- package/src/duckdb/src/storage/table/row_group_collection.cpp +82 -66
- package/src/duckdb/src/storage/table/scan_state.cpp +22 -3
- package/src/duckdb/src/storage/table/standard_column_data.cpp +1 -0
- package/src/duckdb/src/storage/table/struct_column_data.cpp +1 -0
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +11578 -11222
- package/src/duckdb/ub_src_storage_statistics.cpp +2 -0
- package/src/duckdb/ub_src_storage_table.cpp +0 -2
- package/src/duckdb/src/storage/table/segment_tree.cpp +0 -179
@@ -531,37 +531,6 @@ DUCKDB_API timestamp_t Value::GetValueUnsafe() const;
|
|
531
531
|
template <>
|
532
532
|
DUCKDB_API interval_t Value::GetValueUnsafe() const;
|
533
533
|
|
534
|
-
template <>
|
535
|
-
DUCKDB_API int8_t &Value::GetReferenceUnsafe();
|
536
|
-
template <>
|
537
|
-
DUCKDB_API int16_t &Value::GetReferenceUnsafe();
|
538
|
-
template <>
|
539
|
-
DUCKDB_API int32_t &Value::GetReferenceUnsafe();
|
540
|
-
template <>
|
541
|
-
DUCKDB_API int64_t &Value::GetReferenceUnsafe();
|
542
|
-
template <>
|
543
|
-
DUCKDB_API hugeint_t &Value::GetReferenceUnsafe();
|
544
|
-
template <>
|
545
|
-
DUCKDB_API uint8_t &Value::GetReferenceUnsafe();
|
546
|
-
template <>
|
547
|
-
DUCKDB_API uint16_t &Value::GetReferenceUnsafe();
|
548
|
-
template <>
|
549
|
-
DUCKDB_API uint32_t &Value::GetReferenceUnsafe();
|
550
|
-
template <>
|
551
|
-
DUCKDB_API uint64_t &Value::GetReferenceUnsafe();
|
552
|
-
template <>
|
553
|
-
DUCKDB_API float &Value::GetReferenceUnsafe();
|
554
|
-
template <>
|
555
|
-
DUCKDB_API double &Value::GetReferenceUnsafe();
|
556
|
-
template <>
|
557
|
-
DUCKDB_API date_t &Value::GetReferenceUnsafe();
|
558
|
-
template <>
|
559
|
-
DUCKDB_API dtime_t &Value::GetReferenceUnsafe();
|
560
|
-
template <>
|
561
|
-
DUCKDB_API timestamp_t &Value::GetReferenceUnsafe();
|
562
|
-
template <>
|
563
|
-
DUCKDB_API interval_t &Value::GetReferenceUnsafe();
|
564
|
-
|
565
534
|
template <>
|
566
535
|
DUCKDB_API bool Value::IsNan(float input);
|
567
536
|
template <>
|
@@ -67,6 +67,8 @@ private:
|
|
67
67
|
unique_ptr<LogicalOperator> PushdownSingleJoin(unique_ptr<LogicalOperator> op, unordered_set<idx_t> &left_bindings,
|
68
68
|
unordered_set<idx_t> &right_bindings);
|
69
69
|
|
70
|
+
//! Push any remaining filters into a LogicalFilter at this level
|
71
|
+
unique_ptr<LogicalOperator> PushFinalFilters(unique_ptr<LogicalOperator> op);
|
70
72
|
// Finish pushing down at this operator, creating a LogicalFilter to store any of the stored filters and recursively
|
71
73
|
// pushing down into its children (if any)
|
72
74
|
unique_ptr<LogicalOperator> FinishPushdown(unique_ptr<LogicalOperator> op);
|
@@ -8,9 +8,7 @@
|
|
8
8
|
|
9
9
|
#pragma once
|
10
10
|
|
11
|
-
#include "duckdb/
|
12
|
-
#include "duckdb/common/exception.hpp"
|
13
|
-
#include "duckdb/common/types/hugeint.hpp"
|
11
|
+
#include "duckdb/storage/statistics/numeric_stats_union.hpp"
|
14
12
|
#include "duckdb/common/enums/filter_propagate_result.hpp"
|
15
13
|
#include "duckdb/common/enums/expression_type.hpp"
|
16
14
|
#include "duckdb/common/operator/comparison_operators.hpp"
|
@@ -23,28 +21,6 @@ class FieldReader;
|
|
23
21
|
struct SelectionVector;
|
24
22
|
class Vector;
|
25
23
|
|
26
|
-
struct NumericValueUnion {
|
27
|
-
union Val {
|
28
|
-
int8_t boolean;
|
29
|
-
int8_t tinyint;
|
30
|
-
int16_t smallint;
|
31
|
-
int32_t integer;
|
32
|
-
int64_t bigint;
|
33
|
-
uint8_t utinyint;
|
34
|
-
uint16_t usmallint;
|
35
|
-
uint32_t uinteger;
|
36
|
-
uint64_t ubigint;
|
37
|
-
hugeint_t hugeint;
|
38
|
-
float float_;
|
39
|
-
double double_;
|
40
|
-
} value_;
|
41
|
-
|
42
|
-
template <class T>
|
43
|
-
T &GetReferenceUnsafe() {
|
44
|
-
throw InternalException("NumericValueUnion::GetReferenceUnsafe called on unsupported type");
|
45
|
-
}
|
46
|
-
};
|
47
|
-
|
48
24
|
struct NumericStatsData {
|
49
25
|
//! Whether or not the value has a max value
|
50
26
|
bool has_min;
|
@@ -109,13 +85,17 @@ struct NumericStats {
|
|
109
85
|
static void Verify(const BaseStatistics &stats, Vector &vector, const SelectionVector &sel, idx_t count);
|
110
86
|
|
111
87
|
template <class T>
|
112
|
-
static T
|
113
|
-
return NumericStats::Min(stats).
|
88
|
+
static T GetMin(const BaseStatistics &stats) {
|
89
|
+
return NumericStats::Min(stats).GetValueUnsafe<T>();
|
114
90
|
}
|
115
91
|
template <class T>
|
116
|
-
static T
|
117
|
-
return NumericStats::Max(stats).
|
92
|
+
static T GetMax(const BaseStatistics &stats) {
|
93
|
+
return NumericStats::Max(stats).GetValueUnsafe<T>();
|
118
94
|
}
|
95
|
+
template <class T>
|
96
|
+
static T GetMinUnsafe(const BaseStatistics &stats);
|
97
|
+
template <class T>
|
98
|
+
static T GetMaxUnsafe(const BaseStatistics &stats);
|
119
99
|
|
120
100
|
private:
|
121
101
|
static NumericStatsData &GetDataUnsafe(BaseStatistics &stats);
|
@@ -131,27 +111,4 @@ void NumericStats::Update<interval_t>(BaseStatistics &stats, interval_t new_valu
|
|
131
111
|
template <>
|
132
112
|
void NumericStats::Update<list_entry_t>(BaseStatistics &stats, list_entry_t new_value);
|
133
113
|
|
134
|
-
template <>
|
135
|
-
int8_t &NumericValueUnion::GetReferenceUnsafe();
|
136
|
-
template <>
|
137
|
-
int16_t &NumericValueUnion::GetReferenceUnsafe();
|
138
|
-
template <>
|
139
|
-
int32_t &NumericValueUnion::GetReferenceUnsafe();
|
140
|
-
template <>
|
141
|
-
int64_t &NumericValueUnion::GetReferenceUnsafe();
|
142
|
-
template <>
|
143
|
-
hugeint_t &NumericValueUnion::GetReferenceUnsafe();
|
144
|
-
template <>
|
145
|
-
uint8_t &NumericValueUnion::GetReferenceUnsafe();
|
146
|
-
template <>
|
147
|
-
uint16_t &NumericValueUnion::GetReferenceUnsafe();
|
148
|
-
template <>
|
149
|
-
uint32_t &NumericValueUnion::GetReferenceUnsafe();
|
150
|
-
template <>
|
151
|
-
uint64_t &NumericValueUnion::GetReferenceUnsafe();
|
152
|
-
template <>
|
153
|
-
float &NumericValueUnion::GetReferenceUnsafe();
|
154
|
-
template <>
|
155
|
-
double &NumericValueUnion::GetReferenceUnsafe();
|
156
|
-
|
157
114
|
} // namespace duckdb
|
@@ -0,0 +1,62 @@
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
2
|
+
// DuckDB
|
3
|
+
//
|
4
|
+
// duckdb/storage/statistics/numeric_stats_union.hpp
|
5
|
+
//
|
6
|
+
//
|
7
|
+
//===----------------------------------------------------------------------===//
|
8
|
+
|
9
|
+
#pragma once
|
10
|
+
|
11
|
+
#include "duckdb/common/common.hpp"
|
12
|
+
#include "duckdb/common/exception.hpp"
|
13
|
+
#include "duckdb/common/types/hugeint.hpp"
|
14
|
+
|
15
|
+
namespace duckdb {
|
16
|
+
|
17
|
+
struct NumericValueUnion {
|
18
|
+
union Val {
|
19
|
+
bool boolean;
|
20
|
+
int8_t tinyint;
|
21
|
+
int16_t smallint;
|
22
|
+
int32_t integer;
|
23
|
+
int64_t bigint;
|
24
|
+
uint8_t utinyint;
|
25
|
+
uint16_t usmallint;
|
26
|
+
uint32_t uinteger;
|
27
|
+
uint64_t ubigint;
|
28
|
+
hugeint_t hugeint;
|
29
|
+
float float_;
|
30
|
+
double double_;
|
31
|
+
} value_;
|
32
|
+
|
33
|
+
template <class T>
|
34
|
+
T &GetReferenceUnsafe();
|
35
|
+
};
|
36
|
+
|
37
|
+
template <>
|
38
|
+
DUCKDB_API bool &NumericValueUnion::GetReferenceUnsafe();
|
39
|
+
template <>
|
40
|
+
DUCKDB_API int8_t &NumericValueUnion::GetReferenceUnsafe();
|
41
|
+
template <>
|
42
|
+
DUCKDB_API int16_t &NumericValueUnion::GetReferenceUnsafe();
|
43
|
+
template <>
|
44
|
+
DUCKDB_API int32_t &NumericValueUnion::GetReferenceUnsafe();
|
45
|
+
template <>
|
46
|
+
DUCKDB_API int64_t &NumericValueUnion::GetReferenceUnsafe();
|
47
|
+
template <>
|
48
|
+
DUCKDB_API hugeint_t &NumericValueUnion::GetReferenceUnsafe();
|
49
|
+
template <>
|
50
|
+
DUCKDB_API uint8_t &NumericValueUnion::GetReferenceUnsafe();
|
51
|
+
template <>
|
52
|
+
DUCKDB_API uint16_t &NumericValueUnion::GetReferenceUnsafe();
|
53
|
+
template <>
|
54
|
+
DUCKDB_API uint32_t &NumericValueUnion::GetReferenceUnsafe();
|
55
|
+
template <>
|
56
|
+
DUCKDB_API uint64_t &NumericValueUnion::GetReferenceUnsafe();
|
57
|
+
template <>
|
58
|
+
DUCKDB_API float &NumericValueUnion::GetReferenceUnsafe();
|
59
|
+
template <>
|
60
|
+
DUCKDB_API double &NumericValueUnion::GetReferenceUnsafe();
|
61
|
+
|
62
|
+
} // namespace duckdb
|
@@ -13,6 +13,7 @@
|
|
13
13
|
#include "duckdb/storage/data_pointer.hpp"
|
14
14
|
#include "duckdb/storage/statistics/segment_statistics.hpp"
|
15
15
|
#include "duckdb/storage/table/column_segment.hpp"
|
16
|
+
#include "duckdb/storage/table/column_data.hpp"
|
16
17
|
#include "duckdb/common/unordered_set.hpp"
|
17
18
|
|
18
19
|
namespace duckdb {
|
@@ -28,7 +29,7 @@ struct ColumnCheckpointState {
|
|
28
29
|
|
29
30
|
RowGroup &row_group;
|
30
31
|
ColumnData &column_data;
|
31
|
-
|
32
|
+
ColumnSegmentTree new_tree;
|
32
33
|
vector<DataPointer> data_pointers;
|
33
34
|
unique_ptr<BaseStatistics> global_stats;
|
34
35
|
|
@@ -15,7 +15,8 @@
|
|
15
15
|
#include "duckdb/storage/data_pointer.hpp"
|
16
16
|
#include "duckdb/storage/table/persistent_table_data.hpp"
|
17
17
|
#include "duckdb/storage/statistics/segment_statistics.hpp"
|
18
|
-
#include "duckdb/storage/table/
|
18
|
+
#include "duckdb/storage/table/segment_tree.hpp"
|
19
|
+
#include "duckdb/storage/table/column_segment.hpp"
|
19
20
|
#include "duckdb/common/mutex.hpp"
|
20
21
|
|
21
22
|
namespace duckdb {
|
@@ -31,10 +32,12 @@ struct TransactionData;
|
|
31
32
|
struct DataTableInfo;
|
32
33
|
|
33
34
|
struct ColumnCheckpointInfo {
|
34
|
-
ColumnCheckpointInfo(CompressionType compression_type_p) : compression_type(compression_type_p) {};
|
35
|
+
explicit ColumnCheckpointInfo(CompressionType compression_type_p) : compression_type(compression_type_p) {};
|
35
36
|
CompressionType compression_type;
|
36
37
|
};
|
37
38
|
|
39
|
+
class ColumnSegmentTree : public SegmentTree<ColumnSegment> {};
|
40
|
+
|
38
41
|
class ColumnData {
|
39
42
|
friend class ColumnDataCheckpointer;
|
40
43
|
|
@@ -148,7 +151,7 @@ protected:
|
|
148
151
|
|
149
152
|
protected:
|
150
153
|
//! The segments holding the data of this column segment
|
151
|
-
|
154
|
+
ColumnSegmentTree data;
|
152
155
|
//! The lock for the updates
|
153
156
|
mutex update_lock;
|
154
157
|
//! The updates for this column segment
|
@@ -10,6 +10,7 @@
|
|
10
10
|
|
11
11
|
#include "duckdb/storage/table/column_data.hpp"
|
12
12
|
#include "duckdb/function/compression_function.hpp"
|
13
|
+
#include "duckdb/storage/table/column_checkpoint_state.hpp"
|
13
14
|
|
14
15
|
namespace duckdb {
|
15
16
|
|
@@ -25,7 +26,7 @@ public:
|
|
25
26
|
RowGroup &GetRowGroup();
|
26
27
|
ColumnCheckpointState &GetCheckpointState();
|
27
28
|
|
28
|
-
void Checkpoint(vector<SegmentNode
|
29
|
+
void Checkpoint(vector<SegmentNode<ColumnSegment>> nodes);
|
29
30
|
|
30
31
|
private:
|
31
32
|
void ScanSegments(const std::function<void(Vector &, idx_t)> &callback);
|
@@ -40,7 +41,7 @@ private:
|
|
40
41
|
ColumnCheckpointState &state;
|
41
42
|
bool is_validity;
|
42
43
|
Vector intermediate;
|
43
|
-
vector<SegmentNode
|
44
|
+
vector<SegmentNode<ColumnSegment>> nodes;
|
44
45
|
vector<CompressionFunction *> compression_functions;
|
45
46
|
ColumnCheckpointInfo &checkpoint_info;
|
46
47
|
};
|
@@ -9,7 +9,6 @@
|
|
9
9
|
#pragma once
|
10
10
|
|
11
11
|
#include "duckdb/storage/block.hpp"
|
12
|
-
#include "duckdb/storage/table/segment_tree.hpp"
|
13
12
|
#include "duckdb/common/types.hpp"
|
14
13
|
#include "duckdb/common/types/vector.hpp"
|
15
14
|
#include "duckdb/storage/buffer_manager.hpp"
|
@@ -17,6 +16,7 @@
|
|
17
16
|
#include "duckdb/storage/storage_lock.hpp"
|
18
17
|
#include "duckdb/storage/table/scan_state.hpp"
|
19
18
|
#include "duckdb/function/compression_function.hpp"
|
19
|
+
#include "duckdb/storage/table/segment_base.hpp"
|
20
20
|
|
21
21
|
namespace duckdb {
|
22
22
|
class ColumnSegment;
|
@@ -35,10 +35,12 @@ struct ColumnAppendState;
|
|
35
35
|
enum class ColumnSegmentType : uint8_t { TRANSIENT, PERSISTENT };
|
36
36
|
//! TableFilter represents a filter pushed down into the table scan.
|
37
37
|
|
38
|
-
class ColumnSegment : public SegmentBase {
|
38
|
+
class ColumnSegment : public SegmentBase<ColumnSegment> {
|
39
39
|
public:
|
40
|
-
~ColumnSegment()
|
40
|
+
~ColumnSegment();
|
41
41
|
|
42
|
+
//! The index within the segment tree
|
43
|
+
idx_t index;
|
42
44
|
//! The database instance
|
43
45
|
DatabaseInstance &db;
|
44
46
|
//! The type stored in the column
|
@@ -22,8 +22,11 @@ public:
|
|
22
22
|
explicit PersistentTableData(idx_t column_count);
|
23
23
|
~PersistentTableData();
|
24
24
|
|
25
|
-
vector<RowGroupPointer> row_groups;
|
26
25
|
TableStatistics table_stats;
|
26
|
+
idx_t total_rows;
|
27
|
+
idx_t row_group_count;
|
28
|
+
block_id_t block_id;
|
29
|
+
idx_t offset;
|
27
30
|
};
|
28
31
|
|
29
32
|
} // namespace duckdb
|
@@ -9,7 +9,6 @@
|
|
9
9
|
#pragma once
|
10
10
|
|
11
11
|
#include "duckdb/common/vector_size.hpp"
|
12
|
-
#include "duckdb/storage/table/segment_base.hpp"
|
13
12
|
#include "duckdb/storage/table/chunk_info.hpp"
|
14
13
|
#include "duckdb/storage/table/append_state.hpp"
|
15
14
|
#include "duckdb/storage/table/scan_state.hpp"
|
@@ -17,6 +16,7 @@
|
|
17
16
|
#include "duckdb/common/enums/scan_options.hpp"
|
18
17
|
#include "duckdb/common/mutex.hpp"
|
19
18
|
#include "duckdb/parser/column_list.hpp"
|
19
|
+
#include "duckdb/storage/table/segment_base.hpp"
|
20
20
|
|
21
21
|
namespace duckdb {
|
22
22
|
class AttachedDatabase;
|
@@ -42,7 +42,7 @@ struct RowGroupWriteData {
|
|
42
42
|
vector<BaseStatistics> statistics;
|
43
43
|
};
|
44
44
|
|
45
|
-
class RowGroup : public SegmentBase {
|
45
|
+
class RowGroup : public SegmentBase<RowGroup> {
|
46
46
|
public:
|
47
47
|
friend class ColumnData;
|
48
48
|
friend class VersionDeleteState;
|
@@ -58,6 +58,9 @@ public:
|
|
58
58
|
RowGroup(RowGroup &row_group, idx_t start);
|
59
59
|
~RowGroup();
|
60
60
|
|
61
|
+
//! The index within the segment tree
|
62
|
+
idx_t index;
|
63
|
+
|
61
64
|
private:
|
62
65
|
//! The database instance
|
63
66
|
AttachedDatabase &db;
|
@@ -135,7 +138,7 @@ public:
|
|
135
138
|
RowGroupWriteData WriteToDisk(PartialBlockManager &manager, const vector<CompressionType> &compression_types);
|
136
139
|
RowGroupPointer Checkpoint(RowGroupWriter &writer, TableStatistics &global_stats);
|
137
140
|
static void Serialize(RowGroupPointer &pointer, Serializer &serializer);
|
138
|
-
static RowGroupPointer Deserialize(Deserializer &source, const
|
141
|
+
static RowGroupPointer Deserialize(Deserializer &source, const vector<LogicalType> &columns);
|
139
142
|
|
140
143
|
void InitializeAppend(RowGroupAppendState &append_state);
|
141
144
|
void Append(RowGroupAppendState &append_state, DataChunk &chunk, idx_t append_count);
|
@@ -23,6 +23,8 @@ class TableStatistics;
|
|
23
23
|
|
24
24
|
class BoundConstraint;
|
25
25
|
|
26
|
+
class RowGroupSegmentTree;
|
27
|
+
|
26
28
|
class RowGroupCollection {
|
27
29
|
public:
|
28
30
|
RowGroupCollection(shared_ptr<DataTableInfo> info, BlockManager &block_manager, vector<LogicalType> types,
|
@@ -46,8 +48,8 @@ public:
|
|
46
48
|
void InitializeCreateIndexScan(CreateIndexScanState &state);
|
47
49
|
void InitializeScanWithOffset(CollectionScanState &state, const vector<column_t> &column_ids, idx_t start_row,
|
48
50
|
idx_t end_row);
|
49
|
-
static bool InitializeScanInRowGroup(CollectionScanState &state,
|
50
|
-
idx_t max_row);
|
51
|
+
static bool InitializeScanInRowGroup(CollectionScanState &state, ParallelCollectionScanState ¶llel_state,
|
52
|
+
idx_t vector_index, idx_t max_row);
|
51
53
|
void InitializeParallelScan(ParallelCollectionScanState &state);
|
52
54
|
bool NextParallelScan(ClientContext &context, ParallelCollectionScanState &state, CollectionScanState &scan_state);
|
53
55
|
|
@@ -109,7 +111,7 @@ private:
|
|
109
111
|
vector<LogicalType> types;
|
110
112
|
idx_t row_start;
|
111
113
|
//! The segment trees holding the various row_groups of the table
|
112
|
-
shared_ptr<
|
114
|
+
shared_ptr<RowGroupSegmentTree> row_groups;
|
113
115
|
//! Table statistics
|
114
116
|
TableStatistics stats;
|
115
117
|
};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
2
|
+
// DuckDB
|
3
|
+
//
|
4
|
+
// duckdb/storage/table/row_group_segment_tree.hpp
|
5
|
+
//
|
6
|
+
//
|
7
|
+
//===----------------------------------------------------------------------===//
|
8
|
+
|
9
|
+
#pragma once
|
10
|
+
|
11
|
+
#include "duckdb/storage/table/segment_tree.hpp"
|
12
|
+
#include "duckdb/storage/table/row_group.hpp"
|
13
|
+
|
14
|
+
namespace duckdb {
|
15
|
+
struct DataTableInfo;
|
16
|
+
class PersistentTableData;
|
17
|
+
class MetaBlockReader;
|
18
|
+
|
19
|
+
class RowGroupSegmentTree : public SegmentTree<RowGroup, true> {
|
20
|
+
public:
|
21
|
+
RowGroupSegmentTree(DataTableInfo &table_info_p, BlockManager &block_manager_p, vector<LogicalType> column_types_p);
|
22
|
+
~RowGroupSegmentTree() override;
|
23
|
+
|
24
|
+
void Initialize(PersistentTableData &data);
|
25
|
+
|
26
|
+
protected:
|
27
|
+
unique_ptr<RowGroup> LoadSegment() override;
|
28
|
+
|
29
|
+
DataTableInfo &info;
|
30
|
+
BlockManager &block_manager;
|
31
|
+
vector<LogicalType> column_types;
|
32
|
+
idx_t current_row_group;
|
33
|
+
idx_t max_row_group;
|
34
|
+
unique_ptr<MetaBlockReader> reader;
|
35
|
+
};
|
36
|
+
|
37
|
+
} // namespace duckdb
|
@@ -25,10 +25,12 @@ class RowGroupCollection;
|
|
25
25
|
class UpdateSegment;
|
26
26
|
class TableScanState;
|
27
27
|
class ColumnSegment;
|
28
|
+
class ColumnSegmentTree;
|
28
29
|
class ValiditySegment;
|
29
30
|
class TableFilterSet;
|
30
31
|
class ColumnData;
|
31
32
|
class DuckTransaction;
|
33
|
+
class RowGroupSegmentTree;
|
32
34
|
|
33
35
|
struct SegmentScanState {
|
34
36
|
virtual ~SegmentScanState() {
|
@@ -45,6 +47,8 @@ typedef unordered_map<block_id_t, BufferHandle> buffer_handle_set_t;
|
|
45
47
|
struct ColumnScanState {
|
46
48
|
//! The column segment that is currently being scanned
|
47
49
|
ColumnSegment *current = nullptr;
|
50
|
+
//! Column segment tree
|
51
|
+
ColumnSegmentTree *segment_tree = nullptr;
|
48
52
|
//! The current row index of the scan
|
49
53
|
idx_t row_index = 0;
|
50
54
|
//! The internal row index (i.e. the position of the SegmentScanState)
|
@@ -114,10 +118,12 @@ private:
|
|
114
118
|
class CollectionScanState {
|
115
119
|
public:
|
116
120
|
CollectionScanState(TableScanState &parent_p)
|
117
|
-
: row_group_state(*this), max_row(0), batch_index(0), parent(parent_p) {};
|
121
|
+
: row_group_state(*this), row_groups(nullptr), max_row(0), batch_index(0), parent(parent_p) {};
|
118
122
|
|
119
123
|
//! The row_group scan state
|
120
124
|
RowGroupScanState row_group_state;
|
125
|
+
//! Row group segment tree
|
126
|
+
RowGroupSegmentTree *row_groups;
|
121
127
|
//! The total maximum row index
|
122
128
|
idx_t max_row;
|
123
129
|
//! The current batch index
|
@@ -129,6 +135,7 @@ public:
|
|
129
135
|
AdaptiveFilter *GetAdaptiveFilter();
|
130
136
|
bool Scan(DuckTransaction &transaction, DataChunk &result);
|
131
137
|
bool ScanCommitted(DataChunk &result, TableScanType type);
|
138
|
+
bool ScanCommitted(DataChunk &result, SegmentLock &l, TableScanType type);
|
132
139
|
|
133
140
|
private:
|
134
141
|
TableScanState &parent;
|
@@ -13,13 +13,14 @@
|
|
13
13
|
|
14
14
|
namespace duckdb {
|
15
15
|
|
16
|
+
template <class T>
|
16
17
|
class SegmentBase {
|
17
18
|
public:
|
18
19
|
SegmentBase(idx_t start, idx_t count) : start(start), count(count), next(nullptr) {
|
19
20
|
}
|
20
21
|
virtual ~SegmentBase() {
|
21
22
|
}
|
22
|
-
|
23
|
+
T *Next() {
|
23
24
|
#ifndef DUCKDB_R_BUILD
|
24
25
|
return next.load();
|
25
26
|
#else
|
@@ -34,9 +35,9 @@ public:
|
|
34
35
|
//! The next segment after this one
|
35
36
|
|
36
37
|
#ifndef DUCKDB_R_BUILD
|
37
|
-
atomic<
|
38
|
+
atomic<T *> next;
|
38
39
|
#else
|
39
|
-
|
40
|
+
T *next;
|
40
41
|
#endif
|
41
42
|
};
|
42
43
|
|