]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/tools/sst_dump_tool_imp.h
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / rocksdb / tools / sst_dump_tool_imp.h
CommitLineData
7c673cae 1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
11fdf7f2
TL
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).
7c673cae
FG
5#pragma once
6#ifndef ROCKSDB_LITE
7
8#include "rocksdb/sst_dump_tool.h"
9
10#include <memory>
11#include <string>
12#include "db/dbformat.h"
13#include "options/cf_options.h"
14#include "util/file_reader_writer.h"
15
16namespace rocksdb {
17
494da23a 18class SstFileDumper {
7c673cae 19 public:
494da23a
TL
20 explicit SstFileDumper(const Options& options, const std::string& file_name,
21 bool verify_checksum, bool output_hex);
7c673cae
FG
22
23 Status ReadSequential(bool print_kv, uint64_t read_num, bool has_from,
24 const std::string& from_key, bool has_to,
25 const std::string& to_key,
26 bool use_from_as_prefix = false);
27
28 Status ReadTableProperties(
29 std::shared_ptr<const TableProperties>* table_properties);
30 uint64_t GetReadNumber() { return read_num_; }
31 TableProperties* GetInitTableProperties() { return table_properties_.get(); }
32
11fdf7f2 33 Status VerifyChecksum();
7c673cae
FG
34 Status DumpTable(const std::string& out_filename);
35 Status getStatus() { return init_result_; }
36
11fdf7f2
TL
37 int ShowAllCompressionSizes(
38 size_t block_size,
39 const std::vector<std::pair<CompressionType, const char*>>&
40 compression_types);
7c673cae
FG
41
42 private:
43 // Get the TableReader implementation for the sst file
44 Status GetTableReader(const std::string& file_path);
45 Status ReadTableProperties(uint64_t table_magic_number,
46 RandomAccessFileReader* file, uint64_t file_size);
47
48 uint64_t CalculateCompressedTableSize(const TableBuilderOptions& tb_options,
49 size_t block_size);
50
51 Status SetTableOptionsByMagicNumber(uint64_t table_magic_number);
52 Status SetOldTableOptions();
53
54 // Helper function to call the factory with settings specific to the
55 // factory implementation
56 Status NewTableReader(const ImmutableCFOptions& ioptions,
57 const EnvOptions& soptions,
58 const InternalKeyComparator& internal_comparator,
59 uint64_t file_size,
494da23a 60 std::unique_ptr<TableReader>* table_reader);
7c673cae
FG
61
62 std::string file_name_;
63 uint64_t read_num_;
64 bool verify_checksum_;
65 bool output_hex_;
66 EnvOptions soptions_;
67
68 // options_ and internal_comparator_ will also be used in
69 // ReadSequential internally (specifically, seek-related operations)
70 Options options_;
71
72 Status init_result_;
494da23a
TL
73 std::unique_ptr<TableReader> table_reader_;
74 std::unique_ptr<RandomAccessFileReader> file_;
7c673cae
FG
75
76 const ImmutableCFOptions ioptions_;
11fdf7f2 77 const MutableCFOptions moptions_;
7c673cae 78 InternalKeyComparator internal_comparator_;
494da23a 79 std::unique_ptr<TableProperties> table_properties_;
7c673cae
FG
80};
81
82} // namespace rocksdb
83
84#endif // ROCKSDB_LITE