Coverage Report

Created: 2025-03-12 11:23

/root/doris/be/src/olap/merger.cpp
Line
Count
Source (jump to first uncovered line)
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 "olap/merger.h"
19
20
#include <gen_cpp/olap_file.pb.h>
21
#include <gen_cpp/types.pb.h>
22
#include <stddef.h>
23
#include <unistd.h>
24
25
#include <algorithm>
26
#include <iterator>
27
#include <memory>
28
#include <mutex>
29
#include <numeric>
30
#include <ostream>
31
#include <shared_mutex>
32
#include <string>
33
#include <utility>
34
#include <vector>
35
36
#include "common/config.h"
37
#include "common/logging.h"
38
#include "common/status.h"
39
#include "olap/base_tablet.h"
40
#include "olap/iterators.h"
41
#include "olap/olap_common.h"
42
#include "olap/olap_define.h"
43
#include "olap/rowid_conversion.h"
44
#include "olap/rowset/rowset.h"
45
#include "olap/rowset/rowset_meta.h"
46
#include "olap/rowset/rowset_writer.h"
47
#include "olap/rowset/segment_v2/segment_writer.h"
48
#include "olap/storage_engine.h"
49
#include "olap/tablet.h"
50
#include "olap/tablet_fwd.h"
51
#include "olap/tablet_meta.h"
52
#include "olap/tablet_reader.h"
53
#include "olap/utils.h"
54
#include "util/slice.h"
55
#include "vec/core/block.h"
56
#include "vec/olap/block_reader.h"
57
#include "vec/olap/vertical_block_reader.h"
58
#include "vec/olap/vertical_merge_iterator.h"
59
60
namespace doris {
61
62
Status Merger::vmerge_rowsets(BaseTabletSPtr tablet, ReaderType reader_type,
63
                              const TabletSchema& cur_tablet_schema,
64
                              const std::vector<RowsetReaderSharedPtr>& src_rowset_readers,
65
48
                              RowsetWriter* dst_rowset_writer, Statistics* stats_output) {
66
48
    if (!cur_tablet_schema.cluster_key_uids().empty()) {
67
0
        return Status::InternalError(
68
0
                "mow table with cluster keys does not support non vertical compaction");
69
0
    }
70
48
    vectorized::BlockReader reader;
71
48
    TabletReader::ReaderParams reader_params;
72
48
    reader_params.tablet = tablet;
73
48
    reader_params.reader_type = reader_type;
74
75
48
    TabletReader::ReadSource read_source;
76
48
    read_source.rs_splits.reserve(src_rowset_readers.size());
77
144
    for (const RowsetReaderSharedPtr& rs_reader : src_rowset_readers) {
78
144
        read_source.rs_splits.emplace_back(rs_reader);
79
144
    }
80
48
    read_source.fill_delete_predicates();
81
48
    reader_params.set_read_source(std::move(read_source));
82
83
48
    reader_params.version = dst_rowset_writer->version();
84
85
48
    TabletSchemaSPtr merge_tablet_schema = std::make_shared<TabletSchema>();
86
48
    merge_tablet_schema->copy_from(cur_tablet_schema);
87
88
    // Merge the columns in delete predicate that not in latest schema in to current tablet schema
89
48
    for (auto& del_pred_rs : reader_params.delete_predicates) {
90
24
        merge_tablet_schema->merge_dropped_columns(*del_pred_rs->tablet_schema());
91
24
    }
92
48
    reader_params.tablet_schema = merge_tablet_schema;
93
48
    if (!tablet->tablet_schema()->cluster_key_uids().empty()) {
94
0
        reader_params.delete_bitmap = &tablet->tablet_meta()->delete_bitmap();
95
0
    }
96
97
48
    if (stats_output && stats_output->rowid_conversion) {
98
48
        reader_params.record_rowids = true;
99
48
        reader_params.rowid_conversion = stats_output->rowid_conversion;
100
48
        stats_output->rowid_conversion->set_dst_rowset_id(dst_rowset_writer->rowset_id());
101
48
    }
102
103
48
    reader_params.return_columns.resize(cur_tablet_schema.num_columns());
104
48
    std::iota(reader_params.return_columns.begin(), reader_params.return_columns.end(), 0);
105
48
    reader_params.origin_return_columns = &reader_params.return_columns;
106
48
    RETURN_IF_ERROR(reader.init(reader_params));
107
108
48
    vectorized::Block block = cur_tablet_schema.create_block(reader_params.return_columns);
109
48
    size_t output_rows = 0;
110
48
    bool eof = false;
111
626
    while (!eof && !ExecEnv::GetInstance()->storage_engine().stopped()) {
112
578
        auto tablet_state = tablet->tablet_state();
113
578
        if (tablet_state != TABLET_RUNNING && tablet_state != TABLET_NOTREADY) {
114
0
            tablet->clear_cache();
115
0
            return Status::Error<INTERNAL_ERROR>("tablet {} is not used any more",
116
0
                                                 tablet->tablet_id());
117
0
        }
118
119
        // Read one block from block reader
120
578
        RETURN_NOT_OK_STATUS_WITH_WARN(reader.next_block_with_aggregation(&block, &eof),
121
578
                                       "failed to read next block when merging rowsets of tablet " +
122
578
                                               std::to_string(tablet->tablet_id()));
123
578
        RETURN_NOT_OK_STATUS_WITH_WARN(dst_rowset_writer->add_block(&block),
124
578
                                       "failed to write block when merging rowsets of tablet " +
125
578
                                               std::to_string(tablet->tablet_id()));
126
127
578
        if (reader_params.record_rowids && block.rows() > 0) {
128
578
            std::vector<uint32_t> segment_num_rows;
129
578
            RETURN_IF_ERROR(dst_rowset_writer->get_segment_num_rows(&segment_num_rows));
130
578
            stats_output->rowid_conversion->add(reader.current_block_row_locations(),
131
578
                                                segment_num_rows);
132
578
        }
133
134
578
        output_rows += block.rows();
135
578
        block.clear_column_data();
136
578
    }
137
48
    if (ExecEnv::GetInstance()->storage_engine().stopped()) {
138
0
        return Status::Error<INTERNAL_ERROR>("tablet {} failed to do compaction, engine stopped",
139
0
                                             tablet->tablet_id());
140
0
    }
141
142
48
    if (stats_output != nullptr) {
143
48
        stats_output->output_rows = output_rows;
144
48
        stats_output->merged_rows = reader.merged_rows();
145
48
        stats_output->filtered_rows = reader.filtered_rows();
146
48
    }
147
148
48
    RETURN_NOT_OK_STATUS_WITH_WARN(dst_rowset_writer->flush(),
149
48
                                   "failed to flush rowset when merging rowsets of tablet " +
150
48
                                           std::to_string(tablet->tablet_id()));
151
152
48
    return Status::OK();
153
48
}
154
155
// split columns into several groups, make sure all keys in one group
156
// unique_key should consider sequence&delete column
157
void Merger::vertical_split_columns(const TabletSchema& tablet_schema,
158
                                    std::vector<std::vector<uint32_t>>* column_groups,
159
90
                                    std::vector<uint32_t>* key_group_cluster_key_idxes) {
160
90
    uint32_t num_key_cols = tablet_schema.num_key_columns();
161
90
    uint32_t total_cols = tablet_schema.num_columns();
162
90
    std::vector<uint32_t> key_columns;
163
176
    for (auto i = 0; i < num_key_cols; ++i) {
164
86
        key_columns.emplace_back(i);
165
86
    }
166
    // in unique key, sequence & delete sign column should merge with key columns
167
90
    int32_t sequence_col_idx = -1;
168
90
    int32_t delete_sign_idx = -1;
169
    // in key column compaction, seq_col real index is _num_key_columns
170
    // and delete_sign column is _block->columns() - 1
171
90
    if (tablet_schema.keys_type() == KeysType::UNIQUE_KEYS) {
172
49
        if (tablet_schema.has_sequence_col()) {
173
4
            sequence_col_idx = tablet_schema.sequence_col_idx();
174
4
            key_columns.emplace_back(sequence_col_idx);
175
4
        }
176
49
        delete_sign_idx = tablet_schema.field_index(DELETE_SIGN);
177
49
        if (delete_sign_idx != -1) {
178
43
            key_columns.emplace_back(delete_sign_idx);
179
43
        }
180
49
        if (!tablet_schema.cluster_key_uids().empty()) {
181
0
            for (const auto& cid : tablet_schema.cluster_key_uids()) {
182
0
                auto idx = tablet_schema.field_index(cid);
183
0
                DCHECK(idx >= 0) << "could not find cluster key column with unique_id=" << cid
184
0
                                 << " in tablet schema, table_id=" << tablet_schema.table_id();
185
0
                if (idx >= num_key_cols) {
186
0
                    key_columns.emplace_back(idx);
187
0
                }
188
0
            }
189
            // tablet schema unique ids: [1, 2, 5, 3, 6, 4], [1 2] is key columns
190
            // cluster key unique ids: [3, 1, 4]
191
            // the key_columns should be [0, 1, 3, 5]
192
            // the key_group_cluster_key_idxes should be [2, 1, 3]
193
0
            for (const auto& cid : tablet_schema.cluster_key_uids()) {
194
0
                auto idx = tablet_schema.field_index(cid);
195
0
                for (auto i = 0; i < key_columns.size(); ++i) {
196
0
                    if (idx == key_columns[i]) {
197
0
                        key_group_cluster_key_idxes->emplace_back(i);
198
0
                        break;
199
0
                    }
200
0
                }
201
0
            }
202
0
        }
203
49
    }
204
90
    VLOG_NOTICE << "sequence_col_idx=" << sequence_col_idx
205
0
                << ", delete_sign_idx=" << delete_sign_idx;
206
    // for duplicate no keys
207
90
    if (!key_columns.empty()) {
208
75
        column_groups->emplace_back(key_columns);
209
75
    }
210
211
90
    std::vector<uint32_t> value_columns;
212
213
968
    for (uint32_t i = num_key_cols; i < total_cols; ++i) {
214
878
        if (i == sequence_col_idx || i == delete_sign_idx ||
215
878
            key_columns.end() != std::find(key_columns.begin(), key_columns.end(), i)) {
216
47
            continue;
217
47
        }
218
219
831
        if (!value_columns.empty() &&
220
831
            value_columns.size() % config::vertical_compaction_num_columns_per_group == 0) {
221
140
            column_groups->push_back(value_columns);
222
140
            value_columns.clear();
223
140
        }
224
831
        value_columns.push_back(i);
225
831
    }
226
227
90
    if (!value_columns.empty()) {
228
90
        column_groups->push_back(value_columns);
229
90
    }
230
90
}
231
232
Status Merger::vertical_compact_one_group(
233
        BaseTabletSPtr tablet, ReaderType reader_type, const TabletSchema& tablet_schema,
234
        bool is_key, const std::vector<uint32_t>& column_group,
235
        vectorized::RowSourcesBuffer* row_source_buf,
236
        const std::vector<RowsetReaderSharedPtr>& src_rowset_readers,
237
        RowsetWriter* dst_rowset_writer, int64_t max_rows_per_segment, Statistics* stats_output,
238
        std::vector<uint32_t> key_group_cluster_key_idxes, int64_t batch_size,
239
283
        CompactionSampleInfo* sample_info) {
240
    // build tablet reader
241
283
    VLOG_NOTICE << "vertical compact one group, max_rows_per_segment=" << max_rows_per_segment;
242
283
    vectorized::VerticalBlockReader reader(row_source_buf);
243
283
    TabletReader::ReaderParams reader_params;
244
283
    reader_params.is_key_column_group = is_key;
245
283
    reader_params.key_group_cluster_key_idxes = key_group_cluster_key_idxes;
246
283
    reader_params.tablet = tablet;
247
283
    reader_params.reader_type = reader_type;
248
249
283
    TabletReader::ReadSource read_source;
250
283
    read_source.rs_splits.reserve(src_rowset_readers.size());
251
911
    for (const RowsetReaderSharedPtr& rs_reader : src_rowset_readers) {
252
911
        read_source.rs_splits.emplace_back(rs_reader);
253
911
    }
254
283
    read_source.fill_delete_predicates();
255
283
    reader_params.set_read_source(std::move(read_source));
256
257
283
    reader_params.version = dst_rowset_writer->version();
258
259
283
    TabletSchemaSPtr merge_tablet_schema = std::make_shared<TabletSchema>();
260
283
    merge_tablet_schema->copy_from(tablet_schema);
261
262
283
    for (auto& del_pred_rs : reader_params.delete_predicates) {
263
125
        merge_tablet_schema->merge_dropped_columns(*del_pred_rs->tablet_schema());
264
125
    }
265
266
283
    reader_params.tablet_schema = merge_tablet_schema;
267
283
    bool has_cluster_key = false;
268
283
    if (!tablet->tablet_schema()->cluster_key_uids().empty()) {
269
0
        reader_params.delete_bitmap = &tablet->tablet_meta()->delete_bitmap();
270
0
        has_cluster_key = true;
271
0
    }
272
273
283
    if (is_key && stats_output && stats_output->rowid_conversion) {
274
79
        reader_params.record_rowids = true;
275
79
        reader_params.rowid_conversion = stats_output->rowid_conversion;
276
79
        stats_output->rowid_conversion->set_dst_rowset_id(dst_rowset_writer->rowset_id());
277
79
    }
278
279
283
    reader_params.return_columns = column_group;
280
283
    reader_params.origin_return_columns = &reader_params.return_columns;
281
283
    reader_params.batch_size = batch_size;
282
283
    RETURN_IF_ERROR(reader.init(reader_params, sample_info));
283
284
282
    vectorized::Block block = tablet_schema.create_block(reader_params.return_columns);
285
282
    size_t output_rows = 0;
286
282
    bool eof = false;
287
8.03k
    while (!eof && !ExecEnv::GetInstance()->storage_engine().stopped()) {
288
7.75k
        auto tablet_state = tablet->tablet_state();
289
7.75k
        if (tablet_state != TABLET_RUNNING && tablet_state != TABLET_NOTREADY) {
290
0
            tablet->clear_cache();
291
0
            return Status::Error<INTERNAL_ERROR>("tablet {} is not used any more",
292
0
                                                 tablet->tablet_id());
293
0
        }
294
        // Read one block from block reader
295
7.75k
        RETURN_NOT_OK_STATUS_WITH_WARN(reader.next_block_with_aggregation(&block, &eof),
296
7.75k
                                       "failed to read next block when merging rowsets of tablet " +
297
7.75k
                                               std::to_string(tablet->tablet_id()));
298
7.75k
        RETURN_NOT_OK_STATUS_WITH_WARN(
299
7.75k
                dst_rowset_writer->add_columns(&block, column_group, is_key, max_rows_per_segment,
300
7.75k
                                               has_cluster_key),
301
7.75k
                "failed to write block when merging rowsets of tablet " +
302
7.75k
                        std::to_string(tablet->tablet_id()));
303
304
7.75k
        if (is_key && reader_params.record_rowids && block.rows() > 0) {
305
4.60k
            std::vector<uint32_t> segment_num_rows;
306
4.60k
            RETURN_IF_ERROR(dst_rowset_writer->get_segment_num_rows(&segment_num_rows));
307
4.60k
            stats_output->rowid_conversion->add(reader.current_block_row_locations(),
308
4.60k
                                                segment_num_rows);
309
4.60k
        }
310
7.75k
        output_rows += block.rows();
311
7.75k
        block.clear_column_data();
312
7.75k
    }
313
282
    if (ExecEnv::GetInstance()->storage_engine().stopped()) {
314
0
        return Status::Error<INTERNAL_ERROR>("tablet {} failed to do compaction, engine stopped",
315
0
                                             tablet->tablet_id());
316
0
    }
317
318
282
    if (is_key && stats_output != nullptr) {
319
78
        stats_output->output_rows = output_rows;
320
78
        stats_output->merged_rows = reader.merged_rows();
321
78
        stats_output->filtered_rows = reader.filtered_rows();
322
78
    }
323
282
    RETURN_IF_ERROR(dst_rowset_writer->flush_columns(is_key));
324
325
282
    return Status::OK();
326
282
}
327
328
// for segcompaction
329
Status Merger::vertical_compact_one_group(
330
        int64_t tablet_id, ReaderType reader_type, const TabletSchema& tablet_schema, bool is_key,
331
        const std::vector<uint32_t>& column_group, vectorized::RowSourcesBuffer* row_source_buf,
332
        vectorized::VerticalBlockReader& src_block_reader,
333
        segment_v2::SegmentWriter& dst_segment_writer, Statistics* stats_output,
334
22
        uint64_t* index_size, KeyBoundsPB& key_bounds, SimpleRowIdConversion* rowid_conversion) {
335
    // TODO: record_rowids
336
22
    vectorized::Block block = tablet_schema.create_block(column_group);
337
22
    size_t output_rows = 0;
338
22
    bool eof = false;
339
138
    while (!eof && !ExecEnv::GetInstance()->storage_engine().stopped()) {
340
        // Read one block from block reader
341
116
        RETURN_NOT_OK_STATUS_WITH_WARN(src_block_reader.next_block_with_aggregation(&block, &eof),
342
116
                                       "failed to read next block when merging rowsets of tablet " +
343
116
                                               std::to_string(tablet_id));
344
116
        if (!block.rows()) {
345
0
            break;
346
0
        }
347
116
        RETURN_NOT_OK_STATUS_WITH_WARN(dst_segment_writer.append_block(&block, 0, block.rows()),
348
116
                                       "failed to write block when merging rowsets of tablet " +
349
116
                                               std::to_string(tablet_id));
350
351
116
        if (is_key && rowid_conversion != nullptr) {
352
30
            rowid_conversion->add(src_block_reader.current_block_row_locations());
353
30
        }
354
116
        output_rows += block.rows();
355
116
        block.clear_column_data();
356
116
    }
357
22
    if (ExecEnv::GetInstance()->storage_engine().stopped()) {
358
0
        return Status::Error<INTERNAL_ERROR>("tablet {} failed to do compaction, engine stopped",
359
0
                                             tablet_id);
360
0
    }
361
362
22
    if (is_key && stats_output != nullptr) {
363
11
        stats_output->output_rows = output_rows;
364
11
        stats_output->merged_rows = src_block_reader.merged_rows();
365
11
        stats_output->filtered_rows = src_block_reader.filtered_rows();
366
11
    }
367
368
    // segcompaction produce only one segment at once
369
22
    RETURN_IF_ERROR(dst_segment_writer.finalize_columns_data());
370
22
    RETURN_IF_ERROR(dst_segment_writer.finalize_columns_index(index_size));
371
372
22
    if (is_key) {
373
11
        Slice min_key = dst_segment_writer.min_encoded_key();
374
11
        Slice max_key = dst_segment_writer.max_encoded_key();
375
11
        DCHECK_LE(min_key.compare(max_key), 0);
376
11
        key_bounds.set_min_key(min_key.to_string());
377
11
        key_bounds.set_max_key(max_key.to_string());
378
11
    }
379
380
22
    return Status::OK();
381
22
}
382
383
90
int64_t estimate_batch_size(int group_index, BaseTabletSPtr tablet, int64_t way_cnt) {
384
90
    std::unique_lock<std::mutex> lock(tablet->sample_info_lock);
385
90
    CompactionSampleInfo info = tablet->sample_infos[group_index];
386
90
    if (way_cnt <= 0) {
387
0
        LOG(INFO) << "estimate batch size for vertical compaction, tablet id: "
388
0
                  << tablet->tablet_id() << " way cnt: " << way_cnt;
389
0
        return 4096 - 32;
390
0
    }
391
90
    int64_t block_mem_limit = config::compaction_memory_bytes_limit / way_cnt;
392
90
    if (tablet->last_compaction_status.is<ErrorCode::MEM_LIMIT_EXCEEDED>()) {
393
0
        block_mem_limit /= 4;
394
0
    }
395
396
90
    int64_t group_data_size = 0;
397
90
    if (info.group_data_size > 0 && info.bytes > 0 && info.rows > 0) {
398
0
        float smoothing_factor = 0.5;
399
0
        group_data_size = int64_t(info.group_data_size * (1 - smoothing_factor) +
400
0
                                  info.bytes / info.rows * smoothing_factor);
401
0
        tablet->sample_infos[group_index].group_data_size = group_data_size;
402
90
    } else if (info.group_data_size > 0 && (info.bytes <= 0 || info.rows <= 0)) {
403
0
        group_data_size = info.group_data_size;
404
90
    } else if (info.group_data_size <= 0 && info.bytes > 0 && info.rows > 0) {
405
0
        group_data_size = info.bytes / info.rows;
406
0
        tablet->sample_infos[group_index].group_data_size = group_data_size;
407
90
    } else {
408
90
        LOG(INFO) << "estimate batch size for vertical compaction, tablet id: "
409
90
                  << tablet->tablet_id() << " group data size: " << info.group_data_size
410
90
                  << " row num: " << info.rows << " consume bytes: " << info.bytes;
411
90
        return 1024 - 32;
412
90
    }
413
414
0
    if (group_data_size <= 0) {
415
0
        LOG(WARNING) << "estimate batch size for vertical compaction, tablet id: "
416
0
                     << tablet->tablet_id() << " unexpected group data size: " << group_data_size;
417
0
        return 4096 - 32;
418
0
    }
419
420
0
    tablet->sample_infos[group_index].bytes = 0;
421
0
    tablet->sample_infos[group_index].rows = 0;
422
423
0
    int64_t batch_size = block_mem_limit / group_data_size;
424
0
    int64_t res = std::max(std::min(batch_size, int64_t(4096 - 32)), int64_t(32L));
425
0
    LOG(INFO) << "estimate batch size for vertical compaction, tablet id: " << tablet->tablet_id()
426
0
              << " group data size: " << info.group_data_size << " row num: " << info.rows
427
0
              << " consume bytes: " << info.bytes << " way cnt: " << way_cnt
428
0
              << " batch size: " << res;
429
0
    return res;
430
0
}
431
432
// steps to do vertical merge:
433
// 1. split columns into column groups
434
// 2. compact groups one by one, generate a row_source_buf when compact key group
435
// and use this row_source_buf to compact value column groups
436
// 3. build output rowset
437
Status Merger::vertical_merge_rowsets(BaseTabletSPtr tablet, ReaderType reader_type,
438
                                      const TabletSchema& tablet_schema,
439
                                      const std::vector<RowsetReaderSharedPtr>& src_rowset_readers,
440
                                      RowsetWriter* dst_rowset_writer, int64_t max_rows_per_segment,
441
79
                                      int64_t merge_way_num, Statistics* stats_output) {
442
79
    LOG(INFO) << "Start to do vertical compaction, tablet_id: " << tablet->tablet_id();
443
79
    std::vector<std::vector<uint32_t>> column_groups;
444
79
    std::vector<uint32_t> key_group_cluster_key_idxes;
445
79
    vertical_split_columns(tablet_schema, &column_groups, &key_group_cluster_key_idxes);
446
447
79
    vectorized::RowSourcesBuffer row_sources_buf(
448
79
            tablet->tablet_id(), dst_rowset_writer->context().tablet_path, reader_type);
449
79
    {
450
79
        std::unique_lock<std::mutex> lock(tablet->sample_info_lock);
451
79
        tablet->sample_infos.resize(column_groups.size(), {0, 0, 0});
452
79
    }
453
    // compact group one by one
454
361
    for (auto i = 0; i < column_groups.size(); ++i) {
455
283
        VLOG_NOTICE << "row source size: " << row_sources_buf.total_size();
456
283
        bool is_key = (i == 0);
457
283
        int64_t batch_size = config::compaction_batch_size != -1
458
283
                                     ? config::compaction_batch_size
459
283
                                     : estimate_batch_size(i, tablet, merge_way_num);
460
283
        CompactionSampleInfo sample_info;
461
283
        Status st = vertical_compact_one_group(
462
283
                tablet, reader_type, tablet_schema, is_key, column_groups[i], &row_sources_buf,
463
283
                src_rowset_readers, dst_rowset_writer, max_rows_per_segment, stats_output,
464
283
                key_group_cluster_key_idxes, batch_size, &sample_info);
465
283
        {
466
283
            std::unique_lock<std::mutex> lock(tablet->sample_info_lock);
467
283
            tablet->sample_infos[i] = sample_info;
468
283
        }
469
283
        RETURN_IF_ERROR(st);
470
282
        if (is_key) {
471
78
            RETURN_IF_ERROR(row_sources_buf.flush());
472
78
        }
473
282
        RETURN_IF_ERROR(row_sources_buf.seek_to_begin());
474
282
    }
475
476
    // finish compact, build output rowset
477
78
    VLOG_NOTICE << "finish compact groups";
478
78
    RETURN_IF_ERROR(dst_rowset_writer->final_flush());
479
480
78
    return Status::OK();
481
78
}
482
483
} // namespace doris