amorynan commented on code in PR #32620:
URL: https://github.com/apache/doris/pull/32620#discussion_r1554888659
##########
be/src/vec/exprs/vexpr_context.h:
##########
@@ -69,6 +70,21 @@ class VExprContext {
return _fn_contexts[i].get();
}
+ // execute expr with inverted index which column a, b has inverted indexes
+ // but some situation although column b has indexes, but apply index is
not useful, we should
+ // skip this expr, just do not apply index anymore.
+ /**
+ * @param colId_invertedIndexIter_mapping contains all column id to
inverted index iterator mapping from segmentIterator
+ * @param num_rows number of rows in one segment.
+ * @param bitmap roaring bitmap to store the result. 0 is present filed by
index.
+ * @return status not ok means execute failed.
+ */
+ [[nodiscard]] Status eval_inverted_indexs(
+ const std::unordered_map<ColumnId,
std::pair<vectorized::NameAndTypePair,
+
segment_v2::InvertedIndexIterator*>>&
+ colId_invertedIndexIter_mapping,
Review Comment:
done!
##########
be/src/vec/exprs/vcompound_pred.h:
##########
@@ -53,6 +53,56 @@ class VCompoundPred : public VectorizedFnCall {
const std::string& expr_name() const override { return _expr_name; }
+ bool is_all_ones(const roaring::Roaring& r) {
+ return r.contains(0);
+ for (roaring::RoaringSetBitForwardIterator i = r.begin(); i !=
r.end(); ++i) {
+ if (*i == 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // 1. when meet 'or' conjunct: a or b, if b can apply index, return all
rows, so b should not be extracted
+ // 2. when meet 'and' conjunct, function with column b can not apply
inverted index
+ // eg. a and hash(b)=1, if b can apply index, but hash(b)=1 is not
for index, so b should not be extracted
+ // but a and array_contains(b, 1), b can be applied inverted
index, which b can be extracted
+ Status eval_inverted_index(
+ VExprContext* context,
+ const std::unordered_map<ColumnId,
std::pair<vectorized::NameAndTypePair,
+
segment_v2::InvertedIndexIterator*>>&
+ colId_invertedIndexIter_mapping,
+ uint32_t num_rows, roaring::Roaring* bitmap) const override {
+ if (_op == TExprOpcode::COMPOUND_OR) {
+ for (auto child : _children) {
+ Status st = child->eval_inverted_index(context,
colId_invertedIndexIter_mapping,
+ num_rows, bitmap);
+ if (!st.ok()) {
+ return st;
+ }
+ if (!bitmap->contains(
+ 0)) { // the left expr no need to be extracted by
inverted index
+ return Status::OK();
+ }
+ }
+ } else if (_op == TExprOpcode::COMPOUND_AND) {
+ for (auto child : _children) {
+ Status st = child->eval_inverted_index(context,
colId_invertedIndexIter_mapping,
+ num_rows, bitmap);
+ if (!st.ok()) {
+ return st;
+ }
+ if (bitmap->isEmpty()) { // the left expr no need to be
extracted by inverted index
+ return Status::OK();
+ }
+ }
+ } else {
+ return Status::InternalError(
Review Comment:
done!
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]