Skip to content

Commit

Permalink
[Refact](inverted index) refact inverted index compound predicates ev…
Browse files Browse the repository at this point in the history
…aluate logic
  • Loading branch information
airborne12 committed Aug 6, 2024
1 parent 27f2f8e commit 1fe5ce7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
17 changes: 5 additions & 12 deletions be/src/olap/rowset/segment_v2/inverted_index_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ class InvertedIndexResultBitmap {
private:
std::shared_ptr<roaring::Roaring> _data_bitmap;
std::shared_ptr<roaring::Roaring> _null_bitmap;

public:
// Default constructor
InvertedIndexResultBitmap()
: _data_bitmap(nullptr),
_null_bitmap(nullptr) {}
InvertedIndexResultBitmap() : _data_bitmap(nullptr), _null_bitmap(nullptr) {}

// Constructor with arguments
InvertedIndexResultBitmap(std::shared_ptr<roaring::Roaring> data_bitmap,
Expand Down Expand Up @@ -157,18 +156,12 @@ class InvertedIndexResultBitmap {
return *this;
}

std::shared_ptr<roaring::Roaring> get_data_bitmap() {
return _data_bitmap;
}
std::shared_ptr<roaring::Roaring> get_data_bitmap() { return _data_bitmap; }

std::shared_ptr<roaring::Roaring> get_null_bitmap() {
return _null_bitmap;
}
std::shared_ptr<roaring::Roaring> get_null_bitmap() { return _null_bitmap; }

// Check if both bitmaps are empty
bool is_empty() const {
return (_data_bitmap == nullptr && _null_bitmap == nullptr);
}
bool is_empty() const { return (_data_bitmap == nullptr && _null_bitmap == nullptr); }
};

class InvertedIndexReader : public std::enable_shared_from_this<InvertedIndexReader> {
Expand Down
3 changes: 2 additions & 1 deletion be/src/olap/rowset/segment_v2/segment_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2749,7 +2749,8 @@ void SegmentIterator::_output_index_result_column_for_expr(uint16_t* sel_rowid_i
auto inverted_index_result_column_for_exprs = expr_ctx->get_inverted_index_result_column();
for (auto& inverted_index_result_bitmap_for_expr : inverted_index_result_bitmap_for_exprs) {
const auto* expr = inverted_index_result_bitmap_for_expr.first;
auto index_result_bitmap = inverted_index_result_bitmap_for_expr.second.get_data_bitmap();
auto index_result_bitmap =
inverted_index_result_bitmap_for_expr.second.get_data_bitmap();
auto index_result_column = vectorized::ColumnUInt8::create();
vectorized::ColumnUInt8::Container& vec_match_pred = index_result_column->get_data();
vec_match_pred.resize(block->rows());
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/exprs/vectorized_fn_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Status VectorizedFnCall::evaluate_inverted_index(VExprContext* context,
}
RETURN_IF_ERROR(_function->evaluate_inverted_index(arguments, storage_name_type, iter,
segment_num_rows, result_bitmap));
*result_bitmap.data_bitmap -= *result_bitmap.null_bitmap;
//*result_bitmap.data_bitmap -= *result_bitmap.null_bitmap;
context->set_inverted_index_result_for_expr(this, result_bitmap);
} else {
return Status::NotSupported("we can only eval inverted index for slot ref expr, but got ",
Expand Down
6 changes: 4 additions & 2 deletions be/src/vec/functions/array/function_array_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ class FunctionArrayIndex : public IFunction {
segment_v2::InvertedIndexQueryCacheHandle null_bitmap_cache_handle;
RETURN_IF_ERROR(iter->read_null_bitmap(&null_bitmap_cache_handle));
std::shared_ptr<roaring::Roaring> null_bitmap = null_bitmap_cache_handle.get_bitmap();
bitmap_result.null_bitmap = std::move(null_bitmap);
bitmap_result.data_bitmap = std::move(roaring);
segment_v2::InvertedIndexResultBitmap result(roaring, null_bitmap);
bitmap_result = std::move(result);
//bitmap_result.null_bitmap = std::move(null_bitmap);
//bitmap_result.data_bitmap = std::move(roaring);

return Status::OK();
}
Expand Down

0 comments on commit 1fe5ce7

Please sign in to comment.