/src/rocksdb/db/blob/blob_file_garbage.h
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 | | #pragma once |
7 | | |
8 | | #include <cstdint> |
9 | | #include <iosfwd> |
10 | | #include <string> |
11 | | |
12 | | #include "db/blob/blob_constants.h" |
13 | | #include "rocksdb/rocksdb_namespace.h" |
14 | | |
15 | | namespace ROCKSDB_NAMESPACE { |
16 | | |
17 | | class JSONWriter; |
18 | | class Slice; |
19 | | class Status; |
20 | | |
21 | | class BlobFileGarbage { |
22 | | public: |
23 | 0 | BlobFileGarbage() = default; |
24 | | |
25 | | BlobFileGarbage(uint64_t blob_file_number, uint64_t garbage_blob_count, |
26 | | uint64_t garbage_blob_bytes) |
27 | 0 | : blob_file_number_(blob_file_number), |
28 | 0 | garbage_blob_count_(garbage_blob_count), |
29 | 0 | garbage_blob_bytes_(garbage_blob_bytes) {} |
30 | | |
31 | 0 | uint64_t GetBlobFileNumber() const { return blob_file_number_; } |
32 | 0 | uint64_t GetGarbageBlobCount() const { return garbage_blob_count_; } |
33 | 0 | uint64_t GetGarbageBlobBytes() const { return garbage_blob_bytes_; } |
34 | | |
35 | | void EncodeTo(std::string* output) const; |
36 | | Status DecodeFrom(Slice* input); |
37 | | |
38 | | std::string DebugString() const; |
39 | | std::string DebugJSON() const; |
40 | | |
41 | | private: |
42 | | enum CustomFieldTags : uint32_t; |
43 | | |
44 | | uint64_t blob_file_number_ = kInvalidBlobFileNumber; |
45 | | uint64_t garbage_blob_count_ = 0; |
46 | | uint64_t garbage_blob_bytes_ = 0; |
47 | | }; |
48 | | |
49 | | bool operator==(const BlobFileGarbage& lhs, const BlobFileGarbage& rhs); |
50 | | bool operator!=(const BlobFileGarbage& lhs, const BlobFileGarbage& rhs); |
51 | | |
52 | | std::ostream& operator<<(std::ostream& os, |
53 | | const BlobFileGarbage& blob_file_garbage); |
54 | | JSONWriter& operator<<(JSONWriter& jw, |
55 | | const BlobFileGarbage& blob_file_garbage); |
56 | | |
57 | | } // namespace ROCKSDB_NAMESPACE |