Coverage Report

Created: 2026-04-10 07:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rocksdb/db/table_properties_collector.cc
Line
Count
Source
1
//  Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2
//  This source code is licensed under both the GPLv2 (found in the
3
//  COPYING file in the root directory) and Apache 2.0 License
4
//  (found in the LICENSE.Apache file in the root directory).
5
6
#include "db/table_properties_collector.h"
7
8
#include "db/dbformat.h"
9
#include "util/coding.h"
10
#include "util/string_util.h"
11
12
namespace ROCKSDB_NAMESPACE {
13
14
namespace {
15
16
uint64_t GetUint64Property(const UserCollectedProperties& props,
17
                           const std::string& property_name,
18
0
                           bool* property_present) {
19
0
  auto pos = props.find(property_name);
20
0
  if (pos == props.end()) {
21
0
    *property_present = false;
22
0
    return 0;
23
0
  }
24
0
  Slice raw = pos->second;
25
0
  uint64_t val = 0;
26
0
  *property_present = true;
27
0
  return GetVarint64(&raw, &val) ? val : 0;
28
0
}
29
30
}  // anonymous namespace
31
32
Status UserKeyTablePropertiesCollector::InternalAdd(const Slice& key,
33
                                                    const Slice& value,
34
0
                                                    uint64_t file_size) {
35
0
  ParsedInternalKey ikey;
36
0
  Status s = ParseInternalKey(key, &ikey, false /* log_err_key */);  // TODO
37
0
  if (!s.ok()) {
38
0
    return s;
39
0
  }
40
41
0
  return collector_->AddUserKey(ikey.user_key, value, GetEntryType(ikey.type),
42
0
                                ikey.sequence, file_size);
43
0
}
44
45
void UserKeyTablePropertiesCollector::BlockAdd(
46
    uint64_t block_uncomp_bytes, uint64_t block_compressed_bytes_fast,
47
0
    uint64_t block_compressed_bytes_slow) {
48
0
  return collector_->BlockAdd(block_uncomp_bytes, block_compressed_bytes_fast,
49
0
                              block_compressed_bytes_slow);
50
0
}
51
52
Status UserKeyTablePropertiesCollector::Finish(
53
0
    UserCollectedProperties* properties) {
54
0
  return collector_->Finish(properties);
55
0
}
56
57
UserCollectedProperties UserKeyTablePropertiesCollector::GetReadableProperties()
58
0
    const {
59
0
  return collector_->GetReadableProperties();
60
0
}
61
62
0
uint64_t GetDeletedKeys(const UserCollectedProperties& props) {
63
0
  bool property_present_ignored;
64
0
  return GetUint64Property(props, TablePropertiesNames::kDeletedKeys,
65
0
                           &property_present_ignored);
66
0
}
67
68
uint64_t GetMergeOperands(const UserCollectedProperties& props,
69
0
                          bool* property_present) {
70
0
  return GetUint64Property(props, TablePropertiesNames::kMergeOperands,
71
0
                           property_present);
72
0
}
73
74
}  // namespace ROCKSDB_NAMESPACE