Coverage Report

Created: 2026-03-16 21:05

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
441
PendingRowsetGuard::~PendingRowsetGuard() {
25
441
    if (_pending_rowset_set) {
26
133
        _pending_rowset_set->remove(_rowset_id);
27
133
    }
28
441
}
29
30
PendingRowsetGuard::PendingRowsetGuard(const RowsetId& rowset_id, PendingRowsetSet* set)
31
135
        : _rowset_id(rowset_id), _pending_rowset_set(set) {}
32
33
135
PendingRowsetGuard::PendingRowsetGuard(PendingRowsetGuard&& other) noexcept {
34
135
    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
135
    _rowset_id = other._rowset_id;
39
135
    _pending_rowset_set = other._pending_rowset_set;
40
135
    other._pending_rowset_set = nullptr;
41
135
}
42
43
104
PendingRowsetGuard& PendingRowsetGuard::operator=(PendingRowsetGuard&& other) noexcept {
44
104
    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
104
    _rowset_id = other._rowset_id;
49
104
    _pending_rowset_set = other._pending_rowset_set;
50
104
    other._pending_rowset_set = nullptr;
51
104
    return *this;
52
104
}
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
495
bool PendingRowsetSet::contains(const RowsetId& rowset_id) {
63
495
    std::lock_guard lock(_mtx);
64
495
    return _set.contains(rowset_id);
65
495
}
66
67
135
PendingRowsetGuard PendingRowsetSet::add(const RowsetId& rowset_id) {
68
135
    {
69
135
        std::lock_guard lock(_mtx);
70
135
        _set.insert(rowset_id);
71
135
    }
72
135
    return PendingRowsetGuard {rowset_id, this};
73
135
}
74
75
133
void PendingRowsetSet::remove(const RowsetId& rowset_id) {
76
133
    std::lock_guard lock(_mtx);
77
133
    _set.erase(rowset_id);
78
133
}
79
80
} // namespace doris