This is an automated email from the ASF dual-hosted git repository.

eldenmoon pushed a commit to branch variant-sparse
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/variant-sparse by this push:
     new cc4f0d83655 fix[variant] fix base sprase column reader (#49385)
cc4f0d83655 is described below

commit cc4f0d83655fb2c32387b96849607027c7bab434
Author: Sun Chenyang <suncheny...@selectdb.com>
AuthorDate: Mon Mar 24 14:28:02 2025 +0800

    fix[variant] fix base sprase column reader (#49385)
---
 be/src/olap/rowset/segment_v2/hierarchical_data_reader.h | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/be/src/olap/rowset/segment_v2/hierarchical_data_reader.h 
b/be/src/olap/rowset/segment_v2/hierarchical_data_reader.h
index 5ea7ac59ad7..83e9fbcc0e7 100644
--- a/be/src/olap/rowset/segment_v2/hierarchical_data_reader.h
+++ b/be/src/olap/rowset/segment_v2/hierarchical_data_reader.h
@@ -193,10 +193,22 @@ public:
         return _sparse_column_reader->init(opts);
     }
 
+    // When performing compaction, multiple columns are extracted from the 
sparse columns,
+    // and the sparse columns only need to be read once.
+    // So we need to cache the sparse column and reuse it.
+    // The cache is only used when the compaction reader is used.
+    bool has_sparse_column_cache() const {
+        return _read_opts && 
_read_opts->sparse_column_cache[_col.parent_unique_id()] &&
+               
ColumnReader::is_compaction_reader_type(_read_opts->io_ctx.reader_type);
+    }
+
     // Standard seek implementations
     Status seek_to_first() override { return 
_sparse_column_reader->seek_to_first(); }
 
     Status seek_to_ordinal(ordinal_t ord) override {
+        if (has_sparse_column_cache()) {
+            return Status::OK();
+        }
         return _sparse_column_reader->seek_to_ordinal(ord);
     }
 
@@ -209,14 +221,14 @@ public:
     Status _process_batch(ReadMethod&& read_method, size_t nrows,
                           vectorized::MutableColumnPtr& dst) {
         // Cache check and population logic
-        if (_read_opts && 
_read_opts->sparse_column_cache[_col.parent_unique_id()] &&
-            
ColumnReader::is_compaction_reader_type(_read_opts->io_ctx.reader_type)) {
+        if (has_sparse_column_cache()) {
             _sparse_column =
                     
_read_opts->sparse_column_cache[_col.parent_unique_id()]->assume_mutable();
         } else {
             _sparse_column->clear();
             RETURN_IF_ERROR(read_method());
 
+            // cache the sparse column
             if (_read_opts) {
                 _read_opts->sparse_column_cache[_col.parent_unique_id()] =
                         _sparse_column->get_ptr();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to