HappenLee commented on code in PR #71229:
URL: https://github.com/apache/doris/pull/71229#discussion_r4765415180


##########
be/src/storage/segment/segment_iterator.cpp:
##########
@@ -3027,8 +3030,26 @@ Status SegmentIterator::_read_columns_by_rowids(const 
std::vector<ColumnId>& rea
                                      ? ColumnIterator::ReadPhase::PREDICATE
                                      : ColumnIterator::ReadPhase::NORMAL};
 
-        RETURN_IF_ERROR(
-                column_iter->read_by_rowids(rowids.data(), select_size, 
_current_columns[cid]));
+        auto& dst = _current_columns[cid];
+        if (continuous) {
+            // The sequential reader advances across pages after a single 
ordinal seek.
+            ++_opts.stats->block_lazy_read_seek_num;
+            if (_opts.runtime_state && _opts.runtime_state->enable_profile()) {
+                SCOPED_RAW_TIMER(&_opts.stats->block_lazy_read_seek_ns);
+                RETURN_IF_ERROR(column_iter->seek_to_ordinal(rowids.front()));
+            } else {
+                RETURN_IF_ERROR(column_iter->seek_to_ordinal(rowids.front()));
+            }
+
+            size_t rows_read = select_size;
+            RETURN_IF_ERROR(column_iter->next_batch(&rows_read, dst));

Review Comment:
   **[P1] Keep the row-ID read path for Variant iterators that share a 
sparse-column cache.**
   
   A predicate subcolumn and a deferred output subcolumn can share a 
`BinaryColumnCache` when both come from the same sparse bucket. If the 
predicate read caches four rows starting at ordinal 100 and the filter keeps 
only `[100, 101]`, this branch seeks back to 100 and requests two rows. 
`BinaryColumnCache::seek_to_ordinal()` reuses the sequential cache at the same 
starting ordinal, and `next_batch()` overwrites the requested count with the 
cached length of four. This reaches the new row-count error. The existing 
`read_by_rowids()` path includes the count and row IDs in its cache match, so 
it returns the requested two rows. I verified the count mismatch by exercising 
the cache with a minimal reader. [Cache 
implementation](https://github.com/apache/doris/blob/0ce2f7030d4e318e703337d89e26a60768cb8a8a/be/src/storage/segment/variant/variant_column_reader.h#L114-L150)
   
   Could we restrict the fast path to the file iterators verified to support 
this switch and keep Variant on `read_by_rowids()`? If we want to enable it for 
Variant too, please add a regression with two subpaths in the same sparse 
bucket and a filter that keeps a contiguous prefix of the input batch.



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