duckdb 0.3.3-dev1383.0 → 0.3.3-dev1393.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 +73 -39
- package/src/duckdb.hpp +18 -9
- package/src/parquet-amalgamation.cpp +36496 -36496
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -53138,10 +53138,11 @@ public:
|
|
|
53138
53138
|
vector<unique_ptr<Expression>> select_list;
|
|
53139
53139
|
|
|
53140
53140
|
public:
|
|
53141
|
+
unique_ptr<GlobalOperatorState> GetGlobalOperatorState(ClientContext &context) const override;
|
|
53141
53142
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
53142
53143
|
|
|
53143
53144
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
53144
|
-
OperatorState &state) const override;
|
|
53145
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
53145
53146
|
|
|
53146
53147
|
string ParamsToString() const override;
|
|
53147
53148
|
};
|
|
@@ -53161,9 +53162,18 @@ PhysicalStreamingWindow::PhysicalStreamingWindow(vector<LogicalType> types, vect
|
|
|
53161
53162
|
: PhysicalOperator(type, move(types), estimated_cardinality), select_list(move(select_list)) {
|
|
53162
53163
|
}
|
|
53163
53164
|
|
|
53165
|
+
class StreamingWindowGlobalState : public GlobalOperatorState {
|
|
53166
|
+
public:
|
|
53167
|
+
StreamingWindowGlobalState() : row_number(1) {
|
|
53168
|
+
}
|
|
53169
|
+
|
|
53170
|
+
//! The next row number.
|
|
53171
|
+
std::atomic<int64_t> row_number;
|
|
53172
|
+
};
|
|
53173
|
+
|
|
53164
53174
|
class StreamingWindowState : public OperatorState {
|
|
53165
53175
|
public:
|
|
53166
|
-
StreamingWindowState() : initialized(false)
|
|
53176
|
+
StreamingWindowState() : initialized(false) {
|
|
53167
53177
|
}
|
|
53168
53178
|
|
|
53169
53179
|
void Initialize(DataChunk &input, const vector<unique_ptr<Expression>> &expressions) {
|
|
@@ -53194,16 +53204,20 @@ public:
|
|
|
53194
53204
|
|
|
53195
53205
|
public:
|
|
53196
53206
|
bool initialized;
|
|
53197
|
-
int64_t row_number;
|
|
53198
53207
|
vector<unique_ptr<Vector>> const_vectors;
|
|
53199
53208
|
};
|
|
53200
53209
|
|
|
53210
|
+
unique_ptr<GlobalOperatorState> PhysicalStreamingWindow::GetGlobalOperatorState(ClientContext &context) const {
|
|
53211
|
+
return make_unique<StreamingWindowGlobalState>();
|
|
53212
|
+
}
|
|
53213
|
+
|
|
53201
53214
|
unique_ptr<OperatorState> PhysicalStreamingWindow::GetOperatorState(ClientContext &context) const {
|
|
53202
53215
|
return make_unique<StreamingWindowState>();
|
|
53203
53216
|
}
|
|
53204
53217
|
|
|
53205
53218
|
OperatorResultType PhysicalStreamingWindow::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
53206
|
-
OperatorState &state_p) const {
|
|
53219
|
+
GlobalOperatorState &gstate_p, OperatorState &state_p) const {
|
|
53220
|
+
auto &gstate = (StreamingWindowGlobalState &)gstate_p;
|
|
53207
53221
|
auto &state = (StreamingWindowState &)state_p;
|
|
53208
53222
|
if (!state.initialized) {
|
|
53209
53223
|
state.Initialize(input, select_list);
|
|
@@ -53230,7 +53244,7 @@ OperatorResultType PhysicalStreamingWindow::Execute(ExecutionContext &context, D
|
|
|
53230
53244
|
// Set row numbers
|
|
53231
53245
|
auto rdata = FlatVector::GetData<int64_t>(chunk.data[col_idx]);
|
|
53232
53246
|
for (idx_t i = 0; i < count; i++) {
|
|
53233
|
-
rdata[i] =
|
|
53247
|
+
rdata[i] = gstate.row_number + i;
|
|
53234
53248
|
}
|
|
53235
53249
|
break;
|
|
53236
53250
|
}
|
|
@@ -53238,7 +53252,7 @@ OperatorResultType PhysicalStreamingWindow::Execute(ExecutionContext &context, D
|
|
|
53238
53252
|
throw NotImplementedException("%s for StreamingWindow", ExpressionTypeToString(expr.GetExpressionType()));
|
|
53239
53253
|
}
|
|
53240
53254
|
}
|
|
53241
|
-
|
|
53255
|
+
gstate.row_number += count;
|
|
53242
53256
|
chunk.SetCardinality(count);
|
|
53243
53257
|
return OperatorResultType::NEED_MORE_INPUT;
|
|
53244
53258
|
}
|
|
@@ -54828,7 +54842,7 @@ public:
|
|
|
54828
54842
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
54829
54843
|
|
|
54830
54844
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
54831
|
-
OperatorState &state) const override;
|
|
54845
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
54832
54846
|
|
|
54833
54847
|
bool ParallelOperator() const override {
|
|
54834
54848
|
return true;
|
|
@@ -54881,7 +54895,7 @@ unique_ptr<OperatorState> PhysicalFilter::GetOperatorState(ClientContext &contex
|
|
|
54881
54895
|
}
|
|
54882
54896
|
|
|
54883
54897
|
OperatorResultType PhysicalFilter::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
54884
|
-
OperatorState &state_p) const {
|
|
54898
|
+
GlobalOperatorState &gstate, OperatorState &state_p) const {
|
|
54885
54899
|
auto &state = (FilterState &)state_p;
|
|
54886
54900
|
idx_t result_count = state.executor.SelectExpression(input, state.sel);
|
|
54887
54901
|
if (result_count == input.size()) {
|
|
@@ -56051,7 +56065,7 @@ public:
|
|
|
56051
56065
|
// Operator interface
|
|
56052
56066
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
56053
56067
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
56054
|
-
OperatorState &state) const override;
|
|
56068
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
56055
56069
|
|
|
56056
56070
|
bool ParallelOperator() const override {
|
|
56057
56071
|
return true;
|
|
@@ -56120,7 +56134,7 @@ unique_ptr<OperatorState> PhysicalStreamingSample::GetOperatorState(ClientContex
|
|
|
56120
56134
|
}
|
|
56121
56135
|
|
|
56122
56136
|
OperatorResultType PhysicalStreamingSample::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
56123
|
-
OperatorState &state) const {
|
|
56137
|
+
GlobalOperatorState &gstate, OperatorState &state) const {
|
|
56124
56138
|
switch (method) {
|
|
56125
56139
|
case SampleMethod::BERNOULLI_SAMPLE:
|
|
56126
56140
|
BernoulliSample(input, chunk, state);
|
|
@@ -56450,7 +56464,7 @@ public:
|
|
|
56450
56464
|
// Operator Interface
|
|
56451
56465
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
56452
56466
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
56453
|
-
OperatorState &state) const override;
|
|
56467
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
56454
56468
|
|
|
56455
56469
|
bool ParallelOperator() const override {
|
|
56456
56470
|
return true;
|
|
@@ -56784,7 +56798,7 @@ public:
|
|
|
56784
56798
|
// Operator Interface
|
|
56785
56799
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
56786
56800
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
56787
|
-
OperatorState &state) const override;
|
|
56801
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
56788
56802
|
|
|
56789
56803
|
bool ParallelOperator() const override {
|
|
56790
56804
|
return true;
|
|
@@ -56923,7 +56937,7 @@ unique_ptr<OperatorState> PhysicalBlockwiseNLJoin::GetOperatorState(ClientContex
|
|
|
56923
56937
|
}
|
|
56924
56938
|
|
|
56925
56939
|
OperatorResultType PhysicalBlockwiseNLJoin::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
56926
|
-
OperatorState &state_p) const {
|
|
56940
|
+
GlobalOperatorState &gstate_p, OperatorState &state_p) const {
|
|
56927
56941
|
D_ASSERT(input.size() > 0);
|
|
56928
56942
|
auto &state = (BlockwiseNLJoinState &)state_p;
|
|
56929
56943
|
auto &gstate = (BlockwiseNLJoinGlobalState &)*sink_state;
|
|
@@ -57186,7 +57200,7 @@ public:
|
|
|
57186
57200
|
// Operator Interface
|
|
57187
57201
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
57188
57202
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
57189
|
-
OperatorState &state) const override;
|
|
57203
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
57190
57204
|
|
|
57191
57205
|
bool ParallelOperator() const override {
|
|
57192
57206
|
return true;
|
|
@@ -57264,7 +57278,7 @@ unique_ptr<OperatorState> PhysicalCrossProduct::GetOperatorState(ClientContext &
|
|
|
57264
57278
|
}
|
|
57265
57279
|
|
|
57266
57280
|
OperatorResultType PhysicalCrossProduct::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
57267
|
-
OperatorState &state_p) const {
|
|
57281
|
+
GlobalOperatorState &gstate, OperatorState &state_p) const {
|
|
57268
57282
|
auto &state = (CrossProductOperatorState &)state_p;
|
|
57269
57283
|
auto &sink = (CrossProductGlobalState &)*sink_state;
|
|
57270
57284
|
auto &right_collection = sink.rhs_materialized;
|
|
@@ -57767,7 +57781,7 @@ unique_ptr<OperatorState> PhysicalHashJoin::GetOperatorState(ClientContext &cont
|
|
|
57767
57781
|
}
|
|
57768
57782
|
|
|
57769
57783
|
OperatorResultType PhysicalHashJoin::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
57770
|
-
OperatorState &state_p) const {
|
|
57784
|
+
GlobalOperatorState &gstate, OperatorState &state_p) const {
|
|
57771
57785
|
auto &state = (PhysicalHashJoinState &)state_p;
|
|
57772
57786
|
auto &sink = (HashJoinGlobalState &)*sink_state;
|
|
57773
57787
|
D_ASSERT(sink.finalized);
|
|
@@ -57868,7 +57882,7 @@ public:
|
|
|
57868
57882
|
public:
|
|
57869
57883
|
// Operator Interface
|
|
57870
57884
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
57871
|
-
OperatorState &state) const override;
|
|
57885
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
57872
57886
|
|
|
57873
57887
|
public:
|
|
57874
57888
|
// Source interface
|
|
@@ -59079,7 +59093,7 @@ void PhysicalIEJoin::ResolveComplexJoin(ExecutionContext &context, DataChunk &ch
|
|
|
59079
59093
|
}
|
|
59080
59094
|
|
|
59081
59095
|
OperatorResultType PhysicalIEJoin::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
59082
|
-
OperatorState &state) const {
|
|
59096
|
+
GlobalOperatorState &gstate, OperatorState &state) const {
|
|
59083
59097
|
return OperatorResultType::FINISHED;
|
|
59084
59098
|
}
|
|
59085
59099
|
|
|
@@ -59366,7 +59380,7 @@ public:
|
|
|
59366
59380
|
public:
|
|
59367
59381
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
59368
59382
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
59369
|
-
OperatorState &state) const override;
|
|
59383
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
59370
59384
|
|
|
59371
59385
|
bool ParallelOperator() const override {
|
|
59372
59386
|
return true;
|
|
@@ -59652,7 +59666,7 @@ void PhysicalIndexJoin::GetRHSMatches(ExecutionContext &context, DataChunk &inpu
|
|
|
59652
59666
|
}
|
|
59653
59667
|
|
|
59654
59668
|
OperatorResultType PhysicalIndexJoin::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
59655
|
-
OperatorState &state_p) const {
|
|
59669
|
+
GlobalOperatorState &gstate, OperatorState &state_p) const {
|
|
59656
59670
|
auto &state = (IndexJoinOperatorState &)state_p;
|
|
59657
59671
|
|
|
59658
59672
|
state.result_size = 0;
|
|
@@ -59729,7 +59743,7 @@ public:
|
|
|
59729
59743
|
// Operator Interface
|
|
59730
59744
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
59731
59745
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
59732
|
-
OperatorState &state) const override;
|
|
59746
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
59733
59747
|
|
|
59734
59748
|
bool ParallelOperator() const override {
|
|
59735
59749
|
return true;
|
|
@@ -60017,7 +60031,7 @@ unique_ptr<OperatorState> PhysicalNestedLoopJoin::GetOperatorState(ClientContext
|
|
|
60017
60031
|
}
|
|
60018
60032
|
|
|
60019
60033
|
OperatorResultType PhysicalNestedLoopJoin::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
60020
|
-
OperatorState &state_p) const {
|
|
60034
|
+
GlobalOperatorState &gstate_p, OperatorState &state_p) const {
|
|
60021
60035
|
auto &gstate = (NestedLoopJoinGlobalState &)*sink_state;
|
|
60022
60036
|
|
|
60023
60037
|
if (gstate.right_chunks.Count() == 0) {
|
|
@@ -60239,7 +60253,7 @@ public:
|
|
|
60239
60253
|
// Operator Interface
|
|
60240
60254
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
60241
60255
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
60242
|
-
OperatorState &state) const override;
|
|
60256
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
60243
60257
|
|
|
60244
60258
|
bool ParallelOperator() const override {
|
|
60245
60259
|
return true;
|
|
@@ -61227,7 +61241,7 @@ OperatorResultType PhysicalPiecewiseMergeJoin::ResolveComplexJoin(ExecutionConte
|
|
|
61227
61241
|
}
|
|
61228
61242
|
|
|
61229
61243
|
OperatorResultType PhysicalPiecewiseMergeJoin::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
61230
|
-
OperatorState &state) const {
|
|
61244
|
+
GlobalOperatorState &gstate_p, OperatorState &state) const {
|
|
61231
61245
|
auto &gstate = (MergeJoinGlobalState &)*sink_state;
|
|
61232
61246
|
|
|
61233
61247
|
if (gstate.Count() == 0) {
|
|
@@ -64966,7 +64980,7 @@ public:
|
|
|
64966
64980
|
public:
|
|
64967
64981
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
64968
64982
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
64969
|
-
OperatorState &state) const override;
|
|
64983
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
64970
64984
|
|
|
64971
64985
|
bool ParallelOperator() const override {
|
|
64972
64986
|
return true;
|
|
@@ -65002,7 +65016,7 @@ PhysicalProjection::PhysicalProjection(vector<LogicalType> types, vector<unique_
|
|
|
65002
65016
|
}
|
|
65003
65017
|
|
|
65004
65018
|
OperatorResultType PhysicalProjection::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
65005
|
-
OperatorState &state_p) const {
|
|
65019
|
+
GlobalOperatorState &gstate, OperatorState &state_p) const {
|
|
65006
65020
|
auto &state = (ProjectionState &)state_p;
|
|
65007
65021
|
state.executor.Execute(input, chunk);
|
|
65008
65022
|
return OperatorResultType::NEED_MORE_INPUT;
|
|
@@ -65047,7 +65061,7 @@ public:
|
|
|
65047
65061
|
public:
|
|
65048
65062
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
65049
65063
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
65050
|
-
OperatorState &state) const override;
|
|
65064
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
65051
65065
|
|
|
65052
65066
|
bool ParallelOperator() const override {
|
|
65053
65067
|
return true;
|
|
@@ -65088,7 +65102,7 @@ unique_ptr<OperatorState> PhysicalTableInOutFunction::GetOperatorState(ClientCon
|
|
|
65088
65102
|
}
|
|
65089
65103
|
|
|
65090
65104
|
OperatorResultType PhysicalTableInOutFunction::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
65091
|
-
OperatorState &state_p) const {
|
|
65105
|
+
GlobalOperatorState &gstate, OperatorState &state_p) const {
|
|
65092
65106
|
auto &state = (TableInOutFunctionState &)state_p;
|
|
65093
65107
|
|
|
65094
65108
|
if (!state.initialized) {
|
|
@@ -65131,7 +65145,7 @@ public:
|
|
|
65131
65145
|
public:
|
|
65132
65146
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
65133
65147
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
65134
|
-
OperatorState &state) const override;
|
|
65148
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
65135
65149
|
|
|
65136
65150
|
bool ParallelOperator() const override {
|
|
65137
65151
|
return true;
|
|
@@ -65291,7 +65305,7 @@ unique_ptr<OperatorState> PhysicalUnnest::GetOperatorState(ClientContext &contex
|
|
|
65291
65305
|
}
|
|
65292
65306
|
|
|
65293
65307
|
OperatorResultType PhysicalUnnest::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
65294
|
-
OperatorState &state_p) const {
|
|
65308
|
+
GlobalOperatorState &gstate, OperatorState &state_p) const {
|
|
65295
65309
|
auto &state = (UnnestOperatorState &)state_p;
|
|
65296
65310
|
do {
|
|
65297
65311
|
if (state.first_fetch) {
|
|
@@ -65579,7 +65593,7 @@ public:
|
|
|
65579
65593
|
public:
|
|
65580
65594
|
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
65581
65595
|
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
65582
|
-
OperatorState &state) const override;
|
|
65596
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
65583
65597
|
|
|
65584
65598
|
bool ParallelOperator() const override {
|
|
65585
65599
|
return true;
|
|
@@ -65614,7 +65628,7 @@ unique_ptr<OperatorState> PhysicalExpressionScan::GetOperatorState(ClientContext
|
|
|
65614
65628
|
}
|
|
65615
65629
|
|
|
65616
65630
|
OperatorResultType PhysicalExpressionScan::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
65617
|
-
OperatorState &state_p) const {
|
|
65631
|
+
GlobalOperatorState &gstate, OperatorState &state_p) const {
|
|
65618
65632
|
auto &state = (ExpressionScanState &)state_p;
|
|
65619
65633
|
|
|
65620
65634
|
for (; chunk.size() + input.size() <= STANDARD_VECTOR_SIZE && state.expression_index < expressions.size();
|
|
@@ -66761,6 +66775,11 @@ void PhysicalRecursiveCTE::ExecuteRecursivePipelines(ExecutionContext &context)
|
|
|
66761
66775
|
// reset the sink state for any intermediate sinks
|
|
66762
66776
|
sink->sink_state = sink->GetGlobalSinkState(context.client);
|
|
66763
66777
|
}
|
|
66778
|
+
for (auto &op : pipeline->GetOperators()) {
|
|
66779
|
+
if (op) {
|
|
66780
|
+
op->op_state = op->GetGlobalOperatorState(context.client);
|
|
66781
|
+
}
|
|
66782
|
+
}
|
|
66764
66783
|
pipeline->Reset();
|
|
66765
66784
|
}
|
|
66766
66785
|
auto &executor = pipelines[0]->executor;
|
|
@@ -67315,8 +67334,12 @@ unique_ptr<OperatorState> PhysicalOperator::GetOperatorState(ClientContext &cont
|
|
|
67315
67334
|
return make_unique<OperatorState>();
|
|
67316
67335
|
}
|
|
67317
67336
|
|
|
67337
|
+
unique_ptr<GlobalOperatorState> PhysicalOperator::GetGlobalOperatorState(ClientContext &context) const {
|
|
67338
|
+
return make_unique<GlobalOperatorState>();
|
|
67339
|
+
}
|
|
67340
|
+
|
|
67318
67341
|
OperatorResultType PhysicalOperator::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
67319
|
-
OperatorState &state) const {
|
|
67342
|
+
GlobalOperatorState &gstate, OperatorState &state) const {
|
|
67320
67343
|
throw InternalException("Calling Execute on a node that is not an operator!");
|
|
67321
67344
|
}
|
|
67322
67345
|
// LCOV_EXCL_STOP
|
|
@@ -131644,6 +131667,7 @@ void Executor::AddChildPipeline(Pipeline *current) {
|
|
|
131644
131667
|
|
|
131645
131668
|
void Executor::BuildPipelines(PhysicalOperator *op, Pipeline *current) {
|
|
131646
131669
|
D_ASSERT(current);
|
|
131670
|
+
op->op_state.reset();
|
|
131647
131671
|
if (op->IsSink()) {
|
|
131648
131672
|
// operator is a sink, build a pipeline
|
|
131649
131673
|
op->sink_state.reset();
|
|
@@ -132146,6 +132170,13 @@ void Pipeline::Reset() {
|
|
|
132146
132170
|
if (sink && !sink->sink_state) {
|
|
132147
132171
|
sink->sink_state = sink->GetGlobalSinkState(GetClientContext());
|
|
132148
132172
|
}
|
|
132173
|
+
|
|
132174
|
+
for (auto &op : operators) {
|
|
132175
|
+
if (op && !op->op_state) {
|
|
132176
|
+
op->op_state = op->GetGlobalOperatorState(GetClientContext());
|
|
132177
|
+
}
|
|
132178
|
+
}
|
|
132179
|
+
|
|
132149
132180
|
ResetSource();
|
|
132150
132181
|
}
|
|
132151
132182
|
|
|
@@ -132514,7 +132545,7 @@ OperatorResultType PipelineExecutor::Execute(DataChunk &input, DataChunk &result
|
|
|
132514
132545
|
// if current_idx > source_idx, we pass the previous' operators output through the Execute of the current
|
|
132515
132546
|
// operator
|
|
132516
132547
|
StartOperator(current_operator);
|
|
132517
|
-
auto result = current_operator->Execute(context, prev_chunk, current_chunk,
|
|
132548
|
+
auto result = current_operator->Execute(context, prev_chunk, current_chunk, *current_operator->op_state,
|
|
132518
132549
|
*intermediate_states[current_intermediate - 1]);
|
|
132519
132550
|
EndOperator(current_operator, ¤t_chunk);
|
|
132520
132551
|
if (result == OperatorResultType::HAVE_MORE_OUTPUT) {
|
|
@@ -153253,6 +153284,9 @@ namespace duckdb {
|
|
|
153253
153284
|
|
|
153254
153285
|
BindResult ExpressionBinder::BindExpression(ParameterExpression &expr, idx_t depth) {
|
|
153255
153286
|
auto bound_parameter = make_unique<BoundParameterExpression>(expr.parameter_nr);
|
|
153287
|
+
if (!binder.parameters) {
|
|
153288
|
+
throw std::runtime_error("Unexpected prepared parameter. This type of statement can't be prepared!");
|
|
153289
|
+
}
|
|
153256
153290
|
binder.parameters->push_back(bound_parameter.get());
|
|
153257
153291
|
return BindResult(move(bound_parameter));
|
|
153258
153292
|
}
|
|
@@ -171297,7 +171331,7 @@ void LocalTableStorage::InitializeScan(LocalScanState &state, TableFilterSet *ta
|
|
|
171297
171331
|
// nothing to scan
|
|
171298
171332
|
return;
|
|
171299
171333
|
}
|
|
171300
|
-
state.SetStorage(
|
|
171334
|
+
state.SetStorage(shared_from_this());
|
|
171301
171335
|
|
|
171302
171336
|
state.chunk_index = 0;
|
|
171303
171337
|
state.max_index = collection.ChunkCount() - 1;
|
|
@@ -171321,12 +171355,12 @@ LocalScanState::~LocalScanState() {
|
|
|
171321
171355
|
SetStorage(nullptr);
|
|
171322
171356
|
}
|
|
171323
171357
|
|
|
171324
|
-
void LocalScanState::SetStorage(LocalTableStorage
|
|
171325
|
-
if (storage
|
|
171358
|
+
void LocalScanState::SetStorage(shared_ptr<LocalTableStorage> new_storage) {
|
|
171359
|
+
if (storage) {
|
|
171326
171360
|
D_ASSERT(storage->active_scans > 0);
|
|
171327
171361
|
storage->active_scans--;
|
|
171328
171362
|
}
|
|
171329
|
-
storage = new_storage;
|
|
171363
|
+
storage = move(new_storage);
|
|
171330
171364
|
if (storage) {
|
|
171331
171365
|
storage->active_scans++;
|
|
171332
171366
|
}
|
|
@@ -171440,7 +171474,7 @@ void LocalStorage::Append(DataTable *table, DataChunk &chunk) {
|
|
|
171440
171474
|
auto entry = table_storage.find(table);
|
|
171441
171475
|
LocalTableStorage *storage;
|
|
171442
171476
|
if (entry == table_storage.end()) {
|
|
171443
|
-
auto new_storage =
|
|
171477
|
+
auto new_storage = make_shared<LocalTableStorage>(*table);
|
|
171444
171478
|
storage = new_storage.get();
|
|
171445
171479
|
table_storage.insert(make_pair(table, move(new_storage)));
|
|
171446
171480
|
} else {
|
package/src/duckdb.hpp
CHANGED
|
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
13
|
#define DUCKDB_AMALGAMATION_EXTENDED 1
|
|
14
|
-
#define DUCKDB_SOURCE_ID "
|
|
15
|
-
#define DUCKDB_VERSION "v0.3.3-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "dece0efa7"
|
|
15
|
+
#define DUCKDB_VERSION "v0.3.3-dev1393"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -10172,6 +10172,12 @@ public:
|
|
|
10172
10172
|
}
|
|
10173
10173
|
};
|
|
10174
10174
|
|
|
10175
|
+
class GlobalOperatorState {
|
|
10176
|
+
public:
|
|
10177
|
+
virtual ~GlobalOperatorState() {
|
|
10178
|
+
}
|
|
10179
|
+
};
|
|
10180
|
+
|
|
10175
10181
|
class GlobalSinkState {
|
|
10176
10182
|
public:
|
|
10177
10183
|
GlobalSinkState() : state(SinkFinalizeType::READY) {
|
|
@@ -10225,6 +10231,8 @@ public:
|
|
|
10225
10231
|
idx_t estimated_cardinality;
|
|
10226
10232
|
//! The global sink state of this operator
|
|
10227
10233
|
unique_ptr<GlobalSinkState> sink_state;
|
|
10234
|
+
//! The global state of this operator
|
|
10235
|
+
unique_ptr<GlobalOperatorState> op_state;
|
|
10228
10236
|
|
|
10229
10237
|
public:
|
|
10230
10238
|
virtual string GetName() const;
|
|
@@ -10246,8 +10254,9 @@ public:
|
|
|
10246
10254
|
public:
|
|
10247
10255
|
// Operator interface
|
|
10248
10256
|
virtual unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const;
|
|
10257
|
+
virtual unique_ptr<GlobalOperatorState> GetGlobalOperatorState(ClientContext &context) const;
|
|
10249
10258
|
virtual OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
10250
|
-
OperatorState &state) const;
|
|
10259
|
+
GlobalOperatorState &gstate, OperatorState &state) const;
|
|
10251
10260
|
|
|
10252
10261
|
virtual bool ParallelOperator() const {
|
|
10253
10262
|
return false;
|
|
@@ -10630,7 +10639,7 @@ class Pipeline : public std::enable_shared_from_this<Pipeline> {
|
|
|
10630
10639
|
friend class PipelineFinishEvent;
|
|
10631
10640
|
|
|
10632
10641
|
public:
|
|
10633
|
-
Pipeline(Executor &execution_context);
|
|
10642
|
+
explicit Pipeline(Executor &execution_context);
|
|
10634
10643
|
|
|
10635
10644
|
Executor &executor;
|
|
10636
10645
|
|
|
@@ -14435,9 +14444,9 @@ struct ColumnFetchState {
|
|
|
14435
14444
|
struct LocalScanState {
|
|
14436
14445
|
~LocalScanState();
|
|
14437
14446
|
|
|
14438
|
-
void SetStorage(LocalTableStorage
|
|
14447
|
+
void SetStorage(shared_ptr<LocalTableStorage> storage);
|
|
14439
14448
|
LocalTableStorage *GetStorage() {
|
|
14440
|
-
return storage;
|
|
14449
|
+
return storage.get();
|
|
14441
14450
|
}
|
|
14442
14451
|
|
|
14443
14452
|
idx_t chunk_index;
|
|
@@ -14446,7 +14455,7 @@ struct LocalScanState {
|
|
|
14446
14455
|
TableFilterSet *table_filters;
|
|
14447
14456
|
|
|
14448
14457
|
private:
|
|
14449
|
-
LocalTableStorage
|
|
14458
|
+
shared_ptr<LocalTableStorage> storage;
|
|
14450
14459
|
};
|
|
14451
14460
|
|
|
14452
14461
|
class RowGroupScanState {
|
|
@@ -14507,7 +14516,7 @@ class DataTable;
|
|
|
14507
14516
|
class WriteAheadLog;
|
|
14508
14517
|
struct TableAppendState;
|
|
14509
14518
|
|
|
14510
|
-
class LocalTableStorage {
|
|
14519
|
+
class LocalTableStorage : public std::enable_shared_from_this<LocalTableStorage> {
|
|
14511
14520
|
public:
|
|
14512
14521
|
explicit LocalTableStorage(DataTable &table);
|
|
14513
14522
|
~LocalTableStorage();
|
|
@@ -14590,7 +14599,7 @@ private:
|
|
|
14590
14599
|
|
|
14591
14600
|
private:
|
|
14592
14601
|
Transaction &transaction;
|
|
14593
|
-
unordered_map<DataTable *,
|
|
14602
|
+
unordered_map<DataTable *, shared_ptr<LocalTableStorage>> table_storage;
|
|
14594
14603
|
|
|
14595
14604
|
void Flush(DataTable &table, LocalTableStorage &storage);
|
|
14596
14605
|
};
|