Skip to content

Commit

Permalink
[exec](set_operation) Support one child node in set operation
Browse files Browse the repository at this point in the history
  • Loading branch information
HappenLee committed Aug 2, 2023
1 parent 527782f commit dbb5ebf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions be/src/vec/exec/vset_operation_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ Status VSetOperationNode<is_intersect>::alloc_resource(RuntimeState* state) {
for (const VExprContextSPtrs& exprs : _child_expr_lists) {
RETURN_IF_ERROR(VExpr::open(exprs, state));
}
_probe_columns.resize(_child_expr_lists[1].size());
// Add the if check only for compatible with old optimiser
if (_child_expr_lists.size() > 1) {
_probe_columns.resize(_child_expr_lists[1].size());
}
return Status::OK();
}

Expand Down Expand Up @@ -326,8 +329,8 @@ void VSetOperationNode<is_intersect>::hash_table_init() {
bool has_null = false;
int key_byte_size = 0;

_probe_key_sz.resize(_child_expr_lists[1].size());
_build_key_sz.resize(_child_expr_lists[0].size());
_probe_key_sz.resize(_child_expr_lists[0].size());
for (int i = 0; i < _child_expr_lists[0].size(); ++i) {
const auto vexpr = _child_expr_lists[0][i]->root();
const auto& data_type = vexpr->data_type();
Expand Down Expand Up @@ -407,6 +410,7 @@ Status VSetOperationNode<is_intersect>::sink(RuntimeState* state, Block* block,
*_hash_table_variants);
}
_build_finished = true;
_finalize_probe(0);
}
}
return Status::OK();
Expand Down Expand Up @@ -530,11 +534,14 @@ Status VSetOperationNode<is_intersect>::sink_probe(RuntimeState* state, int chil
*_hash_table_variants));
}

return eos ? finalize_probe(state, child_id) : Status::OK();
if (eos) {
_finalize_probe(child_id);
}
return Status::OK();
}

template <bool is_intersect>
Status VSetOperationNode<is_intersect>::finalize_probe(RuntimeState* /*state*/, int child_id) {
void VSetOperationNode<is_intersect>::_finalize_probe(int child_id) {
if (child_id != (_children.size() - 1)) {
refresh_hash_table();
if constexpr (is_intersect) {
Expand All @@ -554,7 +561,6 @@ Status VSetOperationNode<is_intersect>::finalize_probe(RuntimeState* /*state*/,
_can_read = true;
}
_probe_finished_children_index[child_id] = true;
return Status::OK();
}

template <bool is_intersect>
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/exec/vset_operation_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class VSetOperationNode final : public ExecNode {
Status pull(RuntimeState* state, Block* output_block, bool* eos) override;

Status sink_probe(RuntimeState* state, int child_id, Block* block, bool eos);
Status finalize_probe(RuntimeState* state, int child_id);

bool is_child_finished(int child_id) const;

private:
void _finalize_probe(int child_id);
//Todo: In build process of hashtable, It's same as join node.
//It's time to abstract out the same methods and provide them directly to others;
void hash_table_init();
Expand Down

0 comments on commit dbb5ebf

Please sign in to comment.