]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/utilities/blob_db/blob_dump_tool.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rocksdb / utilities / blob_db / blob_dump_tool.h
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 #pragma once
6 #ifndef ROCKSDB_LITE
7
8 #include <memory>
9 #include <string>
10 #include <utility>
11 #include "rocksdb/slice.h"
12 #include "rocksdb/status.h"
13 #include "util/file_reader_writer.h"
14 #include "utilities/blob_db/blob_log_format.h"
15
16 namespace rocksdb {
17 namespace blob_db {
18
19 class BlobDumpTool {
20 public:
21 enum class DisplayType {
22 kNone,
23 kRaw,
24 kHex,
25 kDetail,
26 };
27
28 BlobDumpTool();
29
30 Status Run(const std::string& filename, DisplayType show_key,
31 DisplayType show_blob, DisplayType show_uncompressed_blob,
32 bool show_summary);
33
34 private:
35 std::unique_ptr<RandomAccessFileReader> reader_;
36 std::unique_ptr<char> buffer_;
37 size_t buffer_size_;
38
39 Status Read(uint64_t offset, size_t size, Slice* result);
40 Status DumpBlobLogHeader(uint64_t* offset, CompressionType* compression);
41 Status DumpBlobLogFooter(uint64_t file_size, uint64_t* footer_offset);
42 Status DumpRecord(DisplayType show_key, DisplayType show_blob,
43 DisplayType show_uncompressed_blob, bool show_summary,
44 CompressionType compression, uint64_t* offset,
45 uint64_t* total_records, uint64_t* total_key_size,
46 uint64_t* total_blob_size,
47 uint64_t* total_uncompressed_blob_size);
48 void DumpSlice(const Slice s, DisplayType type);
49
50 template <class T>
51 std::string GetString(std::pair<T, T> p);
52 };
53
54 } // namespace blob_db
55 } // namespace rocksdb
56
57 #endif // ROCKSDB_LITE