YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/consensus/replicate_msgs_holder.cc
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#include "yb/consensus/replicate_msgs_holder.h"
15
16
namespace yb {
17
namespace consensus {
18
19
ReplicateMsgsHolder::ReplicateMsgsHolder(
20
    google::protobuf::RepeatedPtrField<ReplicateMsg>* ops, ReplicateMsgs messages,
21
    ScopedTrackedConsumption consumption)
22
25.4M
    : ops_(ops), messages_(std::move(messages)), consumption_(std::move(consumption)) {
23
25.4M
}
24
25
ReplicateMsgsHolder::ReplicateMsgsHolder(ReplicateMsgsHolder&& rhs)
26
    : ops_(rhs.ops_), messages_(std::move(rhs.messages_)),
27
0
      consumption_(std::move(rhs.consumption_)) {
28
0
  rhs.ops_ = nullptr;
29
0
}
30
31
25.4M
void ReplicateMsgsHolder::operator=(ReplicateMsgsHolder&& rhs) {
32
25.4M
  Reset();
33
25.4M
  ops_ = rhs.ops_;
34
25.4M
  messages_ = std::move(rhs.messages_);
35
25.4M
  consumption_ = std::move(rhs.consumption_);
36
25.4M
  rhs.ops_ = nullptr;
37
25.4M
}
38
39
54.2M
ReplicateMsgsHolder::~ReplicateMsgsHolder() {
40
54.2M
  Reset();
41
54.2M
}
42
43
79.7M
void ReplicateMsgsHolder::Reset() {
44
79.7M
  if (ops_) {
45
15.7k
    ops_->ExtractSubrange(0, ops_->size(), nullptr /* elements */);
46
15.7k
    ops_ = nullptr;
47
15.7k
  }
48
49
79.7M
  messages_.clear();
50
79.7M
  consumption_ = ScopedTrackedConsumption();
51
79.7M
}
52
53
}  // namespace consensus
54
}  // namespace yb