Coverage Report

Created: 2026-07-08 14:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/scan/olap_scanner.cpp
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
#include "exec/scan/olap_scanner.h"
19
20
#include <gen_cpp/Descriptors_types.h>
21
#include <gen_cpp/PlanNodes_types.h>
22
#include <gen_cpp/Types_types.h>
23
#include <glog/logging.h>
24
#include <stdlib.h>
25
#include <thrift/protocol/TDebugProtocol.h>
26
27
#include <algorithm>
28
#include <atomic>
29
#include <iterator>
30
#include <ostream>
31
#include <set>
32
33
#include "cloud/cloud_storage_engine.h"
34
#include "cloud/cloud_tablet_hotspot.h"
35
#include "cloud/config.h"
36
#include "common/config.h"
37
#include "common/consts.h"
38
#include "common/logging.h"
39
#include "common/metrics/doris_metrics.h"
40
#include "core/block/block.h"
41
#include "core/data_type/data_type_number.h"
42
#include "exec/common/variant_util.h"
43
#include "exec/operator/olap_scan_operator.h"
44
#include "exec/scan/scan_node.h"
45
#include "exprs/function_filter.h"
46
#include "exprs/vexpr.h"
47
#include "exprs/vexpr_context.h"
48
#include "io/cache/block_file_cache_profile.h"
49
#include "io/io_common.h"
50
#include "runtime/descriptors.h"
51
#include "runtime/exec_env.h"
52
#include "runtime/runtime_profile.h"
53
#include "runtime/runtime_state.h"
54
#include "service/backend_options.h"
55
#include "storage/binlog.h"
56
#include "storage/id_manager.h"
57
#include "storage/index/inverted/inverted_index_profile.h"
58
#include "storage/iterator/block_reader.h"
59
#include "storage/olap_common.h"
60
#include "storage/olap_tuple.h"
61
#include "storage/olap_utils.h"
62
#include "storage/predicate/predicate_creator.h"
63
#include "storage/storage_engine.h"
64
#include "storage/tablet/tablet_schema.h"
65
#ifndef NDEBUG
66
#include "util/debug_points.h"
67
#endif
68
#include "util/json/path_in_data.h"
69
70
namespace doris {
71
#include "common/compile_check_avoid_begin.h"
72
73
using ReadSource = TabletReadSource;
74
75
OlapScanner::OlapScanner(ScanLocalStateBase* parent, OlapScanner::Params&& params)
76
893k
        : Scanner(params.state, parent, params.limit, params.profile),
77
893k
          _key_ranges(std::move(params.key_ranges)),
78
893k
          _tablet_reader_params({.tablet = std::move(params.tablet),
79
893k
                                 .tablet_schema {},
80
893k
                                 .reader_type = params.read_row_binlog ? ReaderType::READER_BINLOG
81
893k
                                                                       : ReaderType::READER_QUERY,
82
893k
                                 .aggregation = params.aggregation,
83
893k
                                 .version = {0, params.version},
84
893k
                                 .start_key {},
85
893k
                                 .end_key {},
86
893k
                                 .predicates {},
87
893k
                                 .function_filters {},
88
893k
                                 .delete_predicates {},
89
893k
                                 .target_cast_type_for_variants {},
90
893k
                                 .all_access_paths {},
91
893k
                                 .predicate_access_paths {},
92
893k
                                 .rs_splits {},
93
893k
                                 .return_columns {},
94
893k
                                 .tso_predicate_column_id {},
95
893k
                                 .output_columns {},
96
893k
                                 .extra_columns {},
97
893k
                                 .common_expr_ctxs_push_down {},
98
893k
                                 .topn_filter_source_node_ids {},
99
893k
                                 .key_group_cluster_key_idxes {},
100
893k
                                 .virtual_column_exprs {},
101
893k
                                 .score_runtime {},
102
893k
                                 .collection_statistics {},
103
893k
                                 .ann_topn_runtime {},
104
893k
                                 .condition_cache_digest = parent->get_condition_cache_digest(),
105
893k
                                 .binlog_scan_type = params.binlog_scan_type}),
106
893k
          _start_tso(params.start_tso),
107
893k
          _end_tso(params.end_tso),
108
893k
          _initial_file_cache_stats(std::move(params.initial_file_cache_stats)) {
109
893k
    _tablet_reader_params.set_read_source(std::move(params.read_source),
110
893k
                                          _state->skip_delete_bitmap());
111
893k
    _has_prepared = false;
112
893k
    _vector_search_params = params.state->get_vector_search_params();
113
893k
}
114
115
static std::string read_columns_to_string(TabletSchemaSPtr tablet_schema,
116
4.06k
                                          const std::vector<uint32_t>& read_columns) {
117
    // avoid too long for one line,
118
    // it is hard to display in `show profile` stmt if one line is too long.
119
4.06k
    const int col_per_line = 10;
120
4.06k
    int i = 0;
121
4.06k
    std::string read_columns_string;
122
4.06k
    read_columns_string += "[";
123
15.5k
    for (auto it = read_columns.cbegin(); it != read_columns.cend(); it++) {
124
11.5k
        if (it != read_columns.cbegin()) {
125
7.48k
            read_columns_string += ", ";
126
7.48k
        }
127
11.5k
        read_columns_string += tablet_schema->columns().at(*it)->name();
128
11.5k
        if (i >= col_per_line) {
129
13
            read_columns_string += "\n";
130
13
            i = 0;
131
11.5k
        } else {
132
11.5k
            ++i;
133
11.5k
        }
134
11.5k
    }
135
4.06k
    read_columns_string += "]";
136
4.06k
    return read_columns_string;
137
4.06k
}
138
139
1.82M
static bool has_file_cache_statistics(const io::FileCacheStatistics& stats) {
140
1.82M
    return stats.num_local_io_total != 0 || stats.num_remote_io_total != 0 ||
141
1.82M
           stats.num_peer_io_total != 0 || stats.local_io_timer != 0 ||
142
1.82M
           stats.bytes_read_from_local != 0 || stats.bytes_read_from_remote != 0 ||
143
1.82M
           stats.bytes_read_from_peer != 0 || stats.remote_io_timer != 0 ||
144
1.82M
           stats.peer_io_timer != 0 || stats.remote_wait_timer != 0 ||
145
1.82M
           stats.write_cache_io_timer != 0 || stats.bytes_write_into_cache != 0 ||
146
1.82M
           stats.num_skip_cache_io_total != 0 || stats.read_cache_file_directly_timer != 0 ||
147
1.82M
           stats.cache_get_or_set_timer != 0 || stats.lock_wait_timer != 0 ||
148
1.82M
           stats.get_timer != 0 || stats.set_timer != 0 ||
149
1.82M
           stats.inverted_index_num_local_io_total != 0 ||
150
1.82M
           stats.inverted_index_num_remote_io_total != 0 ||
151
1.82M
           stats.inverted_index_num_peer_io_total != 0 ||
152
1.82M
           stats.inverted_index_bytes_read_from_local != 0 ||
153
1.82M
           stats.inverted_index_bytes_read_from_remote != 0 ||
154
1.82M
           stats.inverted_index_bytes_read_from_peer != 0 ||
155
1.82M
           stats.inverted_index_local_io_timer != 0 || stats.inverted_index_remote_io_timer != 0 ||
156
1.82M
           stats.inverted_index_peer_io_timer != 0 || stats.inverted_index_io_timer != 0;
157
1.82M
}
158
159
890k
Status OlapScanner::_prepare_impl() {
160
890k
    auto* local_state = static_cast<OlapScanLocalState*>(_local_state);
161
890k
    auto& tablet = _tablet_reader_params.tablet;
162
890k
    auto& tablet_schema = _tablet_reader_params.tablet_schema;
163
890k
    DBUG_EXECUTE_IF("CloudTablet.capture_rs_readers.return.e-230", {
164
890k
        LOG_WARNING("CloudTablet.capture_rs_readers.return e-230 init")
165
890k
                .tag("tablet_id", tablet->tablet_id());
166
890k
        return Status::Error<false>(-230, "injected error");
167
890k
    });
168
169
890k
    for (auto& ctx : local_state->_common_expr_ctxs_push_down) {
170
20.9k
        VExprContextSPtr context;
171
20.9k
        RETURN_IF_ERROR(ctx->clone(_state, context));
172
20.9k
        _common_expr_ctxs_push_down.emplace_back(context);
173
20.9k
        context->prepare_ann_range_search(_vector_search_params);
174
20.9k
    }
175
176
890k
    for (auto pair : local_state->_slot_id_to_virtual_column_expr) {
177
        // Scanner will be executed in a different thread, so we need to clone the context.
178
384
        VExprContextSPtr context;
179
384
        RETURN_IF_ERROR(pair.second->clone(_state, context));
180
384
        _slot_id_to_virtual_column_expr[pair.first] = context;
181
384
    }
182
183
890k
    _score_runtime = local_state->_score_runtime;
184
    // All scanners share the same ann_topn_runtime.
185
890k
    _ann_topn_runtime = local_state->_ann_topn_runtime;
186
187
    // set limit to reduce end of rowset and segment mem use
188
890k
    _tablet_reader = std::make_unique<BlockReader>();
189
    // batch size is passed down to segment iterator, use _state->batch_size()
190
    // instead of _parent->limit(), because if _parent->limit() is a very small
191
    // value (e.g. select a from t where a .. and b ... limit 1),
192
    // it will be very slow when reading data in segment iterator
193
890k
    _tablet_reader->set_batch_size(_state->batch_size());
194
    // Adaptive batch size: pass byte-budget settings to the storage reader.
195
    // The reader still uses batch_size() as the row ceiling.
196
890k
    _tablet_reader->set_preferred_block_size_bytes(_state->preferred_block_size_bytes());
197
890k
    {
198
890k
        TOlapScanNode& olap_scan_node = local_state->olap_scan_node();
199
890k
        TabletSchemaSPtr source_tablet_schema =
200
890k
                _tablet_reader_params.reader_type == ReaderType::READER_BINLOG
201
890k
                        ? tablet->row_binlog_tablet_schema()
202
890k
                        : tablet->tablet_schema();
203
204
890k
        tablet_schema = std::make_shared<TabletSchema>();
205
890k
        tablet_schema->copy_from(*source_tablet_schema);
206
890k
        if (olap_scan_node.__isset.columns_desc && !olap_scan_node.columns_desc.empty() &&
207
890k
            olap_scan_node.columns_desc[0].col_unique_id >= 0) {
208
890k
            tablet_schema->clear_columns();
209
13.7M
            for (const auto& column_desc : olap_scan_node.columns_desc) {
210
13.7M
                tablet_schema->append_column(TabletColumn(column_desc));
211
13.7M
            }
212
890k
            if (olap_scan_node.__isset.schema_version) {
213
890k
                tablet_schema->set_schema_version(olap_scan_node.schema_version);
214
890k
            }
215
890k
        }
216
890k
        if (olap_scan_node.__isset.indexes_desc) {
217
890k
            tablet_schema->update_indexes_from_thrift(olap_scan_node.indexes_desc);
218
890k
        }
219
220
890k
        if (_tablet_reader_params.rs_splits.empty()) {
221
            // Non-pipeline mode, Tablet : Scanner = 1 : 1
222
            // acquire tablet rowset readers at the beginning of the scan node
223
            // to prevent this case: when there are lots of olap scanners to run for example 10000
224
            // the rowsets maybe compacted when the last olap scanner starts
225
0
            ReadSource read_source;
226
227
0
            if (config::is_cloud_mode()) {
228
                // FIXME(plat1ko): Avoid pointer cast
229
0
                ExecEnv::GetInstance()->storage_engine().to_cloud().tablet_hotspot().count(*tablet);
230
0
            }
231
232
0
            auto maybe_read_source = tablet->capture_read_source(
233
0
                    _tablet_reader_params.version,
234
0
                    {
235
0
                            .skip_missing_versions = _state->skip_missing_version(),
236
0
                            .enable_fetch_rowsets_from_peers =
237
0
                                    config::enable_fetch_rowsets_from_peer_replicas,
238
0
                            .capture_row_binlog =
239
0
                                    _tablet_reader_params.reader_type == ReaderType::READER_BINLOG,
240
0
                            .enable_prefer_cached_rowset =
241
0
                                    config::is_cloud_mode() ? _state->enable_prefer_cached_rowset()
242
0
                                                            : false,
243
0
                            .query_freshness_tolerance_ms =
244
0
                                    config::is_cloud_mode() ? _state->query_freshness_tolerance_ms()
245
0
                                                            : -1,
246
0
                    });
247
0
            if (!maybe_read_source) {
248
0
                LOG(WARNING) << "fail to init reader. res=" << maybe_read_source.error();
249
0
                return maybe_read_source.error();
250
0
            }
251
0
            read_source = std::move(maybe_read_source.value());
252
253
0
            if (config::enable_mow_verbose_log && tablet->enable_unique_key_merge_on_write()) {
254
0
                LOG_INFO("finish capture_rs_readers for tablet={}, query_id={}",
255
0
                         tablet->tablet_id(), print_id(_state->query_id()));
256
0
            }
257
258
0
            if (!_state->skip_delete_predicate()) {
259
0
                read_source.fill_delete_predicates();
260
0
            }
261
0
            _tablet_reader_params.set_read_source(std::move(read_source));
262
0
        }
263
264
        // Initialize tablet_reader_params
265
890k
        RETURN_IF_ERROR(_init_tablet_reader_params(
266
890k
                local_state->_parent->cast<OlapScanOperatorX>()._slot_id_to_slot_desc, _key_ranges,
267
890k
                local_state->_slot_id_to_predicates, local_state->_push_down_functions));
268
890k
    }
269
270
    // add read columns in profile
271
890k
    if (_state->enable_profile()) {
272
4.05k
        _profile->add_info_string("ReadColumns",
273
4.05k
                                  read_columns_to_string(tablet_schema, _return_columns));
274
4.05k
    }
275
276
890k
    if (_tablet_reader_params.score_runtime) {
277
14
        SCOPED_TIMER(local_state->_statistics_collect_timer);
278
14
        _tablet_reader_params.collection_statistics = std::make_shared<CollectionStatistics>();
279
280
14
        io::IOContext io_ctx {
281
14
                .reader_type = _tablet_reader_params.reader_type,
282
14
                .expiration_time = tablet->ttl_seconds(),
283
14
                .query_id = &_state->query_id(),
284
14
                .file_cache_stats = &_tablet_reader->mutable_stats()->file_cache_stats,
285
14
                .is_inverted_index = true,
286
14
        };
287
288
14
        RETURN_IF_ERROR(_tablet_reader_params.collection_statistics->collect(
289
14
                _state, _tablet_reader_params.rs_splits, _tablet_reader_params.tablet_schema,
290
14
                _tablet_reader_params.common_expr_ctxs_push_down, &io_ctx));
291
14
    }
292
293
890k
    _has_prepared = true;
294
890k
    return Status::OK();
295
890k
}
296
297
889k
Status OlapScanner::_open_impl(RuntimeState* state) {
298
889k
    RETURN_IF_ERROR(Scanner::_open_impl(state));
299
889k
    SCOPED_TIMER(_local_state->cast<OlapScanLocalState>()._reader_init_timer);
300
301
889k
    auto res = _tablet_reader->init(_tablet_reader_params);
302
889k
    if (!res.ok()) {
303
        // init() also runs the eager first-row read that evaluates pushed-down expressions,
304
        // so res may be a data/expression error rather than a storage failure. Keep its own
305
        // message and only append the tablet/backend, without a misleading storage wording.
306
53
        res.append(". tablet=" + std::to_string(_tablet_reader_params.tablet->tablet_id()) +
307
53
                   ", backend=" + BackendOptions::get_localhost());
308
53
        return res;
309
53
    }
310
889k
    _tablet_reader->mutable_stats()->file_cache_stats.merge_from(_initial_file_cache_stats);
311
312
    // Do not hold rs_splits any more to release memory.
313
889k
    _tablet_reader_params.rs_splits.clear();
314
315
889k
    return Status::OK();
316
889k
}
317
318
// For binlog partition-based incremental read. Pushes down [start_tso, end_tso] range
319
// predicates onto the TSO column. If the TSO column is not already returned, pass it as
320
// a storage-only predicate column instead of widening scan output.
321
888k
Status OlapScanner::_init_tso_predicates() {
322
889k
    if (!_start_tso.has_value() && !_end_tso.has_value()) {
323
889k
        return Status::OK();
324
889k
    }
325
326
18.4E
    auto& tablet_schema = _tablet_reader_params.tablet_schema;
327
18.4E
    int32_t tso_index = _tablet_reader_params.reader_type == ReaderType::READER_BINLOG
328
18.4E
                                ? tablet_schema->binlog_timestamp_col_idx()
329
18.4E
                                : tablet_schema->commit_tso_col_idx();
330
18.4E
    const std::string& column_name = _tablet_reader_params.reader_type == ReaderType::READER_BINLOG
331
18.4E
                                             ? BINLOG_TIMESTAMP_COL
332
18.4E
                                             : COMMIT_TSO_COL;
333
18.4E
    if (tso_index < 0) {
334
0
        return Status::InternalError("Column {} not found in tablet schema after append",
335
0
                                     column_name);
336
0
    }
337
338
18.4E
    auto data_type = std::make_shared<DataTypeInt64>();
339
18.4E
    if (_start_tso.has_value()) {
340
0
        Field start_value = Field::create_field<TYPE_BIGINT>(*_start_tso);
341
0
        _tablet_reader_params.predicates.push_back(create_comparison_predicate<PredicateType::GT>(
342
0
                tso_index, column_name, data_type, start_value, false));
343
0
    }
344
18.4E
    if (_end_tso.has_value()) {
345
0
        Field end_value = Field::create_field<TYPE_BIGINT>(*_end_tso);
346
0
        _tablet_reader_params.predicates.push_back(create_comparison_predicate<PredicateType::LE>(
347
0
                tso_index, column_name, data_type, end_value, false));
348
0
    }
349
350
    // The storage-layer statistics fast path (VStatisticsIterator, picked when
351
    // push_down_agg_type is COUNT/MINMAX) bypasses SegmentIterator and returns raw
352
    // segment row counts without applying any column predicate. The commit-tso
353
    // predicate injected above is row-level, so the fast path would both miscount
354
    // (ignoring commit_tso <= snapshot_tso) and crash on a column-count DCHECK when
355
    // the tso predicate column is not in return_columns. Disable it here, matching
356
    // the binlog DETAIL/MIN_DELTA handling.
357
18.4E
    _tablet_reader_params.push_down_agg_type_opt = TPushAggOp::NONE;
358
359
18.4E
    if (std::find(_tablet_reader_params.return_columns.begin(),
360
18.4E
                  _tablet_reader_params.return_columns.end(),
361
18.4E
                  tso_index) == _tablet_reader_params.return_columns.end()) {
362
0
        _tablet_reader_params.tso_predicate_column_id = static_cast<ColumnId>(tso_index);
363
0
    }
364
365
18.4E
    return Status::OK();
366
18.4E
}
367
368
// it will be called under tablet read lock because capture rs readers need
369
Status OlapScanner::_init_tablet_reader_params(
370
        const phmap::flat_hash_map<int, SlotDescriptor*>& slot_id_to_slot_desc,
371
        const std::vector<OlapScanRange*>& key_ranges,
372
        const phmap::flat_hash_map<int, std::vector<std::shared_ptr<ColumnPredicate>>>&
373
                slot_to_predicates,
374
890k
        const std::vector<FunctionFilter>& function_filters) {
375
    // if the table with rowset [0-x] or [0-1] [2-y], and [0-1] is empty
376
890k
    const bool single_version = _tablet_reader_params.has_single_version();
377
378
890k
    auto* olap_local_state = static_cast<OlapScanLocalState*>(_local_state);
379
890k
    bool read_mor_as_dup = olap_local_state->olap_scan_node().__isset.read_mor_as_dup &&
380
890k
                           olap_local_state->olap_scan_node().read_mor_as_dup;
381
890k
    if (_state->skip_storage_engine_merge() || read_mor_as_dup) {
382
49
        _tablet_reader_params.direct_mode = true;
383
49
        _tablet_reader_params.aggregation = true;
384
890k
    } else {
385
890k
        auto push_down_agg_type = _local_state->get_push_down_agg_type();
386
890k
        _tablet_reader_params.direct_mode = _tablet_reader_params.aggregation || single_version ||
387
890k
                                            (push_down_agg_type != TPushAggOp::NONE &&
388
10.2k
                                             push_down_agg_type != TPushAggOp::COUNT_ON_INDEX);
389
890k
    }
390
391
890k
    RETURN_IF_ERROR(_init_variant_columns());
392
890k
    RETURN_IF_ERROR(_init_return_columns());
393
394
890k
    _tablet_reader_params.push_down_agg_type_opt = _local_state->get_push_down_agg_type();
395
396
    // Binlog DETAIL/MIN_DELTA scans widen `return_columns` with key/op/lsn/before
397
    // columns to drive the row-level merge in BlockReader. The storage-layer
398
    // statistics fast path (VStatisticsIterator, picked when push_down_agg_type
399
    // is COUNT/MINMAX) bypasses SegmentIterator entirely, returning raw segment
400
    // row counts without binlog op filtering and with a schema that does not
401
    // match the widened read schema. The result is both wrong (raw segment
402
    // count != binlog row count) and unsafe (column-count DCHECK fires inside
403
    // VStatisticsIterator::next_batch). Disable the fast path for these scans.
404
890k
    if (_tablet_reader_params.binlog_scan_type == TBinlogScanType::DETAIL ||
405
890k
        _tablet_reader_params.binlog_scan_type == TBinlogScanType::MIN_DELTA) {
406
0
        _tablet_reader_params.push_down_agg_type_opt = TPushAggOp::NONE;
407
0
    }
408
409
890k
    _tablet_reader_params.common_expr_ctxs_push_down = _common_expr_ctxs_push_down;
410
890k
    _tablet_reader_params.virtual_column_exprs = _virtual_column_exprs;
411
890k
    _tablet_reader_params.score_runtime = _score_runtime;
412
890k
    _tablet_reader_params.output_columns = ((OlapScanLocalState*)_local_state)->_output_column_ids;
413
890k
    _tablet_reader_params.ann_topn_runtime = _ann_topn_runtime;
414
890k
    for (const auto& ele : ((OlapScanLocalState*)_local_state)->_cast_types_for_variants) {
415
1.40k
        _tablet_reader_params.target_cast_type_for_variants[ele.first] = ele.second;
416
1.40k
    };
417
890k
    auto& tablet_schema = _tablet_reader_params.tablet_schema;
418
6.17M
    for (auto& predicates : slot_to_predicates) {
419
6.17M
        const int sid = predicates.first;
420
6.17M
        DCHECK(slot_id_to_slot_desc.contains(sid));
421
6.17M
        int32_t index =
422
6.17M
                tablet_schema->field_index(slot_id_to_slot_desc.find(sid)->second->col_name());
423
6.17M
        if (index < 0) {
424
0
            throw Exception(
425
0
                    Status::InternalError("Column {} not found in tablet schema",
426
0
                                          slot_id_to_slot_desc.find(sid)->second->col_name()));
427
0
        }
428
6.17M
        for (auto& predicate : predicates.second) {
429
662k
            _tablet_reader_params.predicates.push_back(predicate->clone(index));
430
662k
        }
431
6.17M
    }
432
433
890k
    std::copy(function_filters.cbegin(), function_filters.cend(),
434
890k
              std::inserter(_tablet_reader_params.function_filters,
435
890k
                            _tablet_reader_params.function_filters.begin()));
436
437
    // Merge the columns in delete predicate that not in latest schema in to current tablet schema
438
890k
    for (auto& del_pred : _tablet_reader_params.delete_predicates) {
439
7.19k
        tablet_schema->merge_dropped_columns(*del_pred->tablet_schema());
440
7.19k
    }
441
442
    // Push key ranges to the tablet reader.
443
    // Skip the "full scan" placeholder (has_lower_bound == false) — when no key
444
    // predicates exist, start_key/end_key remain empty and the reader does a full scan.
445
1.53M
    for (auto* key_range : key_ranges) {
446
1.53M
        if (!key_range->has_lower_bound) {
447
135k
            continue;
448
135k
        }
449
450
1.39M
        _tablet_reader_params.start_key_include = key_range->begin_include;
451
1.39M
        _tablet_reader_params.end_key_include = key_range->end_include;
452
453
1.39M
        _tablet_reader_params.start_key.push_back(key_range->begin_scan_range);
454
1.39M
        _tablet_reader_params.end_key.push_back(key_range->end_scan_range);
455
1.39M
    }
456
457
890k
    _tablet_reader_params.profile = _local_state->custom_profile();
458
890k
    _tablet_reader_params.runtime_state = _state;
459
460
890k
    _tablet_reader_params.origin_return_columns = &_return_columns;
461
890k
    _tablet_reader_params.tablet_columns_convert_to_null_set = &_tablet_columns_convert_to_null_set;
462
463
890k
    auto add_return_column_if_absent = [&](uint32_t cid) {
464
0
        if (std::find(_tablet_reader_params.return_columns.begin(),
465
0
                      _tablet_reader_params.return_columns.end(),
466
0
                      cid) == _tablet_reader_params.return_columns.end()) {
467
0
            _tablet_reader_params.return_columns.push_back(cid);
468
0
        }
469
0
    };
470
471
    // For row-binlog scans that emit BEFORE/AFTER pairs (MIN_DELTA / DETAIL), we must read
472
    // every key column, every requested value column, the binlog meta columns (op / lsn /
473
    // tso) and their __BEFORE__ mirrors, so the BlockReader can reconstruct change rows.
474
890k
    const bool need_before_columns =
475
890k
            _tablet_reader_params.binlog_scan_type == TBinlogScanType::MIN_DELTA ||
476
890k
            _tablet_reader_params.binlog_scan_type == TBinlogScanType::DETAIL;
477
890k
    if (need_before_columns) {
478
0
        for (size_t i = 0; i < tablet_schema->num_key_columns(); ++i) {
479
0
            add_return_column_if_absent(static_cast<uint32_t>(i));
480
0
        }
481
0
        for (auto cid : _return_columns) {
482
0
            add_return_column_if_absent(cid);
483
0
        }
484
485
0
        if (int32_t op_idx = tablet_schema->field_index(std::string(kRowBinlogOpColName));
486
0
            op_idx >= 0) {
487
0
            add_return_column_if_absent(static_cast<uint32_t>(op_idx));
488
0
        }
489
0
        if (int32_t lsn_idx = tablet_schema->binlog_lsn_col_idx(); lsn_idx >= 0) {
490
0
            add_return_column_if_absent(static_cast<uint32_t>(lsn_idx));
491
0
        }
492
493
0
        for (auto cid : _return_columns) {
494
0
            if (cid >= tablet_schema->num_key_columns()) {
495
0
                const auto& col_name = tablet_schema->column(cid).name();
496
0
                std::string before_col_name;
497
0
                before_col_name.append("__BEFORE__");
498
0
                before_col_name.append(col_name);
499
0
                before_col_name.append("__");
500
0
                if (int32_t before_idx = tablet_schema->field_index(before_col_name);
501
0
                    before_idx >= 0) {
502
0
                    add_return_column_if_absent(static_cast<uint32_t>(before_idx));
503
0
                }
504
0
            }
505
0
        }
506
890k
    } else if (_tablet_reader_params.direct_mode) {
507
879k
        _tablet_reader_params.return_columns = _return_columns;
508
879k
    } else {
509
        // we need to fetch all key columns to do the right aggregation on storage engine side.
510
38.4k
        for (size_t i = 0; i < tablet_schema->num_key_columns(); ++i) {
511
27.3k
            _tablet_reader_params.return_columns.push_back(i);
512
27.3k
        }
513
58.3k
        for (auto index : _return_columns) {
514
58.3k
            if (tablet_schema->column(index).is_key()) {
515
27.2k
                continue;
516
27.2k
            }
517
31.0k
            _tablet_reader_params.return_columns.push_back(index);
518
31.0k
        }
519
        // expand the sequence column
520
11.1k
        if (tablet_schema->has_sequence_col() || tablet_schema->has_seq_map()) {
521
40
            bool has_replace_col = false;
522
91
            for (auto col : _return_columns) {
523
91
                if (tablet_schema->column(col).aggregation() ==
524
91
                    FieldAggregationMethod::OLAP_FIELD_AGGREGATION_REPLACE) {
525
40
                    has_replace_col = true;
526
40
                    break;
527
40
                }
528
91
            }
529
40
            if (auto sequence_col_idx = tablet_schema->sequence_col_idx();
530
40
                has_replace_col && tablet_schema->has_sequence_col() &&
531
40
                std::find(_return_columns.begin(), _return_columns.end(), sequence_col_idx) ==
532
28
                        _return_columns.end()) {
533
15
                _tablet_reader_params.return_columns.push_back(sequence_col_idx);
534
15
            }
535
40
            if (has_replace_col) {
536
39
                const auto& val_to_seq = tablet_schema->value_col_idx_to_seq_col_idx();
537
39
                std::set<uint32_t> return_seq_columns;
538
539
235
                for (auto col : _tablet_reader_params.return_columns) {
540
                    // we need to add the necessary sequence column in _return_columns, and
541
                    // Avoid adding the same seq column twice
542
235
                    const auto val_iter = val_to_seq.find(col);
543
235
                    if (val_iter != val_to_seq.end()) {
544
42
                        auto seq = val_iter->second;
545
42
                        if (std::find(_tablet_reader_params.return_columns.begin(),
546
42
                                      _tablet_reader_params.return_columns.end(),
547
42
                                      seq) == _tablet_reader_params.return_columns.end()) {
548
4
                            return_seq_columns.insert(seq);
549
4
                        }
550
42
                    }
551
235
                }
552
39
                _tablet_reader_params.return_columns.insert(
553
39
                        std::end(_tablet_reader_params.return_columns),
554
39
                        std::begin(return_seq_columns), std::end(return_seq_columns));
555
39
            }
556
40
        }
557
11.1k
    }
558
559
890k
    RETURN_IF_ERROR(_init_tso_predicates());
560
561
    // For any row-binlog scan, force the storage layer to deliver rows strictly in primary-key
562
    // order so the BlockReader can group consecutive same-key changes (MIN_DELTA) or emit
563
    // BEFORE/AFTER pairs in deterministic order (DETAIL). Disable ORDER BY / TopN pushdowns
564
    // and reset their related params, since they would otherwise re-order the stream.
565
890k
    if (_tablet_reader_params.binlog_scan_type != TBinlogScanType::NONE) {
566
0
        _tablet_reader_params.read_orderby_key = true;
567
0
        _tablet_reader_params.read_orderby_key_reverse = false;
568
0
        _tablet_reader_params.read_orderby_key_num_prefix_columns = 0;
569
0
        _tablet_reader_params.read_orderby_key_limit = 0;
570
0
        _tablet_reader_params.force_key_ordered_read = true;
571
0
        _tablet_reader_params.topn_filter_source_node_ids.clear();
572
0
    }
573
574
890k
    _tablet_reader_params.use_page_cache = _state->enable_page_cache();
575
576
890k
    DBUG_EXECUTE_IF("NewOlapScanner::_init_tablet_reader_params.block", DBUG_BLOCK);
577
578
890k
    if (!_state->skip_storage_engine_merge()) {
579
889k
        auto* olap_scan_local_state = (OlapScanLocalState*)_local_state;
580
889k
        TOlapScanNode& olap_scan_node = olap_scan_local_state->olap_scan_node();
581
582
        // Set MOR value predicate pushdown flag
583
889k
        if (olap_scan_node.__isset.enable_mor_value_predicate_pushdown &&
584
889k
            olap_scan_node.enable_mor_value_predicate_pushdown) {
585
25
            _tablet_reader_params.enable_mor_value_predicate_pushdown = true;
586
25
        }
587
588
889k
        const bool has_key_topn =
589
889k
                olap_scan_node.__isset.sort_info && !olap_scan_node.sort_info.is_asc_order.empty();
590
889k
        if (has_key_topn) {
591
3.87k
            _limit = _local_state->limit_per_scanner();
592
3.87k
        }
593
594
889k
        const bool no_runtime_filters = _total_rf_num == 0;
595
889k
        const bool segment_limit_enabled = _state->enable_segment_limit_pushdown();
596
889k
        const bool storage_no_merge = olap_scan_local_state->_storage_no_merge();
597
598
889k
        if (_limit > 0 && no_runtime_filters && segment_limit_enabled && storage_no_merge) {
599
1.70k
            for (const auto& conjunct : _conjuncts) {
600
0
                DORIS_CHECK(!olap_scan_local_state->_check_expr_storage_filter(
601
0
                        conjunct->root(), OlapScanLocalState::ExprStorageFilterCheckMode::
602
0
                                                  HAS_SEGMENT_EVALUABLE_EXPR));
603
0
            }
604
1.70k
        }
605
606
        // Segment LIMIT has only two legal states: completely disabled, or enabled after every
607
        // row-filtering conjunct has become a storage predicate or SegmentIterator common expr.
608
889k
        const bool can_push_down_segment_limit = _limit > 0 && no_runtime_filters &&
609
889k
                                                 _conjuncts.empty() && segment_limit_enabled &&
610
889k
                                                 storage_no_merge;
611
889k
        if (can_push_down_segment_limit) {
612
1.70k
            if (has_key_topn) {
613
1.38k
                _tablet_reader_params.read_orderby_key = true;
614
1.38k
                if (!olap_scan_node.sort_info.is_asc_order[0]) {
615
213
                    _tablet_reader_params.read_orderby_key_reverse = true;
616
213
                }
617
1.38k
                _tablet_reader_params.read_orderby_key_num_prefix_columns =
618
1.38k
                        olap_scan_node.sort_info.is_asc_order.size();
619
1.38k
                _tablet_reader_params.read_orderby_key_limit = _limit;
620
1.38k
            } else {
621
321
                _tablet_reader_params.general_read_limit = _limit;
622
321
            }
623
1.70k
        }
624
625
889k
        if (_tablet_reader_params.read_orderby_key_limit > 0 ||
626
889k
            _tablet_reader_params.general_read_limit > 0) {
627
1.69k
            DORIS_CHECK(can_push_down_segment_limit);
628
1.69k
            DORIS_CHECK(_conjuncts.empty());
629
1.69k
        }
630
631
        // A key TopN scan cannot share the plain LIMIT early-stop counter. If
632
        // storage TopN is pushed down, each scanner must produce its full local
633
        // candidates. If it is not pushed down for any reason, the upper TopN
634
        // still needs all rows from the scan.
635
889k
        if (has_key_topn) {
636
3.89k
            _shared_scan_limit = nullptr;
637
3.89k
            if (_tablet_reader_params.read_orderby_key_limit == 0) {
638
2.51k
                _limit = -1;
639
2.51k
            }
640
3.89k
        }
641
        // Note: _shared_scan_limit is intentionally not pushed into the
642
        // storage layer. SegmentIterator's _process_eof() is irreversible,
643
        // so a concurrently-decremented atomic could reach 0 while a segment
644
        // still has data needed by other scanners.
645
646
        // set push down topn filter
647
889k
        _tablet_reader_params.topn_filter_source_node_ids =
648
889k
                olap_scan_local_state->get_topn_filter_source_node_ids(_state, true);
649
889k
        if (!_tablet_reader_params.topn_filter_source_node_ids.empty()) {
650
6.01k
            _tablet_reader_params.topn_filter_target_node_id =
651
6.01k
                    olap_scan_local_state->parent()->node_id();
652
6.01k
        }
653
889k
    }
654
655
    // If this is a Two-Phase read query, and we need to delay the release of Rowset
656
    // by rowset->update_delayed_expired_timestamp().This could expand the lifespan of Rowset
657
890k
    if (tablet_schema->field_index(BeConsts::ROWID_COL) >= 0) {
658
0
        constexpr static int delayed_s = 60;
659
0
        for (auto rs_reader : _tablet_reader_params.rs_splits) {
660
0
            uint64_t delayed_expired_timestamp =
661
0
                    UnixSeconds() + _tablet_reader_params.runtime_state->execution_timeout() +
662
0
                    delayed_s;
663
0
            rs_reader.rs_reader->rowset()->update_delayed_expired_timestamp(
664
0
                    delayed_expired_timestamp);
665
0
            ExecEnv::GetInstance()->storage_engine().add_quering_rowset(
666
0
                    rs_reader.rs_reader->rowset());
667
0
        }
668
0
    }
669
670
890k
    if (tablet_schema->has_global_row_id()) {
671
8.24k
        auto& id_file_map = _state->get_id_file_map();
672
15.6k
        for (auto rs_reader : _tablet_reader_params.rs_splits) {
673
15.6k
            id_file_map->add_temp_rowset(rs_reader.rs_reader->rowset());
674
15.6k
        }
675
8.24k
    }
676
677
890k
    return Status::OK();
678
890k
}
679
680
889k
Status OlapScanner::_init_variant_columns() {
681
889k
    auto& tablet_schema = _tablet_reader_params.tablet_schema;
682
889k
    if (tablet_schema->num_variant_columns() == 0) {
683
883k
        return Status::OK();
684
883k
    }
685
    // Parent column has path info to distinction from each other
686
15.2k
    for (auto* slot : _output_tuple_desc->slots()) {
687
15.2k
        if (slot->type()->get_primitive_type() == PrimitiveType::TYPE_VARIANT) {
688
            // Such columns are not exist in frontend schema info, so we need to
689
            // add them into tablet_schema for later column indexing.
690
7.03k
            const auto& dt_variant =
691
7.03k
                    assert_cast<const DataTypeVariant&>(*remove_nullable(slot->type()));
692
7.03k
            TabletColumn subcol = TabletColumn::create_materialized_variant_column(
693
7.03k
                    tablet_schema->column_by_uid(slot->col_unique_id()).name_lower_case(),
694
7.03k
                    slot->column_paths(), slot->col_unique_id(),
695
7.03k
                    dt_variant.variant_max_subcolumns_count(), dt_variant.enable_doc_mode());
696
7.03k
            if (tablet_schema->field_index(*subcol.path_info_ptr()) < 0) {
697
5.46k
                tablet_schema->append_column(subcol, TabletSchema::ColumnType::VARIANT);
698
5.46k
            }
699
7.03k
        }
700
15.2k
    }
701
6.11k
    variant_util::inherit_column_attributes(tablet_schema);
702
6.11k
    return Status::OK();
703
889k
}
704
705
889k
Status OlapScanner::_init_return_columns() {
706
    // For OLAP scan, _output_tuple_desc is the storage-aligned scan tuple
707
    // descriptor. extra_key_column_slot_ids marks extra key slots that are
708
    // present only for scan-schema alignment. For example, on an AGG table with
709
    // keys (k1, k2), a query returning only k2 may still scan (k1, k2); k1 is
710
    // an extra column and can be removed by the projection output tuple.
711
8.08M
    for (auto* slot : _output_tuple_desc->slots()) {
712
        // variant column using path to index a column
713
8.08M
        int32_t index = 0;
714
8.08M
        auto& tablet_schema = _tablet_reader_params.tablet_schema;
715
8.08M
        if (slot->type()->get_primitive_type() == PrimitiveType::TYPE_VARIANT) {
716
7.05k
            index = tablet_schema->field_index(PathInData(
717
7.05k
                    tablet_schema->column_by_uid(slot->col_unique_id()).name_lower_case(),
718
7.05k
                    slot->column_paths()));
719
8.07M
        } else {
720
8.08M
            index = slot->col_unique_id() >= 0 ? tablet_schema->field_index(slot->col_unique_id())
721
18.4E
                                               : tablet_schema->field_index(slot->col_name());
722
8.07M
        }
723
724
8.08M
        if (index < 0) {
725
0
            return Status::InternalError(
726
0
                    "field name is invalid. field={}, field_name_to_index={}, col_unique_id={}",
727
0
                    slot->col_name(), tablet_schema->get_all_field_names(), slot->col_unique_id());
728
0
        }
729
730
8.08M
        if (slot->get_virtual_column_expr()) {
731
380
            _virtual_column_exprs[index] = _slot_id_to_virtual_column_expr[slot->id()];
732
733
380
            VLOG_DEBUG << fmt::format("Virtual column, slot id: {}, cid {}, type: {}", slot->id(),
734
3
                                      index, slot->get_data_type_ptr()->get_name());
735
380
        }
736
737
8.08M
        const auto& column = tablet_schema->column(index);
738
8.08M
        auto* olap_local_state = static_cast<OlapScanLocalState*>(_local_state);
739
8.08M
        const auto& olap_scan_node = olap_local_state->olap_scan_node();
740
8.08M
        if (olap_scan_node.__isset.extra_key_column_slot_ids &&
741
8.08M
            olap_scan_node.extra_key_column_slot_ids.contains(slot->id())) {
742
127k
            DORIS_CHECK(column.is_key());
743
127k
            if (_tablet_reader_params.direct_mode) {
744
                // Direct readers can synthesize extra storage keys because they are only
745
                // placeholders before the scan projection removes them. Merge/aggregation
746
                // readers must still read real key values to preserve storage semantics.
747
118k
                _tablet_reader_params.extra_columns.insert(index);
748
118k
            }
749
127k
        }
750
8.08M
        int32_t unique_id =
751
18.4E
                column.unique_id() >= 0 ? column.unique_id() : column.parent_unique_id();
752
8.08M
        if (!slot->all_access_paths().empty()) {
753
67.0k
            _tablet_reader_params.all_access_paths.insert({unique_id, slot->all_access_paths()});
754
67.0k
        }
755
756
8.08M
        if (!slot->predicate_access_paths().empty()) {
757
6.83k
            _tablet_reader_params.predicate_access_paths.insert(
758
6.83k
                    {unique_id, slot->predicate_access_paths()});
759
6.83k
        }
760
761
8.08M
        if ((slot->type()->get_primitive_type() == PrimitiveType::TYPE_STRUCT ||
762
8.09M
             slot->type()->get_primitive_type() == PrimitiveType::TYPE_MAP ||
763
8.08M
             slot->type()->get_primitive_type() == PrimitiveType::TYPE_ARRAY) &&
764
8.08M
            !slot->all_access_paths().empty()) {
765
59.9k
            tablet_schema->add_pruned_columns_data_type(column.unique_id(), slot->type());
766
59.9k
        }
767
768
8.08M
        _return_columns.push_back(index);
769
8.08M
        if (slot->is_nullable() && !tablet_schema->column(index).is_nullable()) {
770
0
            _tablet_columns_convert_to_null_set.emplace(index);
771
8.08M
        } else if (!slot->is_nullable() && tablet_schema->column(index).is_nullable()) {
772
0
            return Status::Error<ErrorCode::INVALID_SCHEMA>(
773
0
                    "slot(id: {}, name: {})'s nullable does not match "
774
0
                    "column(tablet id: {}, index: {}, name: {}) ",
775
0
                    slot->id(), slot->col_name(), tablet_schema->table_id(), index,
776
0
                    tablet_schema->column(index).name());
777
0
        }
778
8.08M
    }
779
780
889k
    if (_return_columns.empty()) {
781
0
        return Status::InternalError("failed to build storage scanner, no materialized slot!");
782
0
    }
783
784
889k
    return Status::OK();
785
889k
}
786
787
1.87M
bool OlapScanner::check_partition_pruned() const {
788
1.87M
    if (!_local_state) {
789
0
        return false;
790
0
    }
791
1.87M
    return _local_state->is_partition_pruned(_tablet_reader_params.tablet->partition_id());
792
1.87M
}
793
794
938k
doris::TabletStorageType OlapScanner::get_storage_type() {
795
938k
    if (config::is_cloud_mode()) {
796
        // we don't have cold storage in cloud mode, all storage is treated as local
797
936k
        return doris::TabletStorageType::STORAGE_TYPE_LOCAL;
798
936k
    }
799
2.29k
    int local_reader = 0;
800
5.16k
    for (const auto& reader : _tablet_reader_params.rs_splits) {
801
5.16k
        local_reader += reader.rs_reader->rowset()->is_local();
802
5.16k
    }
803
2.29k
    int total_reader = _tablet_reader_params.rs_splits.size();
804
805
2.29k
    if (local_reader == total_reader) {
806
2.29k
        return doris::TabletStorageType::STORAGE_TYPE_LOCAL;
807
2.29k
    } else if (local_reader == 0) {
808
0
        return doris::TabletStorageType::STORAGE_TYPE_REMOTE;
809
0
    }
810
0
    return doris::TabletStorageType::STORAGE_TYPE_REMOTE_AND_LOCAL;
811
2.29k
}
812
813
1.14M
Status OlapScanner::_get_block_impl(RuntimeState* state, Block* block, bool* eof) {
814
    // Read one block from block reader
815
    // ATTN: Here we need to let the _get_block_impl method guarantee the semantics of the interface,
816
    // that is, eof can be set to true only when the returned block is empty.
817
1.14M
    RETURN_IF_ERROR(_tablet_reader->next_block_with_aggregation(block, eof));
818
1.14M
    if (block->rows() > 0) {
819
258k
        _tablet_reader_params.tablet->read_block_count.fetch_add(1, std::memory_order_relaxed);
820
258k
        *eof = false;
821
258k
    }
822
1.14M
#ifndef NDEBUG
823
1.14M
    RETURN_IF_ERROR(_check_ann_cache_hit_debug_points(_tablet_reader->stats()));
824
1.14M
#endif
825
1.14M
    return Status::OK();
826
1.14M
}
827
828
897k
Status OlapScanner::close(RuntimeState* state) {
829
897k
    if (!_try_close()) {
830
150
        return Status::OK();
831
150
    }
832
897k
    RETURN_IF_ERROR(Scanner::close(state));
833
897k
    return Status::OK();
834
897k
}
835
836
935k
void OlapScanner::update_realtime_counters() {
837
935k
    if (!_has_prepared) {
838
        // Counter update need prepare successfully, or it maybe core. For example, olap scanner
839
        // will open tablet reader during prepare, if not prepare successfully, tablet reader == nullptr.
840
0
        return;
841
0
    }
842
935k
    OlapScanLocalState* local_state = static_cast<OlapScanLocalState*>(_local_state);
843
935k
    const OlapReaderStatistics& stats = _tablet_reader->stats();
844
935k
    COUNTER_UPDATE(local_state->_read_compressed_counter, stats.compressed_bytes_read);
845
935k
    COUNTER_UPDATE(local_state->_read_uncompressed_counter, stats.uncompressed_bytes_read);
846
935k
    COUNTER_UPDATE(local_state->_scan_bytes, stats.uncompressed_bytes_read);
847
935k
    COUNTER_UPDATE(local_state->_scan_rows, stats.raw_rows_read);
848
849
    // Make sure the scan bytes and scan rows counter in audit log is the same as the counter in
850
    // doris metrics.
851
    // ScanBytes is the uncompressed bytes read from local + remote
852
    // bytes_read_from_local is the compressed bytes read from local
853
    // bytes_read_from_remote is the compressed bytes read from remote
854
    // scan bytes > bytes_read_from_local + bytes_read_from_remote
855
935k
    _state->get_query_ctx()->resource_ctx()->io_context()->update_scan_rows(stats.raw_rows_read);
856
935k
    _state->get_query_ctx()->resource_ctx()->io_context()->update_scan_bytes(
857
935k
            stats.uncompressed_bytes_read);
858
859
    // In case of no cache, we still need to update the IO stats. uncompressed bytes read == local + remote
860
935k
    if (stats.file_cache_stats.bytes_read_from_local == 0 &&
861
935k
        stats.file_cache_stats.bytes_read_from_remote == 0) {
862
845k
        _state->get_query_ctx()->resource_ctx()->io_context()->update_scan_bytes_from_local_storage(
863
845k
                stats.compressed_bytes_read);
864
845k
        DorisMetrics::instance()->query_scan_bytes_from_local->increment(
865
845k
                stats.compressed_bytes_read);
866
845k
    } else {
867
90.4k
        _state->get_query_ctx()->resource_ctx()->io_context()->update_scan_bytes_from_local_storage(
868
90.4k
                stats.file_cache_stats.bytes_read_from_local);
869
90.4k
        _state->get_query_ctx()
870
90.4k
                ->resource_ctx()
871
90.4k
                ->io_context()
872
90.4k
                ->update_scan_bytes_from_remote_storage(
873
90.4k
                        stats.file_cache_stats.bytes_read_from_remote);
874
875
90.4k
        DorisMetrics::instance()->query_scan_bytes_from_local->increment(
876
90.4k
                stats.file_cache_stats.bytes_read_from_local);
877
90.4k
        DorisMetrics::instance()->query_scan_bytes_from_remote->increment(
878
90.4k
                stats.file_cache_stats.bytes_read_from_remote);
879
90.4k
    }
880
881
935k
    if (has_file_cache_statistics(stats.file_cache_stats)) {
882
92.4k
        io::FileCacheProfileReporter cache_profile(local_state->_segment_profile.get());
883
92.4k
        cache_profile.update(&stats.file_cache_stats);
884
92.4k
        _state->get_query_ctx()->resource_ctx()->io_context()->update_bytes_write_into_cache(
885
92.4k
                stats.file_cache_stats.bytes_write_into_cache);
886
92.4k
    }
887
888
935k
    _tablet_reader->mutable_stats()->compressed_bytes_read = 0;
889
935k
    _tablet_reader->mutable_stats()->uncompressed_bytes_read = 0;
890
935k
    _tablet_reader->mutable_stats()->raw_rows_read = 0;
891
935k
    _tablet_reader->mutable_stats()->file_cache_stats = {};
892
935k
}
893
894
888k
void OlapScanner::_collect_profile_before_close() {
895
    //  Please don't directly enable the profile here, we need to set QueryStatistics using the counter inside.
896
888k
    if (_has_updated_counter) {
897
0
        return;
898
0
    }
899
888k
    _has_updated_counter = true;
900
888k
    _tablet_reader->update_profile(_profile);
901
902
888k
    Scanner::_collect_profile_before_close();
903
904
    // Update counters for OlapScanner
905
    // Update counters from tablet reader's stats
906
888k
    auto& stats = _tablet_reader->stats();
907
888k
    auto* local_state = (OlapScanLocalState*)_local_state;
908
888k
    COUNTER_UPDATE(local_state->_io_timer, stats.io_ns);
909
888k
    COUNTER_UPDATE(local_state->_read_compressed_counter, stats.compressed_bytes_read);
910
888k
    COUNTER_UPDATE(local_state->_scan_bytes, stats.uncompressed_bytes_read);
911
888k
    COUNTER_UPDATE(local_state->_decompressor_timer, stats.decompress_ns);
912
888k
    COUNTER_UPDATE(local_state->_read_uncompressed_counter, stats.uncompressed_bytes_read);
913
888k
    COUNTER_UPDATE(local_state->_block_load_timer, stats.block_load_ns);
914
888k
    COUNTER_UPDATE(local_state->_block_load_counter, stats.blocks_load);
915
888k
    COUNTER_UPDATE(local_state->_block_fetch_timer, stats.block_fetch_ns);
916
888k
    COUNTER_UPDATE(local_state->_delete_bitmap_get_agg_timer, stats.delete_bitmap_get_agg_ns);
917
888k
    COUNTER_UPDATE(local_state->_scan_rows, stats.raw_rows_read);
918
888k
    COUNTER_UPDATE(local_state->_vec_cond_timer, stats.vec_cond_ns);
919
888k
    COUNTER_UPDATE(local_state->_short_cond_timer, stats.short_cond_ns);
920
888k
    COUNTER_UPDATE(local_state->_expr_filter_timer, stats.expr_filter_ns);
921
888k
    COUNTER_UPDATE(local_state->_block_init_timer, stats.block_init_ns);
922
888k
    COUNTER_UPDATE(local_state->_block_init_seek_timer, stats.block_init_seek_ns);
923
888k
    COUNTER_UPDATE(local_state->_block_init_seek_counter, stats.block_init_seek_num);
924
888k
    COUNTER_UPDATE(local_state->_segment_generate_row_range_by_keys_timer,
925
888k
                   stats.generate_row_ranges_by_keys_ns);
926
888k
    COUNTER_UPDATE(local_state->_segment_generate_row_range_by_column_conditions_timer,
927
888k
                   stats.generate_row_ranges_by_column_conditions_ns);
928
888k
    COUNTER_UPDATE(local_state->_segment_generate_row_range_by_bf_timer,
929
888k
                   stats.generate_row_ranges_by_bf_ns);
930
888k
    COUNTER_UPDATE(local_state->_collect_iterator_merge_next_timer,
931
888k
                   stats.collect_iterator_merge_next_timer);
932
888k
    COUNTER_UPDATE(local_state->_segment_generate_row_range_by_zonemap_timer,
933
888k
                   stats.generate_row_ranges_by_zonemap_ns);
934
888k
    COUNTER_UPDATE(local_state->_segment_generate_row_range_by_dict_timer,
935
888k
                   stats.generate_row_ranges_by_dict_ns);
936
888k
    COUNTER_UPDATE(local_state->_predicate_column_read_timer, stats.predicate_column_read_ns);
937
888k
    COUNTER_UPDATE(local_state->_non_predicate_column_read_timer, stats.non_predicate_read_ns);
938
888k
    COUNTER_UPDATE(local_state->_predicate_column_read_seek_timer,
939
888k
                   stats.predicate_column_read_seek_ns);
940
888k
    COUNTER_UPDATE(local_state->_predicate_column_read_seek_counter,
941
888k
                   stats.predicate_column_read_seek_num);
942
888k
    COUNTER_UPDATE(local_state->_lazy_read_timer, stats.lazy_read_ns);
943
888k
    COUNTER_UPDATE(local_state->_lazy_read_pruned_timer, stats.lazy_read_pruned_ns);
944
888k
    COUNTER_UPDATE(local_state->_lazy_read_seek_timer, stats.block_lazy_read_seek_ns);
945
888k
    COUNTER_UPDATE(local_state->_lazy_read_seek_counter, stats.block_lazy_read_seek_num);
946
888k
    COUNTER_UPDATE(local_state->_output_col_timer, stats.output_col_ns);
947
888k
    COUNTER_UPDATE(local_state->_rows_vec_cond_filtered_counter, stats.rows_vec_cond_filtered);
948
888k
    COUNTER_UPDATE(local_state->_rows_short_circuit_cond_filtered_counter,
949
888k
                   stats.rows_short_circuit_cond_filtered);
950
888k
    COUNTER_UPDATE(local_state->_rows_expr_cond_filtered_counter, stats.rows_expr_cond_filtered);
951
888k
    COUNTER_UPDATE(local_state->_rows_vec_cond_input_counter, stats.vec_cond_input_rows);
952
888k
    COUNTER_UPDATE(local_state->_rows_short_circuit_cond_input_counter,
953
888k
                   stats.short_circuit_cond_input_rows);
954
888k
    COUNTER_UPDATE(local_state->_rows_expr_cond_input_counter, stats.expr_cond_input_rows);
955
888k
    COUNTER_UPDATE(local_state->_stats_filtered_counter, stats.rows_stats_filtered);
956
888k
    COUNTER_UPDATE(local_state->_stats_rp_filtered_counter, stats.rows_stats_rp_filtered);
957
888k
    COUNTER_UPDATE(local_state->_expr_zonemap_filtered_segment_counter,
958
888k
                   stats.expr_zonemap_filtered_segments);
959
888k
    COUNTER_UPDATE(local_state->_expr_zonemap_filtered_page_counter,
960
888k
                   stats.expr_zonemap_filtered_pages);
961
888k
    COUNTER_UPDATE(local_state->_expr_zonemap_unusable_counter, stats.expr_zonemap_unusable_evals);
962
888k
    COUNTER_UPDATE(local_state->_in_zonemap_point_check_counter,
963
888k
                   stats.in_zonemap_point_check_count);
964
888k
    COUNTER_UPDATE(local_state->_in_zonemap_range_only_counter, stats.in_zonemap_range_only_count);
965
888k
    COUNTER_UPDATE(local_state->_dict_filtered_counter, stats.segment_dict_filtered);
966
888k
    COUNTER_UPDATE(local_state->_bf_filtered_counter, stats.rows_bf_filtered);
967
888k
    COUNTER_UPDATE(local_state->_del_filtered_counter, stats.rows_del_filtered);
968
888k
    COUNTER_UPDATE(local_state->_del_filtered_counter, stats.rows_del_by_bitmap);
969
888k
    COUNTER_UPDATE(local_state->_del_filtered_counter, stats.rows_vec_del_cond_filtered);
970
888k
    COUNTER_UPDATE(local_state->_conditions_filtered_counter, stats.rows_conditions_filtered);
971
888k
    COUNTER_UPDATE(local_state->_key_range_filtered_counter, stats.rows_key_range_filtered);
972
888k
    COUNTER_UPDATE(local_state->_total_pages_num_counter, stats.total_pages_num);
973
888k
    COUNTER_UPDATE(local_state->_cached_pages_num_counter, stats.cached_pages_num);
974
888k
    COUNTER_UPDATE(local_state->_inverted_index_filter_counter, stats.rows_inverted_index_filtered);
975
888k
    COUNTER_UPDATE(local_state->_inverted_index_filter_timer, stats.inverted_index_filter_timer);
976
888k
    COUNTER_UPDATE(local_state->_inverted_index_query_cache_hit_counter,
977
888k
                   stats.inverted_index_query_cache_hit);
978
888k
    COUNTER_UPDATE(local_state->_inverted_index_query_cache_miss_counter,
979
888k
                   stats.inverted_index_query_cache_miss);
980
888k
    COUNTER_UPDATE(local_state->_inverted_index_query_timer, stats.inverted_index_query_timer);
981
888k
    COUNTER_UPDATE(local_state->_inverted_index_query_null_bitmap_timer,
982
888k
                   stats.inverted_index_query_null_bitmap_timer);
983
888k
    COUNTER_UPDATE(local_state->_inverted_index_query_bitmap_copy_timer,
984
888k
                   stats.inverted_index_query_bitmap_copy_timer);
985
888k
    COUNTER_UPDATE(local_state->_inverted_index_searcher_open_timer,
986
888k
                   stats.inverted_index_searcher_open_timer);
987
888k
    COUNTER_UPDATE(local_state->_inverted_index_searcher_search_timer,
988
888k
                   stats.inverted_index_searcher_search_timer);
989
888k
    COUNTER_UPDATE(local_state->_inverted_index_searcher_search_init_timer,
990
888k
                   stats.inverted_index_searcher_search_init_timer);
991
888k
    COUNTER_UPDATE(local_state->_inverted_index_searcher_search_exec_timer,
992
888k
                   stats.inverted_index_searcher_search_exec_timer);
993
888k
    COUNTER_UPDATE(local_state->_inverted_index_searcher_cache_hit_counter,
994
888k
                   stats.inverted_index_searcher_cache_hit);
995
888k
    COUNTER_UPDATE(local_state->_inverted_index_searcher_cache_miss_counter,
996
888k
                   stats.inverted_index_searcher_cache_miss);
997
888k
    COUNTER_UPDATE(local_state->_inverted_index_downgrade_count_counter,
998
888k
                   stats.inverted_index_downgrade_count);
999
888k
    COUNTER_UPDATE(local_state->_inverted_index_analyzer_timer,
1000
888k
                   stats.inverted_index_analyzer_timer);
1001
888k
    COUNTER_UPDATE(local_state->_inverted_index_lookup_timer, stats.inverted_index_lookup_timer);
1002
888k
    COUNTER_UPDATE(local_state->_variant_scan_sparse_column_timer,
1003
888k
                   stats.variant_scan_sparse_column_timer_ns);
1004
888k
    COUNTER_UPDATE(local_state->_variant_scan_sparse_column_bytes,
1005
888k
                   stats.variant_scan_sparse_column_bytes);
1006
888k
    COUNTER_UPDATE(local_state->_variant_fill_path_from_sparse_column_timer,
1007
888k
                   stats.variant_fill_path_from_sparse_column_timer_ns);
1008
888k
    COUNTER_UPDATE(local_state->_variant_subtree_default_iter_count,
1009
888k
                   stats.variant_subtree_default_iter_count);
1010
888k
    COUNTER_UPDATE(local_state->_variant_subtree_leaf_iter_count,
1011
888k
                   stats.variant_subtree_leaf_iter_count);
1012
888k
    COUNTER_UPDATE(local_state->_variant_subtree_hierarchical_iter_count,
1013
888k
                   stats.variant_subtree_hierarchical_iter_count);
1014
888k
    COUNTER_UPDATE(local_state->_variant_subtree_sparse_iter_count,
1015
888k
                   stats.variant_subtree_sparse_iter_count);
1016
888k
    COUNTER_UPDATE(local_state->_variant_doc_value_column_iter_count,
1017
888k
                   stats.variant_doc_value_column_iter_count);
1018
1019
888k
    if (stats.adaptive_batch_size_predict_max_rows > 0) {
1020
620k
        local_state->_adaptive_batch_predict_min_rows_counter->set(
1021
620k
                stats.adaptive_batch_size_predict_min_rows);
1022
620k
        local_state->_adaptive_batch_predict_max_rows_counter->set(
1023
620k
                stats.adaptive_batch_size_predict_max_rows);
1024
620k
    }
1025
1026
888k
    InvertedIndexProfileReporter inverted_index_profile;
1027
888k
    inverted_index_profile.update(local_state->_index_filter_profile.get(),
1028
888k
                                  &stats.inverted_index_stats);
1029
1030
888k
    if (has_file_cache_statistics(stats.file_cache_stats)) {
1031
0
        io::FileCacheProfileReporter cache_profile(local_state->_segment_profile.get());
1032
0
        cache_profile.update(&stats.file_cache_stats);
1033
0
        _state->get_query_ctx()->resource_ctx()->io_context()->update_bytes_write_into_cache(
1034
0
                stats.file_cache_stats.bytes_write_into_cache);
1035
0
    }
1036
888k
    COUNTER_UPDATE(local_state->_output_index_result_column_timer,
1037
888k
                   stats.output_index_result_column_timer);
1038
888k
    COUNTER_UPDATE(local_state->_filtered_segment_counter, stats.filtered_segment_number);
1039
888k
    COUNTER_UPDATE(local_state->_total_segment_counter, stats.total_segment_number);
1040
888k
    COUNTER_UPDATE(local_state->_condition_cache_hit_counter, stats.condition_cache_hit_seg_nums);
1041
888k
    COUNTER_UPDATE(local_state->_condition_cache_filtered_rows_counter,
1042
888k
                   stats.condition_cache_filtered_rows);
1043
1044
888k
    COUNTER_UPDATE(local_state->_tablet_reader_init_timer, stats.tablet_reader_init_timer_ns);
1045
888k
    COUNTER_UPDATE(local_state->_tablet_reader_capture_rs_readers_timer,
1046
888k
                   stats.tablet_reader_capture_rs_readers_timer_ns);
1047
888k
    COUNTER_UPDATE(local_state->_tablet_reader_init_return_columns_timer,
1048
888k
                   stats.tablet_reader_init_return_columns_timer_ns);
1049
888k
    COUNTER_UPDATE(local_state->_tablet_reader_init_keys_param_timer,
1050
888k
                   stats.tablet_reader_init_keys_param_timer_ns);
1051
888k
    COUNTER_UPDATE(local_state->_tablet_reader_init_orderby_keys_param_timer,
1052
888k
                   stats.tablet_reader_init_orderby_keys_param_timer_ns);
1053
888k
    COUNTER_UPDATE(local_state->_tablet_reader_init_conditions_param_timer,
1054
888k
                   stats.tablet_reader_init_conditions_param_timer_ns);
1055
888k
    COUNTER_UPDATE(local_state->_tablet_reader_init_delete_condition_param_timer,
1056
888k
                   stats.tablet_reader_init_delete_condition_param_timer_ns);
1057
888k
    COUNTER_UPDATE(local_state->_block_reader_vcollect_iter_init_timer,
1058
888k
                   stats.block_reader_vcollect_iter_init_timer_ns);
1059
888k
    COUNTER_UPDATE(local_state->_block_reader_rs_readers_init_timer,
1060
888k
                   stats.block_reader_rs_readers_init_timer_ns);
1061
888k
    COUNTER_UPDATE(local_state->_block_reader_build_heap_init_timer,
1062
888k
                   stats.block_reader_build_heap_init_timer_ns);
1063
1064
888k
    COUNTER_UPDATE(local_state->_rowset_reader_get_segment_iterators_timer,
1065
888k
                   stats.rowset_reader_get_segment_iterators_timer_ns);
1066
888k
    COUNTER_UPDATE(local_state->_rowset_reader_create_iterators_timer,
1067
888k
                   stats.rowset_reader_create_iterators_timer_ns);
1068
888k
    COUNTER_UPDATE(local_state->_rowset_reader_init_iterators_timer,
1069
888k
                   stats.rowset_reader_init_iterators_timer_ns);
1070
888k
    COUNTER_UPDATE(local_state->_rowset_reader_load_segments_timer,
1071
888k
                   stats.rowset_reader_load_segments_timer_ns);
1072
1073
888k
    COUNTER_UPDATE(local_state->_segment_iterator_init_timer, stats.segment_iterator_init_timer_ns);
1074
888k
    COUNTER_UPDATE(local_state->_segment_iterator_init_return_column_iterators_timer,
1075
888k
                   stats.segment_iterator_init_return_column_iterators_timer_ns);
1076
888k
    COUNTER_UPDATE(local_state->_segment_iterator_init_index_iterators_timer,
1077
888k
                   stats.segment_iterator_init_index_iterators_timer_ns);
1078
888k
    COUNTER_UPDATE(local_state->_segment_iterator_init_segment_prefetchers_timer,
1079
888k
                   stats.segment_iterator_init_segment_prefetchers_timer_ns);
1080
1081
888k
    COUNTER_UPDATE(local_state->_segment_create_column_readers_timer,
1082
888k
                   stats.segment_create_column_readers_timer_ns);
1083
888k
    COUNTER_UPDATE(local_state->_segment_load_index_timer, stats.segment_load_index_timer_ns);
1084
1085
    // Update metrics
1086
888k
    DorisMetrics::instance()->query_scan_bytes->increment(
1087
888k
            local_state->_read_uncompressed_counter->value());
1088
888k
    DorisMetrics::instance()->query_scan_rows->increment(local_state->_scan_rows->value());
1089
888k
    auto& tablet = _tablet_reader_params.tablet;
1090
888k
    tablet->query_scan_bytes->increment(local_state->_read_uncompressed_counter->value());
1091
888k
    tablet->query_scan_rows->increment(local_state->_scan_rows->value());
1092
888k
    tablet->query_scan_count->increment(1);
1093
1094
888k
    COUNTER_UPDATE(local_state->_ann_range_search_filter_counter,
1095
888k
                   stats.rows_ann_index_range_filtered);
1096
888k
    COUNTER_UPDATE(local_state->_ann_topn_filter_counter, stats.rows_ann_index_topn_filtered);
1097
888k
    COUNTER_UPDATE(local_state->_ann_index_load_costs, stats.ann_index_load_ns);
1098
888k
    COUNTER_UPDATE(local_state->_ann_ivf_on_disk_load_costs, stats.ann_ivf_on_disk_load_ns);
1099
888k
    COUNTER_UPDATE(local_state->_ann_ivf_on_disk_cache_hit_cnt,
1100
888k
                   stats.ann_ivf_on_disk_cache_hit_cnt);
1101
888k
    COUNTER_UPDATE(local_state->_ann_ivf_on_disk_cache_miss_cnt,
1102
888k
                   stats.ann_ivf_on_disk_cache_miss_cnt);
1103
888k
    COUNTER_UPDATE(local_state->_ann_range_search_costs, stats.ann_index_range_search_ns);
1104
888k
    COUNTER_UPDATE(local_state->_ann_range_search_cnt, stats.ann_index_range_search_cnt);
1105
888k
    COUNTER_UPDATE(local_state->_ann_range_engine_search_costs, stats.ann_range_engine_search_ns);
1106
    // Engine prepare before search
1107
888k
    COUNTER_UPDATE(local_state->_ann_range_pre_process_costs, stats.ann_range_pre_process_ns);
1108
    // Post process parent: Doris result process + engine convert
1109
888k
    COUNTER_UPDATE(local_state->_ann_range_post_process_costs,
1110
888k
                   stats.ann_range_result_convert_ns + stats.ann_range_engine_convert_ns);
1111
    // Engine convert (child under post-process)
1112
888k
    COUNTER_UPDATE(local_state->_ann_range_engine_convert_costs, stats.ann_range_engine_convert_ns);
1113
    // Doris-side result convert (child under post-process)
1114
888k
    COUNTER_UPDATE(local_state->_ann_range_result_convert_costs, stats.ann_range_result_convert_ns);
1115
1116
888k
    COUNTER_UPDATE(local_state->_ann_topn_search_costs, stats.ann_topn_search_ns);
1117
888k
    COUNTER_UPDATE(local_state->_ann_topn_search_cnt, stats.ann_index_topn_search_cnt);
1118
888k
    COUNTER_UPDATE(local_state->_ann_cache_hit_cnt, stats.ann_index_cache_hits);
1119
888k
    COUNTER_UPDATE(local_state->_ann_range_cache_hit_cnt, stats.ann_index_range_cache_hits);
1120
1121
    // Detailed ANN timers
1122
    // ANN TopN timers with hierarchy
1123
    // Engine search time (FAISS)
1124
888k
    COUNTER_UPDATE(local_state->_ann_topn_engine_search_costs,
1125
888k
                   stats.ann_index_topn_engine_search_ns);
1126
    // Engine prepare time (allocations/buffer setup before search)
1127
888k
    COUNTER_UPDATE(local_state->_ann_topn_pre_process_costs,
1128
888k
                   stats.ann_index_topn_engine_prepare_ns);
1129
    // Post process parent includes Doris result processing + engine convert
1130
888k
    COUNTER_UPDATE(local_state->_ann_topn_post_process_costs,
1131
888k
                   stats.ann_index_topn_result_process_ns + stats.ann_index_topn_engine_convert_ns);
1132
    // Engine-side conversion time inside FAISS wrappers (child under post-process)
1133
888k
    COUNTER_UPDATE(local_state->_ann_topn_engine_convert_costs,
1134
888k
                   stats.ann_index_topn_engine_convert_ns);
1135
1136
    // Doris-side result convert costs (show separately as another child counter); use pure process time
1137
888k
    COUNTER_UPDATE(local_state->_ann_topn_result_convert_costs,
1138
888k
                   stats.ann_index_topn_result_process_ns);
1139
1140
888k
    COUNTER_UPDATE(local_state->_ann_fallback_brute_force_cnt, stats.ann_fall_back_brute_force_cnt);
1141
888k
    COUNTER_UPDATE(local_state->_ann_topn_fallback_by_small_candidate_cnt,
1142
888k
                   stats.ann_topn_fallback_by_small_candidate_cnt);
1143
888k
    COUNTER_UPDATE(local_state->_ann_topn_fallback_small_candidate_rows,
1144
888k
                   stats.ann_topn_fallback_small_candidate_rows);
1145
888k
    COUNTER_UPDATE(local_state->_ann_range_fallback_by_small_candidate_cnt,
1146
888k
                   stats.ann_range_fallback_by_small_candidate_cnt);
1147
888k
    COUNTER_UPDATE(local_state->_ann_range_fallback_small_candidate_rows,
1148
888k
                   stats.ann_range_fallback_small_candidate_rows);
1149
1150
    // Overhead counter removed; precise instrumentation is reported via engine_prepare above.
1151
888k
}
1152
1153
#ifndef NDEBUG
1154
1.14M
Status OlapScanner::_check_ann_cache_hit_debug_points(const OlapReaderStatistics& stats) {
1155
1.14M
    DBUG_EXECUTE_IF("olap_scanner.ann_topn_cache_hits", {
1156
1.14M
        auto expected_hits = dp->param<int32_t>("expected_hits", -1);
1157
1.14M
        auto min_hits = dp->param<int32_t>("min_hits", -1);
1158
1.14M
        if (expected_hits >= 0 && stats.ann_index_cache_hits != expected_hits) {
1159
1.14M
            return Status::Error<ErrorCode::INTERNAL_ERROR>(
1160
1.14M
                    "ann_index_cache_hits: {} not equal to expected: {}",
1161
1.14M
                    stats.ann_index_cache_hits, expected_hits);
1162
1.14M
        }
1163
1.14M
        if (min_hits >= 0 && stats.ann_index_cache_hits < min_hits) {
1164
1.14M
            return Status::Error<ErrorCode::INTERNAL_ERROR>(
1165
1.14M
                    "ann_index_cache_hits: {} less than expected min: {}",
1166
1.14M
                    stats.ann_index_cache_hits, min_hits);
1167
1.14M
        }
1168
1.14M
    })
1169
1.14M
    DBUG_EXECUTE_IF("olap_scanner.ann_range_cache_hits", {
1170
1.14M
        auto expected_hits = dp->param<int32_t>("expected_hits", -1);
1171
1.14M
        auto min_hits = dp->param<int32_t>("min_hits", -1);
1172
1.14M
        if (expected_hits >= 0 && stats.ann_index_range_cache_hits != expected_hits) {
1173
1.14M
            return Status::Error<ErrorCode::INTERNAL_ERROR>(
1174
1.14M
                    "ann_index_range_cache_hits: {} not equal to expected: {}",
1175
1.14M
                    stats.ann_index_range_cache_hits, expected_hits);
1176
1.14M
        }
1177
1.14M
        if (min_hits >= 0 && stats.ann_index_range_cache_hits < min_hits) {
1178
1.14M
            return Status::Error<ErrorCode::INTERNAL_ERROR>(
1179
1.14M
                    "ann_index_range_cache_hits: {} less than expected min: {}",
1180
1.14M
                    stats.ann_index_range_cache_hits, min_hits);
1181
1.14M
        }
1182
1.14M
    })
1183
1.14M
    return Status::OK();
1184
1.14M
}
1185
#endif
1186
1187
#include "common/compile_check_avoid_end.h"
1188
} // namespace doris