HappenLee commented on code in PR #63279:
URL: https://github.com/apache/doris/pull/63279#discussion_r3256120835
##########
be/src/storage/segment/segment_iterator.cpp:
##########
@@ -107,11 +108,108 @@
#include "storage/utils.h"
#include "util/concurrency_stats.h"
#include "util/defer_op.h"
+#include "util/json/path_in_data.h"
#include "util/simd/bits.h"
namespace doris {
using namespace ErrorCode;
namespace segment_v2 {
+namespace {
+
+Status tablet_column_id_by_slot(const TabletSchemaSPtr& tablet_schema, const
SlotDescriptor* slot,
+ ColumnId* cid) {
+ int32_t field_index = -1;
+ if (slot->type()->get_primitive_type() == PrimitiveType::TYPE_VARIANT) {
+ field_index = tablet_schema->field_index(
+
PathInData(tablet_schema->column_by_uid(slot->col_unique_id()).name_lower_case(),
+ slot->column_paths()));
+ } else {
+ field_index = slot->col_unique_id() >= 0 ?
tablet_schema->field_index(slot->col_unique_id())
+ :
tablet_schema->field_index(slot->col_name());
+ }
+ if (field_index < 0) {
+ return Status::InternalError(
+ "field name is invalid. field={}, field_name_to_index={},
col_unique_id={}",
+ slot->col_name(), tablet_schema->get_all_field_names(),
slot->col_unique_id());
+ }
+ *cid = field_index;
+ return Status::OK();
+}
+
+Status rebind_storage_expr_to_reader_schema(
+ const StorageReadOptions& opts, const VExprSPtr& expr,
+ const std::unordered_map<ColumnId, size_t>& cid_to_pos) {
+ DORIS_CHECK(expr != nullptr);
+
+ if (expr->is_slot_ref()) {
+ auto slot_ref = std::static_pointer_cast<VSlotRef>(expr);
+ auto* slot =
opts.runtime_state->desc_tbl().get_slot_descriptor(slot_ref->slot_id());
+ if (slot == nullptr) {
+ return Status::InternalError("slot {} is not found in descriptor
table",
+ slot_ref->slot_id());
+ }
+
+ ColumnId cid = 0;
+ RETURN_IF_ERROR(tablet_column_id_by_slot(opts.tablet_schema, slot,
&cid));
+ auto pos_it = cid_to_pos.find(cid);
+ if (pos_it == cid_to_pos.end()) {
+ return Status::InternalError("slot {} column {} with cid {} is not
in reader schema",
+ slot_ref->slot_id(),
slot->col_name(), cid);
+ }
+ slot_ref->set_column_id(cast_set<int>(pos_it->second));
+ } else if (expr->is_virtual_slot_ref()) {
+ auto virtual_slot_ref = std::static_pointer_cast<VirtualSlotRef>(expr);
+ auto* slot =
+
opts.runtime_state->desc_tbl().get_slot_descriptor(virtual_slot_ref->slot_id());
+ if (slot == nullptr) {
+ return Status::InternalError("slot {} is not found in descriptor
table",
+ virtual_slot_ref->slot_id());
+ }
+
+ ColumnId cid = 0;
+ RETURN_IF_ERROR(tablet_column_id_by_slot(opts.tablet_schema, slot,
&cid));
+ auto pos_it = cid_to_pos.find(cid);
+ if (pos_it == cid_to_pos.end()) {
+ return Status::InternalError(
+ "virtual slot {} column {} with cid {} is not in reader
schema",
+ virtual_slot_ref->slot_id(), slot->col_name(), cid);
+ }
+ virtual_slot_ref->set_column_id(cast_set<int>(pos_it->second));
+ RETURN_IF_ERROR(rebind_storage_expr_to_reader_schema(
+ opts, virtual_slot_ref->get_virtual_column_expr(),
cid_to_pos));
+ }
+
+ for (const auto& child : expr->children()) {
+ RETURN_IF_ERROR(rebind_storage_expr_to_reader_schema(opts, child,
cid_to_pos));
+ }
+ return Status::OK();
+}
+
+Status rebind_storage_exprs_to_reader_schema(const StorageReadOptions& opts,
const Schema& schema,
+ const VExprContextSPtrs&
common_exprs,
+ std::map<ColumnId,
VExprContextSPtr>& virtual_exprs) {
+ if (common_exprs.empty() && virtual_exprs.empty()) {
Review Comment:
这里能直接判断出来是不是DUP或者是MOW吗?也可以直接return
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]