csun5285 commented on code in PR #66472:
URL: https://github.com/apache/doris/pull/66472#discussion_r3765664169
##########
be/src/storage/segment/segment_iterator.cpp:
##########
@@ -2256,50 +2044,30 @@ Status SegmentIterator::_init_current_block(Block*
block,
return Status::OK();
}
-Status SegmentIterator::_output_non_pred_columns(Block* block) {
+Status SegmentIterator::_output_columns_to_block(Block* block) {
SCOPED_RAW_TIMER(&_opts.stats->output_col_ns);
- VLOG_DEBUG << fmt::format(
- "Output non-predicate columns, _non_predicate_columns: [{}], "
- "schema_column_id_to_index: [{}]",
- fmt::join(_non_predicate_columns, ","),
fmt::join(_schema->column_id_to_index(), ","));
- RETURN_IF_ERROR(_convert_to_expected_type(_non_predicate_columns));
- for (auto cid : _non_predicate_columns) {
- auto loc = _schema->column_index(cid);
- // Whether a delete predicate column gets output depends on how the
caller builds
- // the block passed to next_batch(). Both calling paths now build the
block with
- // only the output schema (return_columns), so delete predicate
columns are skipped:
- //
- // 1) VMergeIterator path: block_reset() builds _block using the
output schema
- // (return_columns only), e.g. block has 2 columns {c1, c2}.
- // Here loc=2 for delete predicate c3, block->columns()=2, so loc <
block->columns()
- // is false, and c3 is skipped.
- //
- // 2) VUnionIterator path: the caller's block is built with only
return_columns
- // (output schema), e.g. block has 2 columns {c1, c2}.
- // Here loc=2 for c3, block->columns()=2, so loc < block->columns()
is false,
- // and c3 is skipped — same behavior as the VMergeIterator path.
- if (loc < block->columns()) {
- bool column_in_block_is_nothing = check_and_get_column<const
ColumnNothing>(
- block->get_by_position(loc).column.get());
- bool column_is_normal = !_virtual_column_exprs.contains(cid);
- bool return_column_is_nothing =
- check_and_get_column<const
ColumnNothing>(_current_return_columns[cid].get());
- VLOG_DEBUG << fmt::format(
- "Cid {} loc {}, column_in_block_is_nothing {},
column_is_normal {}, "
- "return_column_is_nothing {}",
- cid, loc, column_in_block_is_nothing, column_is_normal,
- return_column_is_nothing);
-
- if (column_in_block_is_nothing || column_is_normal) {
- block->replace_by_position(loc,
std::move(_current_return_columns[cid]));
- VLOG_DEBUG << fmt::format(
- "Output non-predicate column, cid: {}, loc: {},
col_name: {}, rows {}", cid,
- loc, _schema->column(cid)->name(),
- block->get_by_position(loc).column->size());
- }
- // Means virtual column in block has been materialized(maybe by
common expr).
- // so do nothing here.
+ VLOG_DEBUG << fmt::format("Output columns, ordinals: [{}]",
fmt::join(_output_ordinals, ","));
+ RETURN_IF_ERROR(_convert_to_expected_type(_output_ordinals));
+ for (auto cid : _output_ordinals) {
+ DCHECK_LT(cid, _schema->num_block_columns());
+ bool column_in_block_is_nothing =
+ check_and_get_column<const
ColumnNothing>(block->get_by_position(cid).column.get());
+ bool column_is_normal = !_virtual_column_exprs.contains(cid);
+ bool current_column_is_nothing =
+ check_and_get_column<const
ColumnNothing>(_current_columns[cid].get());
+ VLOG_DEBUG << fmt::format(
+ "Cid {}, column_in_block_is_nothing {}, column_is_normal {}, "
+ "current_column_is_nothing {}",
+ cid, column_in_block_is_nothing, column_is_normal,
current_column_is_nothing);
+
+ if (column_in_block_is_nothing || column_is_normal) {
+ block->replace_by_position(cid, std::move(_current_columns[cid]));
Review Comment:
看起来这里不用 replace,难道是 column_in_block_is_nothing 的时候需要特别处理?
--
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]