-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[refactor](topn) Refactor topn filter push down #59005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,16 +55,31 @@ RuntimePredicate::RuntimePredicate(const TTopnFilterDesc& desc) | |
| : create_comparison_predicate0<PredicateType::GE>; | ||
| } | ||
|
|
||
| void RuntimePredicate::init_target( | ||
| int32_t target_node_id, phmap::flat_hash_map<int, SlotDescriptor*> slot_id_to_slot_desc) { | ||
| Status RuntimePredicate::init_target( | ||
| int32_t target_node_id, phmap::flat_hash_map<int, SlotDescriptor*> slot_id_to_slot_desc, | ||
| const doris::RowDescriptor& desc) { | ||
| std::unique_lock<std::shared_mutex> wlock(_rwlock); | ||
| check_target_node_id(target_node_id); | ||
| if (target_is_slot(target_node_id)) { | ||
| _contexts[target_node_id].col_name = | ||
| slot_id_to_slot_desc[get_texpr(target_node_id).nodes[0].slot_ref.slot_id] | ||
| ->col_name(); | ||
| auto slot_id = get_texpr(target_node_id).nodes[0].slot_ref.slot_id; | ||
| auto column_id = desc.get_column_id(slot_id); | ||
| if (column_id < 0) { | ||
| return Status::Error<ErrorCode::INTERNAL_ERROR>( | ||
| "RuntimePredicate has invalid slot id: {}, name: {}, desc: {}, slot_desc: {}", | ||
| slot_id, | ||
| slot_id_to_slot_desc[get_texpr(target_node_id).nodes[0].slot_ref.slot_id] | ||
| ->col_name(), | ||
| desc.debug_string(), | ||
| slot_id_to_slot_desc[get_texpr(target_node_id).nodes[0].slot_ref.slot_id] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我们这个可能不对,之前的可能是对的 |
||
| ->debug_string()); | ||
| } | ||
| _contexts[target_node_id].predicate = SharedPredicate::create_shared(column_id); | ||
| } | ||
| _detected_target = true; | ||
| return Status::OK(); | ||
| } | ||
|
|
||
| StringRef RuntimePredicate::_get_string_ref(const Field& field, const PrimitiveType type) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,8 +44,9 @@ class RuntimePredicate { | |
| public: | ||
| RuntimePredicate(const TTopnFilterDesc& desc); | ||
|
|
||
| void init_target(int32_t target_node_id, | ||
| phmap::flat_hash_map<int, SlotDescriptor*> slot_id_to_slot_desc); | ||
| Status init_target(int32_t target_node_id, | ||
| phmap::flat_hash_map<int, SlotDescriptor*> slot_id_to_slot_desc, | ||
| const doris::RowDescriptor& desc); | ||
|
|
||
| bool enable() const { | ||
| // when sort node and scan node are not in the same fragment, predicate will be disabled | ||
|
|
@@ -66,9 +67,10 @@ class RuntimePredicate { | |
| } | ||
| RETURN_IF_ERROR(tablet_schema->have_column(_contexts[target_node_id].col_name)); | ||
| _contexts[target_node_id].tablet_schema = tablet_schema; | ||
| int64_t index = DORIS_TRY(_contexts[target_node_id].get_field_index()) | ||
| _contexts[target_node_id] | ||
| .predicate = SharedPredicate::create_shared(index); | ||
| int64_t index = DORIS_TRY(_contexts[target_node_id].get_field_index()); | ||
| DCHECK(_contexts[target_node_id].predicate != nullptr); | ||
| assert_cast<SharedPredicate*>(_contexts[target_node_id].predicate.get()) | ||
| ->set_column_id(cast_set<uint32_t>(index)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里为什么要setcolumnid? |
||
| return Status::OK(); | ||
| } | ||
|
|
||
|
|
@@ -130,6 +132,7 @@ class RuntimePredicate { | |
| struct TargetContext { | ||
| TExpr expr; | ||
| std::string col_name; | ||
| // TODO(gabriel): remove this | ||
| TabletSchemaSPtr tablet_schema; | ||
| std::shared_ptr<ColumnPredicate> predicate; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们为什么在一个函数里,定义这么多lambda,而不是写多个函数呢?