Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
[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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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) { | ||
| 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; | ||
Uh oh!
There was an error while loading. Please reload this page.
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,而不是写多个函数呢?