]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/db/table_properties_collector.cc
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).
6 #include "db/table_properties_collector.h"
8 #include "db/dbformat.h"
9 #include "util/coding.h"
10 #include "util/string_util.h"
12 namespace ROCKSDB_NAMESPACE
{
16 uint64_t GetUint64Property(const UserCollectedProperties
& props
,
17 const std::string
& property_name
,
18 bool* property_present
) {
19 auto pos
= props
.find(property_name
);
20 if (pos
== props
.end()) {
21 *property_present
= false;
24 Slice raw
= pos
->second
;
26 *property_present
= true;
27 return GetVarint64(&raw
, &val
) ? val
: 0;
32 Status
UserKeyTablePropertiesCollector::InternalAdd(const Slice
& key
,
35 ParsedInternalKey ikey
;
36 Status s
= ParseInternalKey(key
, &ikey
, false /* log_err_key */); // TODO
41 return collector_
->AddUserKey(ikey
.user_key
, value
, GetEntryType(ikey
.type
),
42 ikey
.sequence
, file_size
);
45 void UserKeyTablePropertiesCollector::BlockAdd(
46 uint64_t bLockRawBytes
, uint64_t blockCompressedBytesFast
,
47 uint64_t blockCompressedBytesSlow
) {
48 return collector_
->BlockAdd(bLockRawBytes
, blockCompressedBytesFast
,
49 blockCompressedBytesSlow
);
52 Status
UserKeyTablePropertiesCollector::Finish(
53 UserCollectedProperties
* properties
) {
54 return collector_
->Finish(properties
);
57 UserCollectedProperties
58 UserKeyTablePropertiesCollector::GetReadableProperties() const {
59 return collector_
->GetReadableProperties();
62 uint64_t GetDeletedKeys(
63 const UserCollectedProperties
& props
) {
64 bool property_present_ignored
;
65 return GetUint64Property(props
, TablePropertiesNames::kDeletedKeys
,
66 &property_present_ignored
);
69 uint64_t GetMergeOperands(const UserCollectedProperties
& props
,
70 bool* property_present
) {
71 return GetUint64Property(
72 props
, TablePropertiesNames::kMergeOperands
, property_present
);
75 } // namespace ROCKSDB_NAMESPACE