Coverage Report

Created: 2026-07-27 20:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/rowset/pending_rowset_helper.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 "storage/rowset/pending_rowset_helper.h"
19
20
#include "storage/olap_common.h"
21
22
namespace doris {
23
24
1.04k
PendingRowsetGuard::~PendingRowsetGuard() {
25
1.04k
    if (_pending_rowset_set) {
26
352
        for (const auto& rowset_id : _rowset_ids) {
27
352
            _pending_rowset_set->remove(rowset_id);
28
352
        }
29
346
    }
30
1.04k
}
31
32
PendingRowsetGuard::PendingRowsetGuard(const std::vector<RowsetId>& rowset_ids,
33
                                       PendingRowsetSet* set)
34
350
        : _rowset_ids(rowset_ids), _pending_rowset_set(set) {}
35
36
286
PendingRowsetGuard::PendingRowsetGuard(PendingRowsetGuard&& other) noexcept {
37
286
    CHECK(!_pending_rowset_set ||
38
0
          (_rowset_ids == other._rowset_ids && _pending_rowset_set == other._pending_rowset_set))
39
0
            << _rowset_ids.size() << ' ' << other._rowset_ids.size() << ' ' << _pending_rowset_set
40
0
            << ' ' << other._pending_rowset_set;
41
286
    _rowset_ids = other._rowset_ids;
42
286
    _pending_rowset_set = other._pending_rowset_set;
43
286
    other._pending_rowset_set = nullptr;
44
286
}
45
46
278
PendingRowsetGuard& PendingRowsetGuard::operator=(PendingRowsetGuard&& other) noexcept {
47
278
    CHECK(!_pending_rowset_set ||
48
0
          (_rowset_ids == other._rowset_ids && _pending_rowset_set == other._pending_rowset_set))
49
0
            << _rowset_ids.size() << ' ' << other._rowset_ids.size() << ' ' << _pending_rowset_set
50
0
            << ' ' << other._pending_rowset_set;
51
278
    _rowset_ids = other._rowset_ids;
52
278
    _pending_rowset_set = other._pending_rowset_set;
53
278
    other._pending_rowset_set = nullptr;
54
278
    return *this;
55
278
}
56
57
0
void PendingRowsetGuard::drop() {
58
0
    if (_pending_rowset_set) {
59
0
        for (const auto& rowset_id : _rowset_ids) {
60
0
            _pending_rowset_set->remove(rowset_id);
61
0
        }
62
0
    }
63
0
    _pending_rowset_set = nullptr;
64
0
    _rowset_ids = std::vector {RowsetId {}};
65
0
}
66
67
990
bool PendingRowsetSet::contains(const RowsetId& rowset_id) {
68
990
    std::lock_guard lock(_mtx);
69
990
    return _set.contains(rowset_id);
70
990
}
71
72
288
PendingRowsetGuard PendingRowsetSet::add(const RowsetId& rowset_id) {
73
288
    {
74
288
        std::lock_guard lock(_mtx);
75
288
        _set.insert(rowset_id);
76
288
    }
77
288
    return PendingRowsetGuard {std::vector<RowsetId> {rowset_id}, this};
78
288
}
79
80
62
PendingRowsetGuard PendingRowsetSet::add(const std::vector<RowsetId>& rowset_ids) {
81
62
    {
82
62
        std::lock_guard lock(_mtx);
83
68
        for (const auto& rowset_id : rowset_ids) {
84
68
            _set.insert(rowset_id);
85
68
        }
86
62
    }
87
62
    return PendingRowsetGuard {rowset_ids, this};
88
62
}
89
90
352
void PendingRowsetSet::remove(const RowsetId& rowset_id) {
91
352
    std::lock_guard lock(_mtx);
92
352
    _set.erase(rowset_id);
93
352
}
94
95
} // namespace doris