Skip to content

Commit c7f6225

Browse files
committed
2
1 parent 3cb7b2e commit c7f6225

File tree

13 files changed

+305
-74
lines changed

13 files changed

+305
-74
lines changed

be/src/olap/iterators.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class StorageReadOptions {
116116
// columns for orderby keys
117117
std::vector<uint32_t>* read_orderby_key_columns = nullptr;
118118
IOContext io_ctx;
119-
vectorized::VExpr* remaining_vconjunct_root = nullptr;
119+
vectorized::VExprContext* remaining_vconjunct_ctx = nullptr;
120120
// runtime state
121121
RuntimeState* runtime_state = nullptr;
122122
};

be/src/olap/reader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ Status TabletReader::_capture_rs_readers(const ReaderParams& read_params,
226226
_reader_context.enable_unique_key_merge_on_write = tablet()->enable_unique_key_merge_on_write();
227227
_reader_context.record_rowids = read_params.record_rowids;
228228
_reader_context.is_key_column_group = read_params.is_key_column_group;
229-
_reader_context.remaining_vconjunct_root = read_params.remaining_vconjunct_root;
229+
_reader_context.remaining_vconjunct_ctx = read_params.remaining_vconjunct_ctx;
230230

231231
*valid_rs_readers = *rs_readers;
232232

be/src/olap/reader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class TabletReader {
9292
std::vector<uint32_t>* origin_return_columns = nullptr;
9393
std::unordered_set<uint32_t>* tablet_columns_convert_to_null_set = nullptr;
9494
TPushAggOp::type push_down_agg_type_opt = TPushAggOp::NONE;
95-
vectorized::VExpr* remaining_vconjunct_root = nullptr;
95+
vectorized::VExprContext* remaining_vconjunct_ctx = nullptr;
9696

9797
// used for compaction to record row ids
9898
bool record_rowids = false;

be/src/olap/rowset/beta_rowset_reader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Status BetaRowsetReader::get_segment_iterators(RowsetReaderContext* read_context
5656
// convert RowsetReaderContext to StorageReadOptions
5757
_read_options.stats = _stats;
5858
_read_options.push_down_agg_type_opt = _context->push_down_agg_type_opt;
59-
_read_options.remaining_vconjunct_root = _context->remaining_vconjunct_root;
59+
_read_options.remaining_vconjunct_ctx = _context->remaining_vconjunct_ctx;
6060
if (read_context->lower_bound_keys != nullptr) {
6161
for (int i = 0; i < read_context->lower_bound_keys->size(); ++i) {
6262
_read_options.key_ranges.emplace_back(&read_context->lower_bound_keys->at(i),

be/src/olap/rowset/rowset_reader_context.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct RowsetReaderContext {
5858
const DeleteHandler* delete_handler = nullptr;
5959
OlapReaderStatistics* stats = nullptr;
6060
RuntimeState* runtime_state = nullptr;
61-
vectorized::VExpr* remaining_vconjunct_root = nullptr;
61+
vectorized::VExprContext* remaining_vconjunct_ctx = nullptr;
6262
bool use_page_cache = false;
6363
int sequence_id_idx = -1;
6464
int batch_size = 1024;

be/src/olap/rowset/segment_v2/segment_iterator.cpp

+265-64
Large diffs are not rendered by default.

be/src/olap/rowset/segment_v2/segment_iterator.h

+12
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ class SegmentIterator : public RowwiseIterator {
178178

179179
bool _can_evaluated_by_vectorized(ColumnPredicate* predicate);
180180

181+
Status _extract_remaining_expr_columns(vectorized::VExpr* expr);
182+
uint16_t _execute_remaining_expr(uint16_t* sel_rowid_idx, uint16_t selected_size,
183+
vectorized::Block* block);
184+
uint16_t _evaluate_remaining_expr_filter(uint16_t* sel_rowid_idx, uint16_t selected_size,
185+
const vectorized::IColumn::Filter& filter);
186+
181187
// Dictionary column should do something to initial.
182188
void _convert_dict_code_for_predicate_if_necessary();
183189

@@ -279,18 +285,21 @@ class SegmentIterator : public RowwiseIterator {
279285
std::vector<ColumnId> _predicate_columns;
280286
// columns to read after predicate evaluation
281287
std::vector<ColumnId> _non_predicate_columns;
288+
std::vector<ColumnId> _remaining_expr_columns;
282289
// remember the rowids we've read for the current row block.
283290
// could be a local variable of next_batch(), kept here to reuse vector memory
284291
std::vector<rowid_t> _block_rowids;
285292
bool _is_need_vec_eval = false;
286293
bool _is_need_short_eval = false;
294+
bool _is_need_expr_eval = false;
287295

288296
// fields for vectorization execution
289297
std::vector<ColumnId>
290298
_vec_pred_column_ids; // keep columnId of columns for vectorized predicate evaluation
291299
std::vector<ColumnId>
292300
_short_cir_pred_column_ids; // keep columnId of columns for short circuit predicate evaluation
293301
std::vector<bool> _is_pred_column; // columns hold by segmentIter
302+
std::vector<bool> _is_remaining_expr_column;
294303
vectorized::MutableColumns _current_return_columns;
295304
std::vector<ColumnPredicate*> _pre_eval_block_predicate;
296305
std::vector<ColumnPredicate*> _short_cir_eval_predicate;
@@ -301,6 +310,8 @@ class SegmentIterator : public RowwiseIterator {
301310
// second, read non-predicate columns
302311
// so we need a field to stand for columns first time to read
303312
std::vector<ColumnId> _first_read_column_ids;
313+
std::vector<ColumnId> _second_read_column_ids;
314+
std::vector<ColumnId> _columns_to_filter;
304315
std::vector<int> _schema_block_id_map; // map from schema column id to column idx in Block
305316

306317
// the actual init process is delayed to the first call to next_batch()
@@ -311,6 +322,7 @@ class SegmentIterator : public RowwiseIterator {
311322
// make a copy of `_opts.column_predicates` in order to make local changes
312323
std::vector<ColumnPredicate*> _col_predicates;
313324
std::vector<ColumnPredicate*> _col_preds_except_leafnode_of_andnode;
325+
doris::vectorized::VExprContext* _remaining_vconjunct_ctx;
314326
doris::vectorized::VExpr* _remaining_vconjunct_root;
315327
std::vector<roaring::Roaring> _pred_except_leafnode_of_andnode_evaluate_result;
316328
std::unique_ptr<ColumnPredicateInfo> _column_predicate_info;

be/src/runtime/runtime_state.h

+5
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ class RuntimeState {
139139
_query_options.check_overflow_for_decimal;
140140
}
141141

142+
bool enable_remaining_expr_pushdown() const {
143+
return _query_options.__isset.enable_remaining_expr_pushdown &&
144+
_query_options.enable_remaining_expr_pushdown;
145+
}
146+
142147
// Create a codegen object in _codegen. No-op if it has already been called.
143148
// If codegen is enabled for the query, this is created when the runtime
144149
// state is created. If codegen is disabled for the query, this is created

be/src/vec/core/block.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void Block::check_number_of_rows(bool allow_null_columns) const {
314314

315315
size_t Block::rows() const {
316316
for (const auto& elem : data) {
317-
if (elem.column) {
317+
if (elem.column && elem.column->size() != 0) {
318318
return elem.column->size();
319319
}
320320
}

be/src/vec/exec/scan/new_olap_scanner.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ Status NewOlapScanner::_init_tablet_reader_params(
171171
real_parent->_olap_scan_node.push_down_agg_type_opt;
172172
}
173173
_tablet_reader_params.version = Version(0, _version);
174-
_tablet_reader_params.remaining_vconjunct_root =
175-
(_vconjunct_ctx == nullptr) ? nullptr : _vconjunct_ctx->root();
174+
if (_state->enable_remaining_expr_pushdown()) {
175+
_tablet_reader_params.remaining_vconjunct_ctx = _vconjunct_ctx;
176+
}
176177

177178
// Condition
178179
for (auto& filter : filters) {

be/src/vec/exec/scan/vscanner.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ Status VScanner::get_block(RuntimeState* state, Block* block, bool* eof) {
8080

8181
Status VScanner::_filter_output_block(Block* block) {
8282
auto old_rows = block->rows();
83-
Status st =
84-
VExprContext::filter_block(_vconjunct_ctx, block, _output_tuple_desc->slots().size());
83+
Status st;
84+
if (_state->enable_remaining_expr_pushdown()) {
85+
st = Status::OK();
86+
} else {
87+
st = VExprContext::filter_block(_vconjunct_ctx, block, _output_tuple_desc->slots().size());
88+
}
8589
_counter.num_rows_unselected += old_rows - block->rows();
8690
return st;
8791
}

fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java

+6
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ public class SessionVariable implements Serializable, Writable {
221221

222222
public static final String ENABLE_FUNCTION_PUSHDOWN = "enable_function_pushdown";
223223

224+
public static final String ENABLE_REMAINING_EXPR_PUSHDOWN = "enable_remaining_expr_pushdown";
225+
224226
public static final String FRAGMENT_TRANSMISSION_COMPRESSION_CODEC = "fragment_transmission_compression_codec";
225227

226228
public static final String ENABLE_LOCAL_EXCHANGE = "enable_local_exchange";
@@ -594,6 +596,9 @@ public class SessionVariable implements Serializable, Writable {
594596
@VariableMgr.VarAttr(name = ENABLE_FUNCTION_PUSHDOWN)
595597
public boolean enableFunctionPushdown;
596598

599+
@VariableMgr.VarAttr(name = ENABLE_REMAINING_EXPR_PUSHDOWN)
600+
public boolean enableRemainingExprPushdown = false;
601+
597602
@VariableMgr.VarAttr(name = ENABLE_LOCAL_EXCHANGE)
598603
public boolean enableLocalExchange = true;
599604

@@ -1395,6 +1400,7 @@ public TQueryOptions toThrift() {
13951400
}
13961401

13971402
tResult.setEnableFunctionPushdown(enableFunctionPushdown);
1403+
tResult.setEnableRemainingExprPushdown(enableRemainingExprPushdown);
13981404
tResult.setCheckOverflowForDecimal(checkOverflowForDecimal);
13991405
tResult.setFragmentTransmissionCompressionCodec(fragmentTransmissionCompressionCodec);
14001406
tResult.setEnableLocalExchange(enableLocalExchange);

gensrc/thrift/PaloInternalService.thrift

+2
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ struct TQueryOptions {
190190
57: optional bool check_overflow_for_decimal = false
191191

192192
58: optional i64 external_sort_bytes_threshold = 0
193+
194+
59: optional bool enable_remaining_expr_pushdown = false;
193195
}
194196

195197

0 commit comments

Comments
 (0)