Coverage Report

Created: 2026-03-19 18:23

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
882
PendingRowsetGuard::~PendingRowsetGuard() {
25
882
    if (_pending_rowset_set) {
26
266
        _pending_rowset_set->remove(_rowset_id);
27
266
    }
28
882
}
29
30
PendingRowsetGuard::PendingRowsetGuard(const RowsetId& rowset_id, PendingRowsetSet* set)
31
270
        : _rowset_id(rowset_id), _pending_rowset_set(set) {}
32
33
270
PendingRowsetGuard::PendingRowsetGuard(PendingRowsetGuard&& other) noexcept {
34
270
    CHECK(!_pending_rowset_set ||
35
0
          (_rowset_id == other._rowset_id && _pending_rowset_set == other._pending_rowset_set))
36
0
            << _rowset_id << ' ' << other._rowset_id << ' ' << _pending_rowset_set << ' '
37
0
            << other._pending_rowset_set;
38
270
    _rowset_id = other._rowset_id;
39
270
    _pending_rowset_set = other._pending_rowset_set;
40
270
    other._pending_rowset_set = nullptr;
41
270
}
42
43
208
PendingRowsetGuard& PendingRowsetGuard::operator=(PendingRowsetGuard&& other) noexcept {
44
208
    CHECK(!_pending_rowset_set ||
45
0
          (_rowset_id == other._rowset_id && _pending_rowset_set == other._pending_rowset_set))
46
0
            << _rowset_id << ' ' << other._rowset_id << ' ' << _pending_rowset_set << ' '
47
0
            << other._pending_rowset_set;
48
208
    _rowset_id = other._rowset_id;
49
208
    _pending_rowset_set = other._pending_rowset_set;
50
208
    other._pending_rowset_set = nullptr;
51
208
    return *this;
52
208
}
53
54
0
void PendingRowsetGuard::drop() {
55
0
    if (_pending_rowset_set) {
56
0
        _pending_rowset_set->remove(_rowset_id);
57
0
    }
58
0
    _pending_rowset_set = nullptr;
59
0
    _rowset_id = RowsetId {};
60
0
}
61
62
990
bool PendingRowsetSet::contains(const RowsetId& rowset_id) {
63
990
    std::lock_guard lock(_mtx);
64
990
    return _set.contains(rowset_id);
65
990
}
66
67
270
PendingRowsetGuard PendingRowsetSet::add(const RowsetId& rowset_id) {
68
270
    {
69
270
        std::lock_guard lock(_mtx);
70
270
        _set.insert(rowset_id);
71
270
    }
72
270
    return PendingRowsetGuard {rowset_id, this};
73
270
}
74
75
266
void PendingRowsetSet::remove(const RowsetId& rowset_id) {
76
266
    std::lock_guard lock(_mtx);
77
266
    _set.erase(rowset_id);
78
266
}
79
80
} // namespace doris