be/src/storage/segment/segment_iterator.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <gen_cpp/Exprs_types.h> |
21 | | #include <stddef.h> |
22 | | #include <stdint.h> |
23 | | |
24 | | #include <map> |
25 | | #include <memory> |
26 | | #include <ostream> |
27 | | #include <roaring/roaring.hh> |
28 | | #include <set> |
29 | | #include <string> |
30 | | #include <unordered_map> |
31 | | #include <utility> |
32 | | #include <vector> |
33 | | |
34 | | #include "common/status.h" |
35 | | #include "core/block/block.h" |
36 | | #include "core/block/column_with_type_and_name.h" |
37 | | #include "core/block/columns_with_type_and_name.h" |
38 | | #include "core/column/column.h" |
39 | | #include "core/data_type/data_type.h" |
40 | | #include "exec/common/variant_util.h" |
41 | | #include "exprs/score_runtime.h" |
42 | | #include "exprs/vexpr_fwd.h" |
43 | | #include "io/fs/file_reader_writer_fwd.h" |
44 | | #include "runtime/runtime_profile.h" |
45 | | #include "storage/field.h" |
46 | | #include "storage/index/ann/ann_topn_runtime.h" |
47 | | #include "storage/index/index_iterator.h" |
48 | | #include "storage/iterators.h" |
49 | | #include "storage/olap_common.h" |
50 | | #include "storage/predicate/block_column_predicate.h" |
51 | | #include "storage/predicate/column_predicate.h" |
52 | | #include "storage/row_cursor.h" |
53 | | #include "storage/row_cursor_cell.h" |
54 | | #include "storage/schema.h" |
55 | | #include "storage/segment/common.h" |
56 | | #include "storage/segment/segment.h" |
57 | | #include "util/slice.h" |
58 | | |
59 | | namespace doris { |
60 | | |
61 | | class ObjectPool; |
62 | | class MatchPredicate; |
63 | | |
64 | | class VExpr; |
65 | | class VExprContext; |
66 | | struct RowLocation; |
67 | | |
68 | | namespace segment_v2 { |
69 | | |
70 | | class ColumnIterator; |
71 | | class InvertedIndexIterator; |
72 | | class RowRanges; |
73 | | class IndexIterator; |
74 | | |
75 | | struct ColumnPredicateInfo { |
76 | | ColumnPredicateInfo() = default; |
77 | | |
78 | 0 | std::string debug_string() const { |
79 | 0 | std::stringstream ss; |
80 | 0 | ss << "column_name=" << column_name << ", query_op=" << query_op |
81 | 0 | << ", query_value=" << boost::join(query_values, ","); |
82 | 0 | return ss.str(); |
83 | 0 | } |
84 | | |
85 | 0 | bool is_empty() const { |
86 | 0 | return column_name.empty() && query_values.empty() && query_op.empty(); |
87 | 0 | } |
88 | | |
89 | 0 | bool is_equal(const ColumnPredicateInfo& column_pred_info) const { |
90 | 0 | if (column_pred_info.column_name != column_name) { |
91 | 0 | return false; |
92 | 0 | } |
93 | 0 |
|
94 | 0 | if (column_pred_info.query_values != query_values) { |
95 | 0 | return false; |
96 | 0 | } |
97 | 0 |
|
98 | 0 | if (column_pred_info.query_op != query_op) { |
99 | 0 | return false; |
100 | 0 | } |
101 | 0 |
|
102 | 0 | return true; |
103 | 0 | } |
104 | | |
105 | | std::string column_name; |
106 | | // use set to ensure the consistent order of predicate_result_sign generated by inlist. |
107 | | std::set<std::string> query_values; |
108 | | std::string query_op; |
109 | | int32_t column_id; |
110 | | }; |
111 | | |
112 | | class SegmentIterator : public RowwiseIterator { |
113 | | public: |
114 | | SegmentIterator(std::shared_ptr<Segment> segment, SchemaSPtr schema); |
115 | | ~SegmentIterator() override; |
116 | | |
117 | | [[nodiscard]] Status init_iterators(); |
118 | | [[nodiscard]] Status init(const StorageReadOptions& opts) override; |
119 | | [[nodiscard]] Status next_batch(Block* block) override; |
120 | | |
121 | | // Get current block row locations. This function should be called |
122 | | // after the `next_batch` function. |
123 | | // Only vectorized version is supported. |
124 | | [[nodiscard]] Status current_block_row_locations( |
125 | | std::vector<RowLocation>* block_row_locations) override; |
126 | | |
127 | 266 | const Schema& schema() const override { return *_schema; } |
128 | 0 | Segment& segment() { return *_segment; } |
129 | 0 | StorageReadOptions& storage_read_options() { return _opts; } |
130 | 12 | uint64_t data_id() const override { return _segment->id(); } |
131 | 0 | RowsetId rowset_id() const { return _segment->rowset_id(); } |
132 | 0 | int64_t tablet_id() const { return _tablet_id; } |
133 | | |
134 | 0 | void update_profile(RuntimeProfile* profile) override { |
135 | 0 | _update_profile(profile, _short_cir_eval_predicate, "ShortCircuitPredicates"); |
136 | 0 | _update_profile(profile, _pre_eval_block_predicate, "PreEvaluatePredicates"); |
137 | |
|
138 | 0 | if (_opts.delete_condition_predicates != nullptr) { |
139 | 0 | std::set<std::shared_ptr<const ColumnPredicate>> delete_predicate_set; |
140 | 0 | _opts.delete_condition_predicates->get_all_column_predicate(delete_predicate_set); |
141 | 0 | _update_profile(profile, delete_predicate_set, "DeleteConditionPredicates"); |
142 | 0 | } |
143 | 0 | } |
144 | | |
145 | 0 | bool has_index_in_iterators() const { |
146 | 0 | return std::any_of(_index_iterators.begin(), _index_iterators.end(), |
147 | 0 | [](const auto& iterator) { return iterator != nullptr; }); |
148 | 0 | } |
149 | | |
150 | | private: |
151 | | Status _next_batch_internal(Block* block); |
152 | | |
153 | | Status _check_output_block(Block* block); |
154 | | |
155 | | template <typename Container> |
156 | | void _update_profile(RuntimeProfile* profile, const Container& predicates, |
157 | 0 | const std::string& title) { |
158 | 0 | if (predicates.empty()) { |
159 | 0 | return; |
160 | 0 | } |
161 | 0 | std::string info; |
162 | 0 | for (auto pred : predicates) { |
163 | 0 | info += "\n" + pred->debug_string(); |
164 | 0 | } |
165 | 0 | profile->add_info_string(title, info); |
166 | 0 | } Unexecuted instantiation: _ZN5doris10segment_v215SegmentIterator15_update_profileISt6vectorISt10shared_ptrINS_15ColumnPredicateEESaIS6_EEEEvPNS_14RuntimeProfileERKT_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE Unexecuted instantiation: _ZN5doris10segment_v215SegmentIterator15_update_profileISt3setISt10shared_ptrIKNS_15ColumnPredicateEESt4lessIS7_ESaIS7_EEEEvPNS_14RuntimeProfileERKT_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE |
167 | | |
168 | | [[nodiscard]] Status _lazy_init(Block* block); |
169 | | [[nodiscard]] Status _init_impl(const StorageReadOptions& opts); |
170 | | [[nodiscard]] Status _init_return_column_iterators(); |
171 | | [[nodiscard]] Status _init_index_iterators(); |
172 | | |
173 | | // calculate row ranges that fall into requested key ranges using short key index |
174 | | [[nodiscard]] Status _get_row_ranges_by_keys(); |
175 | | [[nodiscard]] Status _prepare_seek(const StorageReadOptions::KeyRange& key_range); |
176 | | [[nodiscard]] Status _lookup_ordinal(const RowCursor& key, bool is_include, rowid_t upper_bound, |
177 | | rowid_t* rowid); |
178 | | // lookup the ordinal of given key from short key index |
179 | | // the returned rowid is rowid in primary index, not the rowid encoded in primary key |
180 | | [[nodiscard]] Status _lookup_ordinal_from_sk_index(const RowCursor& key, bool is_include, |
181 | | rowid_t upper_bound, rowid_t* rowid); |
182 | | // lookup the ordinal of given key from primary key index |
183 | | [[nodiscard]] Status _lookup_ordinal_from_pk_index(const RowCursor& key, bool is_include, |
184 | | rowid_t* rowid); |
185 | | [[nodiscard]] Status _seek_and_peek(rowid_t rowid); |
186 | | |
187 | | // calculate row ranges that satisfy requested column conditions using various column index |
188 | | [[nodiscard]] Status _get_row_ranges_by_column_conditions(); |
189 | | [[nodiscard]] Status _get_row_ranges_from_conditions(RowRanges* condition_row_ranges); |
190 | | |
191 | | [[nodiscard]] Status _apply_inverted_index(); |
192 | | [[nodiscard]] Status _apply_inverted_index_on_column_predicate( |
193 | | std::shared_ptr<ColumnPredicate> pred, |
194 | | std::vector<std::shared_ptr<ColumnPredicate>>& remaining_predicates, |
195 | | bool* continue_apply); |
196 | | [[nodiscard]] Status _apply_ann_topn_predicate(); |
197 | | [[nodiscard]] Status _apply_index_expr(); |
198 | | |
199 | | bool _column_has_fulltext_index(int32_t cid); |
200 | | bool _column_has_ann_index(int32_t cid); |
201 | | bool _downgrade_without_index(Status res, bool need_remaining = false); |
202 | | inline bool _inverted_index_not_support_pred_type(const PredicateType& type); |
203 | | bool _is_literal_node(const TExprNodeType::type& node_type); |
204 | | |
205 | | Status _vec_init_lazy_materialization(); |
206 | | // TODO: Fix Me |
207 | | // CHAR type in storage layer padding the 0 in length. But query engine need ignore the padding 0. |
208 | | // so segment iterator need to shrink char column before output it. only use in vec query engine. |
209 | | void _vec_init_char_column_id(Block* block); |
210 | | bool _has_char_type(const StorageField& column_desc); |
211 | | |
212 | 12.8k | uint32_t segment_id() const { return _segment->id(); } |
213 | 17.8k | uint32_t num_rows() const { return _segment->num_rows(); } |
214 | | |
215 | | [[nodiscard]] Status _seek_columns(const std::vector<ColumnId>& column_ids, rowid_t pos); |
216 | | // read `nrows` of columns specified by `column_ids` into `block` at `row_offset`. |
217 | | // for vectorization implementation |
218 | | [[nodiscard]] Status _read_columns(const std::vector<ColumnId>& column_ids, |
219 | | MutableColumns& column_block, size_t nrows); |
220 | | [[nodiscard]] Status _read_columns_by_index(uint32_t nrows_read_limit, uint16_t& nrows_read); |
221 | | void _replace_version_col_if_needed(const std::vector<ColumnId>& column_ids, size_t num_rows); |
222 | | Status _init_current_block(Block* block, std::vector<MutableColumnPtr>& non_pred_vector, |
223 | | uint32_t nrows_read_limit); |
224 | | uint16_t _evaluate_vectorization_predicate(uint16_t* sel_rowid_idx, uint16_t selected_size); |
225 | | uint16_t _evaluate_short_circuit_predicate(uint16_t* sel_rowid_idx, uint16_t selected_size); |
226 | | void _collect_runtime_filter_predicate(); |
227 | | Status _output_non_pred_columns(Block* block); |
228 | | [[nodiscard]] Status _read_columns_by_rowids(std::vector<ColumnId>& read_column_ids, |
229 | | std::vector<rowid_t>& rowid_vector, |
230 | | uint16_t* sel_rowid_idx, size_t select_size, |
231 | | MutableColumns* mutable_columns, |
232 | | bool init_condition_cache = false); |
233 | | |
234 | | Status copy_column_data_by_selector(IColumn* input_col_ptr, MutableColumnPtr& output_col, |
235 | | uint16_t* sel_rowid_idx, uint16_t select_size, |
236 | | size_t batch_size); |
237 | | |
238 | | template <class Container> |
239 | | [[nodiscard]] Status _output_column_by_sel_idx(Block* block, const Container& column_ids, |
240 | 4.04k | uint16_t* sel_rowid_idx, uint16_t select_size) { |
241 | 4.04k | SCOPED_RAW_TIMER(&_opts.stats->output_col_ns); |
242 | 4.04k | for (auto cid : column_ids) { |
243 | 4.04k | int block_cid = _schema_block_id_map[cid]; |
244 | | // Only the additional deleted filter condition need to materialize column be at the end of the block |
245 | | // We should not to materialize the column of query engine do not need. So here just return OK. |
246 | | // Eg: |
247 | | // `delete from table where a = 10;` |
248 | | // `select b from table;` |
249 | | // a column only effective in segment iterator, the block from query engine only contain the b column. |
250 | | // so the `block_cid >= data.size()` is true |
251 | 4.04k | if (block_cid >= block->columns()) { |
252 | 1.21k | continue; |
253 | 1.21k | } |
254 | 2.83k | DataTypePtr storage_type = |
255 | 2.83k | _segment->get_data_type_of(_schema->column(cid)->get_desc(), _opts); |
256 | 2.83k | if (storage_type && !storage_type->equals(*block->get_by_position(block_cid).type)) { |
257 | | // Do additional cast |
258 | 0 | MutableColumnPtr tmp = storage_type->create_column(); |
259 | 0 | RETURN_IF_ERROR(copy_column_data_by_selector(_current_return_columns[cid].get(), |
260 | 0 | tmp, sel_rowid_idx, select_size, |
261 | 0 | _opts.block_row_max)); |
262 | 0 | RETURN_IF_ERROR(variant_util::cast_column( |
263 | 0 | {tmp->get_ptr(), storage_type, ""}, block->get_by_position(block_cid).type, |
264 | 0 | &block->get_by_position(block_cid).column)); |
265 | 2.83k | } else { |
266 | 2.83k | MutableColumnPtr output_column = |
267 | 2.83k | block->get_by_position(block_cid).column->assume_mutable(); |
268 | 2.83k | RETURN_IF_ERROR(copy_column_data_by_selector(_current_return_columns[cid].get(), |
269 | 2.83k | output_column, sel_rowid_idx, |
270 | 2.83k | select_size, _opts.block_row_max)); |
271 | 2.83k | } |
272 | 2.83k | } |
273 | 4.04k | return Status::OK(); |
274 | 4.04k | } |
275 | | |
276 | | bool _can_evaluated_by_vectorized(std::shared_ptr<ColumnPredicate> predicate); |
277 | | |
278 | | [[nodiscard]] Status _extract_common_expr_columns(const VExprSPtr& expr); |
279 | | // same with _extract_common_expr_columns, but only extract columns that can be used for index |
280 | | [[nodiscard]] Status _execute_common_expr(uint16_t* sel_rowid_idx, uint16_t& selected_size, |
281 | | Block* block); |
282 | | Status _process_common_expr(uint16_t* sel_rowid_idx, uint16_t& selected_size, Block* block); |
283 | | |
284 | | uint16_t _evaluate_common_expr_filter(uint16_t* sel_rowid_idx, uint16_t selected_size, |
285 | | const IColumn::Filter& filter); |
286 | | |
287 | | // Dictionary column should do something to initial. |
288 | | void _convert_dict_code_for_predicate_if_necessary(); |
289 | | |
290 | | void _convert_dict_code_for_predicate_if_necessary_impl( |
291 | | std::shared_ptr<ColumnPredicate> predicate); |
292 | | |
293 | | bool _check_apply_by_inverted_index(std::shared_ptr<ColumnPredicate> pred); |
294 | | |
295 | | void _output_index_result_column(const std::vector<VExprContext*>& expr_ctxs, |
296 | | uint16_t* sel_rowid_idx, uint16_t select_size, Block* block); |
297 | | |
298 | | bool _need_read_data(ColumnId cid); |
299 | | bool _prune_column(ColumnId cid, MutableColumnPtr& column, bool fill_defaults, |
300 | | size_t num_of_defaults); |
301 | | |
302 | | Status _construct_compound_expr_context(); |
303 | | |
304 | | // todo(wb) remove this method after RowCursor is removed |
305 | | void NO_SANITIZE_UNDEFINED _convert_rowcursor_to_short_key(const RowCursor& key, |
306 | 0 | size_t num_keys) { |
307 | 0 | if (_short_key.size() == 0) { |
308 | 0 | _short_key.resize(num_keys); |
309 | 0 | for (auto cid = 0; cid < num_keys; cid++) { |
310 | 0 | auto* field = key.schema()->column(cid); |
311 | 0 | _short_key[cid] = Schema::get_column_by_field(*field); |
312 | 0 | } |
313 | 0 | } else { |
314 | 0 | for (int i = 0; i < num_keys; i++) { |
315 | 0 | _short_key[i]->clear(); |
316 | 0 | } |
317 | 0 | } |
318 | |
|
319 | 0 | for (auto cid = 0; cid < num_keys; cid++) { |
320 | 0 | auto field = key.schema()->column(cid); |
321 | 0 | if (field == nullptr) { |
322 | 0 | break; |
323 | 0 | } |
324 | 0 | auto cell = key.cell(cid); |
325 | 0 | if (cell.is_null()) { |
326 | 0 | _short_key[cid]->insert_default(); |
327 | 0 | } else { |
328 | 0 | if (field->type() == FieldType::OLAP_FIELD_TYPE_VARCHAR || |
329 | 0 | field->type() == FieldType::OLAP_FIELD_TYPE_CHAR || |
330 | 0 | field->type() == FieldType::OLAP_FIELD_TYPE_STRING) { |
331 | 0 | const Slice* slice = reinterpret_cast<const Slice*>(cell.cell_ptr()); |
332 | 0 | _short_key[cid]->insert_data(slice->data, slice->size); |
333 | 0 | } else { |
334 | 0 | _short_key[cid]->insert_many_fix_len_data( |
335 | 0 | reinterpret_cast<const char*>(cell.cell_ptr()), 1); |
336 | 0 | } |
337 | 0 | } |
338 | 0 | } |
339 | 0 | } |
340 | | |
341 | 0 | int _compare_short_key_with_seek_block(const std::vector<ColumnId>& col_ids) { |
342 | 0 | for (auto cid : col_ids) { |
343 | | // todo(wb) simd compare when memory layout in row |
344 | 0 | auto res = _short_key[cid]->compare_at(0, 0, *_seek_block[cid], -1); |
345 | 0 | if (res != 0) { |
346 | 0 | return res; |
347 | 0 | } |
348 | 0 | } |
349 | 0 | return 0; |
350 | 0 | } |
351 | | |
352 | | Status _convert_to_expected_type(const std::vector<ColumnId>& col_ids); |
353 | | |
354 | | bool _no_need_read_key_data(ColumnId cid, MutableColumnPtr& column, size_t nrows_read); |
355 | | |
356 | | bool _has_delete_predicate(ColumnId cid); |
357 | | |
358 | | bool _can_opt_topn_reads(); |
359 | | |
360 | | void _initialize_predicate_results(); |
361 | | bool _check_all_conditions_passed_inverted_index_for_column(ColumnId cid, |
362 | | bool default_return = false); |
363 | | |
364 | | void _calculate_expr_in_remaining_conjunct_root(); |
365 | | |
366 | | Status _process_eof(Block* block); |
367 | | |
368 | | Status _process_column_predicate(); |
369 | | |
370 | | void _fill_column_nothing(); |
371 | | |
372 | | Status _process_columns(const std::vector<ColumnId>& column_ids, Block* block); |
373 | | |
374 | | // Initialize virtual columns in the block, set all virtual columns in the block to ColumnNothing |
375 | | void _init_virtual_columns(Block* block); |
376 | | // Fallback logic for virtual column materialization, materializing all unmaterialized virtual columns through expressions |
377 | | Status _materialization_of_virtual_column(Block* block); |
378 | | void _prepare_score_column_materialization(); |
379 | | |
380 | | void _init_row_bitmap_by_condition_cache(); |
381 | | |
382 | | void _init_segment_prefetchers(); |
383 | | |
384 | | class BitmapRangeIterator; |
385 | | class BackwardBitmapRangeIterator; |
386 | | |
387 | | std::shared_ptr<Segment> _segment; |
388 | | // read schema from scanner |
389 | | SchemaSPtr _schema; |
390 | | // storage type schema related to _schema, since column in segment may be different with type in _schema |
391 | | std::vector<IndexFieldNameAndTypePair> _storage_name_and_type; |
392 | | // vector idx -> column iterarator |
393 | | std::vector<std::unique_ptr<ColumnIterator>> _column_iterators; |
394 | | std::vector<std::unique_ptr<IndexIterator>> _index_iterators; |
395 | | // after init(), `_row_bitmap` contains all rowid to scan |
396 | | roaring::Roaring _row_bitmap; |
397 | | // an iterator for `_row_bitmap` that can be used to extract row range to scan |
398 | | std::unique_ptr<BitmapRangeIterator> _range_iter; |
399 | | // the next rowid to read |
400 | | rowid_t _cur_rowid; |
401 | | // members related to lazy materialization read |
402 | | // -------------------------------------------- |
403 | | // whether lazy materialization read should be used. |
404 | | bool _lazy_materialization_read; |
405 | | // columns to read after predicate evaluation and remaining expr execute |
406 | | std::vector<ColumnId> _non_predicate_columns; |
407 | | std::set<ColumnId> _common_expr_columns; |
408 | | // remember the rowids we've read for the current row block. |
409 | | // could be a local variable of next_batch(), kept here to reuse vector memory |
410 | | std::vector<rowid_t> _block_rowids; |
411 | | bool _is_need_vec_eval = false; |
412 | | bool _is_need_short_eval = false; |
413 | | bool _is_need_expr_eval = false; |
414 | | |
415 | | // fields for vectorization execution |
416 | | std::vector<ColumnId> |
417 | | _vec_pred_column_ids; // keep columnId of columns for vectorized predicate evaluation |
418 | | std::vector<ColumnId> |
419 | | _short_cir_pred_column_ids; // keep columnId of columns for short circuit predicate evaluation |
420 | | std::vector<bool> _is_pred_column; // columns hold _init segmentIter |
421 | | std::map<uint32_t, bool> _need_read_data_indices; |
422 | | std::vector<bool> _is_common_expr_column; |
423 | | MutableColumns _current_return_columns; |
424 | | std::vector<std::shared_ptr<ColumnPredicate>> _pre_eval_block_predicate; |
425 | | std::vector<std::shared_ptr<ColumnPredicate>> _short_cir_eval_predicate; |
426 | | std::vector<uint32_t> _delete_range_column_ids; |
427 | | std::vector<uint32_t> _delete_bloom_filter_column_ids; |
428 | | // when lazy materialization is enabled, segmentIter need to read data at least twice |
429 | | // first, read predicate columns by various index |
430 | | // second, read non-predicate columns |
431 | | // so we need a field to stand for columns first time to read |
432 | | std::vector<ColumnId> _predicate_column_ids; |
433 | | std::vector<ColumnId> _common_expr_column_ids; |
434 | | // TODO: Should use std::vector<size_t> |
435 | | std::vector<ColumnId> _columns_to_filter; |
436 | | std::vector<bool> _converted_column_ids; |
437 | | // TODO: Should use std::vector<size_t> |
438 | | std::vector<int> _schema_block_id_map; // map from schema column id to column idx in Block |
439 | | |
440 | | // the actual init process is delayed to the first call to next_batch() |
441 | | bool _lazy_inited; |
442 | | bool _inited; |
443 | | |
444 | | StorageReadOptions _opts; |
445 | | // make a copy of `_opts.column_predicates` in order to make local changes |
446 | | std::vector<std::shared_ptr<ColumnPredicate>> _col_predicates; |
447 | | VExprContextSPtrs _common_expr_ctxs_push_down; |
448 | | bool _enable_common_expr_pushdown = false; |
449 | | std::vector<VExprSPtr> _remaining_conjunct_roots; |
450 | | std::set<ColumnId> _not_apply_index_pred; |
451 | | |
452 | | // row schema of the key to seek |
453 | | // only used in `_get_row_ranges_by_keys` |
454 | | std::unique_ptr<Schema> _seek_schema; |
455 | | // used to binary search the rowid for a given key |
456 | | // only used in `_get_row_ranges_by_keys` |
457 | | MutableColumns _seek_block; |
458 | | |
459 | | //todo(wb) remove this field after Rowcursor is removed |
460 | | MutableColumns _short_key; |
461 | | |
462 | | io::FileReaderSPtr _file_reader; |
463 | | |
464 | | // char_type or array<char> type columns cid |
465 | | std::vector<size_t> _char_type_idx; |
466 | | std::vector<bool> _is_char_type; |
467 | | |
468 | | // used for compaction, record selectd rowids of current batch |
469 | | uint16_t _selected_size; |
470 | | std::vector<uint16_t> _sel_rowid_idx; |
471 | | |
472 | | std::unique_ptr<ObjectPool> _pool; |
473 | | |
474 | | // used to collect filter information. |
475 | | std::vector<std::shared_ptr<ColumnPredicate>> _filter_info_id; |
476 | | bool _record_rowids = false; |
477 | | int64_t _tablet_id = 0; |
478 | | std::set<int32_t> _output_columns; |
479 | | |
480 | | std::vector<uint8_t> _ret_flags; |
481 | | |
482 | | /* |
483 | | * column and column_predicates on it. |
484 | | * a boolean value to indicate whether the column has been read by the index. |
485 | | */ |
486 | | std::unordered_map<ColumnId, std::unordered_map<std::shared_ptr<ColumnPredicate>, bool>> |
487 | | _column_predicate_index_exec_status; |
488 | | |
489 | | /* |
490 | | * column and common expr on it. |
491 | | * a boolean value to indicate whether the column has been read by the index. |
492 | | */ |
493 | | std::unordered_map<ColumnId, std::unordered_map<const VExpr*, bool>> |
494 | | _common_expr_index_exec_status; |
495 | | |
496 | | /* |
497 | | * common expr context to slotref map |
498 | | * slot ref map is used to get slot ref expr by using column id. |
499 | | */ |
500 | | std::unordered_map<VExprContext*, std::unordered_map<ColumnId, VExpr*>> |
501 | | _common_expr_to_slotref_map; |
502 | | |
503 | | ScoreRuntimeSPtr _score_runtime; |
504 | | |
505 | | std::shared_ptr<segment_v2::AnnTopNRuntime> _ann_topn_runtime; |
506 | | |
507 | | // cid to virtual column expr |
508 | | std::map<ColumnId, VExprContextSPtr> _virtual_column_exprs; |
509 | | std::map<ColumnId, size_t> _vir_cid_to_idx_in_block; |
510 | | |
511 | | IndexQueryContextPtr _index_query_context; |
512 | | |
513 | | // key is column uid, value is the sparse column cache |
514 | | std::unordered_map<int32_t, PathToBinaryColumnCacheUPtr> _variant_sparse_column_cache; |
515 | | |
516 | | bool _find_condition_cache = false; |
517 | | std::shared_ptr<std::vector<bool>> _condition_cache; |
518 | | static constexpr int CONDITION_CACHE_OFFSET = 2048; |
519 | | }; |
520 | | |
521 | | } // namespace segment_v2 |
522 | | } // namespace doris |