gaodayue commented on a change in pull request #2547: [Segment V2] Support lazy 
materialization read
URL: https://github.com/apache/incubator-doris/pull/2547#discussion_r361248603
 
 

 ##########
 File path: be/src/olap/rowset/segment_v2/segment_iterator.cpp
 ##########
 @@ -314,34 +385,28 @@ Status SegmentIterator::_seek_and_peek(rowid_t rowid) {
     // please note that usually RowBlockV2.clear() is called to free MemPool 
memory before reading the next block,
     // but here since there won't be too many keys to seek, we don't call 
RowBlockV2.clear() so that we can use
     // a single MemPool for all seeked keys.
-    RETURN_IF_ERROR(_next_batch(_seek_block.get(), 0, &num_rows));
+    RETURN_IF_ERROR(_read_columns(_seek_schema->column_ids(), 
_seek_block.get(), 0, num_rows));
     _seek_block->set_num_rows(num_rows);
     return Status::OK();
 }
 
-// Trying to read `rows_read` rows into `block` at the given offset.
-// Return the actual number of rows read in `*rows_read`.
-Status SegmentIterator::_next_batch(RowBlockV2* block, size_t row_offset, 
size_t* rows_read) {
-    bool has_read = false;
-    size_t first_read = 0;
-    for (auto cid : block->schema()->column_ids()) {
-        size_t num_rows = has_read ? first_read : *rows_read;
-        auto column_block = block->column_block(cid);
-        ColumnBlockView dst(&column_block, row_offset);
-        RETURN_IF_ERROR(_column_iterators[cid]->next_batch(&num_rows, &dst));
-        block->set_delete_state(column_block.delete_state());
-        if (!has_read) {
-            has_read = true;
-            first_read = num_rows;
-        } else if (num_rows != first_read) {
-            return Status::InternalError(
-                Substitute("Read different rows in different columns"
-                           ", column($0) read $1 vs column($2) read $3",
-                           block->schema()->column_ids()[0], first_read, cid, 
num_rows));
+void SegmentIterator::_init_lazy_materialization() {
+    if (!_col_predicates.empty()) {
+        std::set<ColumnId> predicate_columns;
+        for (auto predicate : _col_predicates) {
+            predicate_columns.insert(predicate->column_id());
+        }
+        // when all return columns have predicates, disable lazy 
materialization to avoid its overhead
+        if (_schema.column_ids().size() > predicate_columns.size()) {
+            _lazy_materialization_read = true;
 
 Review comment:
   ok

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to