/src/rocksdb/db/blob/blob_file_addition.h
Line | Count | Source (jump to first uncovered line) |
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 <cassert> |
9 | | #include <cstdint> |
10 | | #include <iosfwd> |
11 | | #include <string> |
12 | | |
13 | | #include "db/blob/blob_constants.h" |
14 | | #include "rocksdb/rocksdb_namespace.h" |
15 | | |
16 | | namespace ROCKSDB_NAMESPACE { |
17 | | |
18 | | class JSONWriter; |
19 | | class Slice; |
20 | | class Status; |
21 | | |
22 | | class BlobFileAddition { |
23 | | public: |
24 | 0 | BlobFileAddition() = default; |
25 | | |
26 | | BlobFileAddition(uint64_t blob_file_number, uint64_t total_blob_count, |
27 | | uint64_t total_blob_bytes, std::string checksum_method, |
28 | | std::string checksum_value) |
29 | 0 | : blob_file_number_(blob_file_number), |
30 | 0 | total_blob_count_(total_blob_count), |
31 | 0 | total_blob_bytes_(total_blob_bytes), |
32 | 0 | checksum_method_(std::move(checksum_method)), |
33 | 0 | checksum_value_(std::move(checksum_value)) { |
34 | 0 | assert(checksum_method_.empty() == checksum_value_.empty()); |
35 | 0 | } |
36 | | |
37 | 0 | uint64_t GetBlobFileNumber() const { return blob_file_number_; } |
38 | 0 | uint64_t GetTotalBlobCount() const { return total_blob_count_; } |
39 | 0 | uint64_t GetTotalBlobBytes() const { return total_blob_bytes_; } |
40 | 0 | const std::string& GetChecksumMethod() const { return checksum_method_; } |
41 | 0 | const std::string& GetChecksumValue() const { return checksum_value_; } |
42 | | |
43 | | void EncodeTo(std::string* output) const; |
44 | | Status DecodeFrom(Slice* input); |
45 | | |
46 | | std::string DebugString() const; |
47 | | std::string DebugJSON() const; |
48 | | |
49 | | private: |
50 | | enum CustomFieldTags : uint32_t; |
51 | | |
52 | | uint64_t blob_file_number_ = kInvalidBlobFileNumber; |
53 | | uint64_t total_blob_count_ = 0; |
54 | | uint64_t total_blob_bytes_ = 0; |
55 | | std::string checksum_method_; |
56 | | std::string checksum_value_; |
57 | | }; |
58 | | |
59 | | bool operator==(const BlobFileAddition& lhs, const BlobFileAddition& rhs); |
60 | | bool operator!=(const BlobFileAddition& lhs, const BlobFileAddition& rhs); |
61 | | |
62 | | std::ostream& operator<<(std::ostream& os, |
63 | | const BlobFileAddition& blob_file_addition); |
64 | | JSONWriter& operator<<(JSONWriter& jw, |
65 | | const BlobFileAddition& blob_file_addition); |
66 | | |
67 | | } // namespace ROCKSDB_NAMESPACE |