YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/rocksdb/db/file_numbers.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/rocksdb/db/file_numbers.h"
15
16
#include "yb/rocksdb/db/version_set.h"
17
18
namespace rocksdb {
19
20
0
std::string FileNumbersHolder::ToString() const {
21
0
  return yb::ToString(file_numbers_);
22
0
}
23
24
38.5k
FileNumbersHolder FileNumbersProvider::NewFileNumber() {
25
  // No need to lock because VersionSet::next_file_number_ is atomic.
26
38.5k
  auto file_number = versions_->NewFileNumber();
27
38.5k
  AddFileNumber(file_number);
28
38.5k
  auto holder = FileNumbersHolder(this);
29
38.5k
  holder.Add(file_number);
30
38.5k
  return holder;
31
38.5k
}
32
33
10.6k
FileNumbersHolder FileNumbersProvider::CreateHolder() {
34
10.6k
  return FileNumbersHolder(this);
35
10.6k
}
36
37
22.1k
FileNumber FileNumbersProvider::NewFileNumber(FileNumbersHolder* holder) {
38
  // No need to lock because VersionSet::next_file_number_ is atomic.
39
22.1k
  auto file_number = versions_->NewFileNumber();
40
22.1k
  std::lock_guard<SpinMutex> l(mutex_);
41
22.1k
  fset_.insert(file_number);
42
22.1k
  holder->Add(file_number);
43
22.1k
  return file_number;
44
22.1k
}
45
46
4.82M
bool FileNumbersProvider::HasFileNumber(FileNumber file_number) const {
47
4.82M
  std::lock_guard<SpinMutex> l(mutex_);
48
4.82M
  return fset_.count(file_number) > 0;
49
4.82M
}
50
51
0
std::string FileNumbersProvider::ToString() const {
52
0
  std::lock_guard<SpinMutex> l(mutex_);
53
0
  return yb::ToString(fset_);
54
0
}
55
56
64.0k
void FileNumbersProvider::AddFileNumber(FileNumber file_number) {
57
64.0k
  std::lock_guard<SpinMutex> l(mutex_);
58
64.0k
  fset_.insert(file_number);
59
64.0k
}
60
61
86.1k
void FileNumbersProvider::RemoveFileNumber(FileNumber file_number) {
62
86.1k
  std::lock_guard<SpinMutex> l(mutex_);
63
86.1k
  auto iter = fset_.find(file_number);
64
86.1k
  if (iter != fset_.end()) {
65
86.1k
    fset_.erase(iter);
66
86.1k
  }
67
86.1k
}
68
69
}  // namespace rocksdb