You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/04/25 08:36:38 UTC

[GitHub] [incubator-doris] zenoyang commented on a diff in pull request #8834: [refactor]refactor lazy materialized

zenoyang commented on code in PR #8834:
URL: https://github.com/apache/incubator-doris/pull/8834#discussion_r857385501


##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -937,48 +969,48 @@ Status SegmentIterator::next_batch(vectorized::Block* block) {
         return Status::EndOfFile("no more data in segment");
     }
 
-    // when no predicate(include delete condition) is provided, output column directly
-    if (_vec_pred_column_ids.empty() && _short_cir_pred_column_ids.empty()) {
+    if (!_is_need_vec_eval && !_is_need_short_eval) {
         _output_non_pred_columns(block);
-    } else { // need predicate evaluation
+    } else {
         uint16_t selected_size = nrows_read;
         uint16_t sel_rowid_idx[selected_size];
 
         // step 1: evaluate vectorization predicate
         _evaluate_vectorization_predicate(sel_rowid_idx, selected_size);
 
-        // When predicate column and no-predicate column are both basic type, lazy materialization is eliminate
-        // So output block directly after vectorization evaluation
-        if (_is_all_column_basic_type) {
-            RETURN_IF_ERROR(_output_column_by_sel_idx(block, _first_read_column_ids, sel_rowid_idx,
-                                                      selected_size));
-        } else {
-            // step 2: evaluate short ciruit predicate
-            // todo(wb) research whether need to read short predicate after vectorization evaluation
-            //          to reduce cost of read short circuit columns.
-            //          In SSB test, it make no difference; So need more scenarios to test
-            _evaluate_short_circuit_predicate(sel_rowid_idx, &selected_size);
-
-            // step3: read non_predicate column
-            if (!_non_predicate_columns.empty()) {
-                _read_columns_by_rowids(_non_predicate_columns, _block_rowids, sel_rowid_idx,
-                                        selected_size, &_current_return_columns);
+        // step 2: evaluate short ciruit predicate
+        // todo(wb) research whether need to read short predicate after vectorization evaluation
+        //          to reduce cost of read short circuit columns.
+        //          In SSB test, it make no difference; So need more scenarios to test
+        _evaluate_short_circuit_predicate(sel_rowid_idx, &selected_size);
+
+        if (!_lazy_materialization_read) {
+            Status ret = _output_column_by_sel_idx(block, _first_read_column_ids, sel_rowid_idx,
+                                                      selected_size);
+            if (!ret.ok()) {
+                return ret;
             }
+            // shrink char_type suffix zero data
+            block->shrink_char_type_column_suffix_zero(_char_type_idx);
+            return ret;
+        }
 
-            // step4: output columns
-            // 4.1 output non-predicate column
-            _output_non_pred_columns(block);
+        // step3: read non_predicate column
+        _read_columns_by_rowids(_non_predicate_columns, _block_rowids, sel_rowid_idx,
+                                        selected_size, &_current_return_columns);
 
-            // 4.2 get union of short_cir_pred and vec_pred
-            std::set<ColumnId> pred_column_ids;
-            pred_column_ids.insert(_short_cir_pred_column_ids.begin(),
-                                   _short_cir_pred_column_ids.end());
-            pred_column_ids.insert(_vec_pred_column_ids.begin(), _vec_pred_column_ids.end());
+        // step4: output columns
+        // 4.1 output non-predicate column
+        _output_non_pred_columns(block);
 
-            // 4.3 output short circuit and predicate column
-            RETURN_IF_ERROR(_output_column_by_sel_idx(block, pred_column_ids, sel_rowid_idx,
-                                                      selected_size));
-        }
+        // 4.2 get union of short_cir_pred and vec_pred
+        std::set<ColumnId> pred_column_ids;
+        pred_column_ids.insert(_short_cir_pred_column_ids.begin(), _short_cir_pred_column_ids.end());
+        pred_column_ids.insert(_vec_pred_column_ids.begin(), _vec_pred_column_ids.end());
+
+        // 4.3 output short circuit and predicate column
+        RETURN_IF_ERROR(_output_column_by_sel_idx(block, pred_column_ids, sel_rowid_idx,
+                                                    selected_size));

Review Comment:
   Executed here, it means that `_lazy_materialization_read` is true, then `pred_column_ids` can be replaced by `_first_read_column_ids`, and the above three lines can be deleted.



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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