imay commented on a change in pull request #1633: add zone map page(#1390)
URL: https://github.com/apache/incubator-doris/pull/1633#discussion_r313282796
 
 

 ##########
 File path: be/src/olap/rowset/segment_v2/segment_iterator.cpp
 ##########
 @@ -114,6 +119,80 @@ Status SegmentIterator::_prepare_seek() {
     return Status::OK();
 }
 
+Status SegmentIterator::_init_row_ranges() {
+    if (_lower_rowid == _upper_rowid) {
+        // no data return;
+        _row_ranges = RowRanges();
+        return Status::OK();
+    }
+    // short key range is [_lower_rowid, _upper_rowid)
+    RowRanges 
short_key_row_ranges(std::move(RowRanges::create_single(_lower_rowid, 
_upper_rowid)));
+    if (_opts.conditions != nullptr) {
+        RETURN_IF_ERROR(_get_row_ranges_from_zone_map());
+        // TODO(hkp): get row ranges from bloom filter and secondary index
+        RowRanges::ranges_intersection(_row_ranges, short_key_row_ranges, 
&_row_ranges);
+    } else {
+        _row_ranges = std::move(short_key_row_ranges);
+    }
+
+    if (_row_ranges.has_next()) {
+        _row_ranges.next();
+        _cur_rowid = _row_ranges.current_range_from();
+    }
+
+    // TODO(hkp): calculate filter rate to decide whether to
+    // use zone map/bloom filter/secondary index or not.
+    return Status::OK();
+}
+
+Status SegmentIterator::_get_row_ranges_from_zone_map() {
+    Conditions* conditions = _opts.conditions;
+    for (auto& column_condition : conditions->columns()) {
+        int32_t column_id = column_condition.first;
+        // get row ranges from zone map
+        const ColumnZoneMap* column_zone_map = 
_segment->_column_readers[column_id]->get_zone_map();
+        if (column_zone_map == nullptr) {
+            // there is no zone map for this column
+            continue;
+        }
+        std::vector<uint32_t> page_indexes;
+        const TypeInfo* type_info = 
_segment->_column_readers[column_id]->type_info();
+        _get_filtered_pages(type_info->type(), column_zone_map, 
column_condition.second, &page_indexes);
 
 Review comment:
   If we don't check _get_filtered_pages's return, just return void

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to