yiguolei commented on code in PR #66472:
URL: https://github.com/apache/doris/pull/66472#discussion_r3765306345


##########
be/src/storage/segment/segment_iterator.cpp:
##########
@@ -751,63 +736,56 @@ Status SegmentIterator::_get_row_ranges_by_keys() {
 
 // Set up environment for the following seek.
 Status SegmentIterator::_prepare_seek(const StorageReadOptions::KeyRange& 
key_range) {
-    std::vector<const TabletColumn*> key_columns;
-    std::set<uint32_t> column_set;
-    if (key_range.lower_key != nullptr) {
-        for (auto cid : key_range.lower_key->schema()->column_ids()) {
-            column_set.emplace(cid);
-            key_columns.emplace_back(key_range.lower_key->column(cid));
-        }
-    }
-    if (key_range.upper_key != nullptr) {
-        for (auto cid : key_range.upper_key->schema()->column_ids()) {
-            if (column_set.count(cid) == 0) {
-                key_columns.emplace_back(key_range.upper_key->column(cid));
-                column_set.emplace(cid);
-            }
-        }
+    // Both bound keys carry a dense prefix of the tablet key columns,
+    const doris::ReadSchema* key_schema =
+            key_range.lower_key != nullptr ? key_range.lower_key->schema() : 
nullptr;
+    if (key_range.upper_key != nullptr &&
+        (key_schema == nullptr ||
+         key_range.upper_key->schema()->num_read_columns() > 
key_schema->num_read_columns())) {
+        key_schema = key_range.upper_key->schema();
+    }
+    if (key_schema == nullptr) {
+        return Status::OK();
     }
     if (!_seek_schema) {
-        std::vector<TabletColumnPtr> cols;
-        cols.reserve(key_columns.size());
-        for (const TabletColumn* col : key_columns) {
-            cols.emplace_back(std::make_shared<TabletColumn>(*col));
-        }
-        std::vector<uint32_t> column_ids(cols.size());
-        std::iota(column_ids.begin(), column_ids.end(), 0);
-        _seek_schema = std::make_unique<Schema>(cols, column_ids);
+        _seek_schema = std::make_unique<ReadSchema>(*key_schema);
     }
     // todo(wb) need refactor here, when using pk to search, _seek_block is 
useless
-    if (_seek_block.size() == 0) {
-        _seek_block.resize(_seek_schema->num_column_ids());
-        int i = 0;
-        for (auto cid : _seek_schema->column_ids()) {
-            auto column_desc = _seek_schema->column(cid);
-            _seek_block[i] = 
Schema::get_data_type_ptr(*column_desc)->create_column();
-            i++;
+    if (_seek_block.empty()) {
+        _seek_block.resize(_seek_schema->num_read_columns());

Review Comment:
   这里跟直接调用seek schema  create read block 什么区别?



-- 
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]

Reply via email to