github-actions[bot] commented on code in PR #61535:
URL: https://github.com/apache/doris/pull/61535#discussion_r3134969901
##########
be/src/storage/segment/segment.cpp:
##########
@@ -623,6 +624,22 @@ Status Segment::_create_column_meta(const SegmentFooterPB&
footer) {
// Initialize column meta accessor which internally maintains uid ->
column_ordinal mapping.
_column_meta_accessor = std::make_unique<ColumnMetaAccessor>();
RETURN_IF_ERROR(_column_meta_accessor->init(footer, _file_reader));
+
Review Comment:
**[High]** `_create_column_meta()` runs under `DorisCallOnce` on cached
`Segment` instances, so gating this cache fill on
`config::enable_adaptive_batch_size` makes the result depend on whichever query
touched the segment first. If a segment is opened while the BE param is
`false`, `_column_uid_to_raw_bytes` stays empty forever for that cached object.
After a later `set_be_param('enable_adaptive_batch_size', 'true')`,
`SegmentIterator` will start building predictors again, but every
`column_raw_data_bytes()` lookup on the reused segment still returns `0` until
cache eviction or restart.
This is a separate lifecycle bug from the existing config-gating comments:
even after the feature is re-enabled correctly, cached segments never regain
their metadata hints. Please populate `_column_uid_to_raw_bytes`
unconditionally here (or lazily on first lookup) so dynamic config flips do not
change behavior based on cache history.
##########
be/src/storage/segment/segment_iterator.cpp:
##########
@@ -367,6 +367,36 @@ Status SegmentIterator::_init_impl(const
StorageReadOptions& opts) {
// Read options will not change, so that just resize here
_block_rowids.resize(_opts.block_row_max);
+ // Adaptive batch size: snapshot the initial row limit and create
predictor if enabled.
+ _initial_block_row_max = _opts.block_row_max;
+ if (config::enable_adaptive_batch_size && _opts.preferred_block_size_bytes
> 0) {
+ // Collect per-column raw byte metadata from the segment footer.
+ std::vector<AdaptiveBlockSizePredictor::ColumnMetadata> col_metadata;
+ uint32_t seg_rows = _segment->num_rows();
+ if (seg_rows > 0) {
+ const auto& ts = _segment->tablet_schema();
+ if (ts) {
+ for (ColumnId cid : _opts.adaptive_batch_output_columns) {
+ if (static_cast<size_t>(cid) < ts->num_columns()) {
+ int32_t uid = ts->column(cid).unique_id();
+ uint64_t raw_bytes =
_segment->column_raw_data_bytes(uid);
Review Comment:
**[High]** This footer bootstrap is still using `raw_data_bytes /
segment_rows` as if it were the runtime bytes-per-row of the returned block.
That is not true for sparse nullable fixed-width columns: `raw_data_bytes` only
counts non-null payload, but the read block still materializes the nested POD
array plus the null map for every row. A `Nullable<Int32>` column with 1%
non-nulls can therefore contribute almost nothing here even though the returned
block still costs about `type_size + 1` bytes per row, so the first prediction
stays near the 4096-row probe cap and can blow far past
`preferred_block_size_bytes` before EWMA has any history.
This is distinct from the existing `origin_return_columns` thread: the
column order can be correct and we still underestimate badly. `merger.cpp`
already has to correct footer raw sizes with `max(raw_per_row, type_size)` plus
the null-map byte; this path needs the same adjustment (or a shared helper) for
the query-side bootstrap too.
##########
be/src/exec/sort/partition_sorter.cpp:
##########
@@ -145,12 +146,18 @@ Status PartitionSorter::_read_row_num(Block*
output_block, bool* eos, int batch_
} else {
queue.remove_top();
}
+
+ // block_max_bytes == 0 means no byte budget.
Review Comment:
**[Medium]** The new byte-budget check is still bypassed by the `ROW_NUMBER`
whole-block fast path a few lines above:
```cpp
if (current->impl->is_last(step) && current->impl->pos == 0) {
...
output_block->swap(*current->impl->block);
return Status::OK();
}
```
When `current_rows` covers the whole source block and `merged_rows == 0`,
`_read_row_num()` returns that entire block before any `block_max_bytes` test
runs. A partition whose first remaining sorted block is already wider than the
target will still emit an oversized batch. This is distinct from the existing
`vsorted_run_merger` comment: it is the partition-sort row-number fast path,
not the merge-run reader.
The new test only checks `num_blocks > 1`, so it would still pass if the
first returned block is larger than `preferred_block_size_bytes`. Please gate
the fast path on the byte budget (or split that block before swapping) and add
an assertion on per-block size.
--
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]