Tanya-W commented on code in PR #14211: URL: https://github.com/apache/doris/pull/14211#discussion_r1058120491
########## be/src/olap/rowset/segment_v2/segment_iterator.cpp: ########## @@ -373,6 +382,55 @@ Status SegmentIterator::_apply_bitmap_index() { return Status::OK(); } +Status SegmentIterator::_apply_inverted_index() { + std::vector<ColumnPredicate*> remaining_predicates; + + for (auto pred : _col_predicates) { + int32_t unique_id = _schema.unique_id(pred->column_id()); + if (_inverted_index_iterators.count(unique_id) < 1 || + _inverted_index_iterators[unique_id] == nullptr) { + // 1. this column no inverted index + remaining_predicates.push_back(pred); + } else { + roaring::Roaring bitmap = _row_bitmap; + Status res = pred->evaluate(_schema, _inverted_index_iterators[unique_id], num_rows(), &bitmap); + if (!res.ok()) { + LOG(WARNING) << "failed to evaluate index" + << ", column predicate type: " << pred->pred_type_string(pred->type()) + << ", error msg: " << res.get_error_msg(); + return res; + } + + std::string pred_sign = _gen_predicate_sign(pred); + auto pred_type = pred->type(); + if (pred_type == PredicateType::MATCH) { + _rowid_result_for_index.emplace( + std::make_pair(pred_sign, std::make_pair(false, bitmap))); + } + + _row_bitmap &= bitmap; + if (_row_bitmap.isEmpty()) { + break; // all rows have been pruned, no need to process further predicates + } + } + } + _col_predicates = std::move(remaining_predicates); + return Status::OK(); +} + +std::string SegmentIterator::_gen_predicate_sign(ColumnPredicate* predicate) { Review Comment: _gen_predicate_result_sign maybe better -- 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-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org