zhannngchen commented on code in PR #11057:
URL: https://github.com/apache/doris/pull/11057#discussion_r928913088


##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -444,6 +458,36 @@ Status SegmentIterator::_lookup_ordinal(const RowCursor& 
key, bool is_include, r
     return Status::OK();
 }
 
+Status SegmentIterator::_lookup_ordinal_from_pk_index(const RowCursor& key, 
bool is_include,
+                                                      rowid_t* rowid) {
+    DCHECK(_segment->_tablet_schema.keys_type() == UNIQUE_KEYS);
+    const PrimaryKeyIndexReader* pk_index_reader = 
_segment->get_primary_key_index();
+    DCHECK(pk_index_reader != nullptr);
+
+    std::string index_key;
+    encode_key_with_padding<RowCursor, true, true>(
+            &index_key, key, _segment->_tablet_schema.num_key_columns(), 
is_include);
+    bool exact_match = false;
+
+    std::unique_ptr<segment_v2::IndexedColumnIterator> index_iterator;
+    RETURN_IF_ERROR(pk_index_reader->new_iterator(&index_iterator));
+
+    Status status = index_iterator->seek_at_or_after(&index_key, &exact_match);
+    if (UNLIKELY(!status.ok())) {
+        *rowid = num_rows();
+        if (status.is_not_found()) {
+            return Status::OK();
+        }
+        return status;
+    }
+    *rowid = index_iterator->get_current_ordinal();
+
+    if (exact_match && !is_include) {

Review Comment:
   Add some comment here.



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