]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/table/sst_file_dumper.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / table / sst_file_dumper.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
7c673cae
FG
8#include <memory>
9#include <string>
10#include "db/dbformat.h"
f67539c2 11#include "file/writable_file_writer.h"
7c673cae 12#include "options/cf_options.h"
7c673cae 13
f67539c2 14namespace ROCKSDB_NAMESPACE {
7c673cae 15
494da23a 16class SstFileDumper {
7c673cae 17 public:
494da23a 18 explicit SstFileDumper(const Options& options, const std::string& file_name,
20effc67
TL
19 size_t readahead_size, bool verify_checksum,
20 bool output_hex, bool decode_blob_index,
21 const EnvOptions& soptions = EnvOptions(),
22 bool silent = false);
7c673cae
FG
23
24 Status ReadSequential(bool print_kv, uint64_t read_num, bool has_from,
25 const std::string& from_key, bool has_to,
26 const std::string& to_key,
27 bool use_from_as_prefix = false);
28
29 Status ReadTableProperties(
30 std::shared_ptr<const TableProperties>* table_properties);
31 uint64_t GetReadNumber() { return read_num_; }
32 TableProperties* GetInitTableProperties() { return table_properties_.get(); }
33
11fdf7f2 34 Status VerifyChecksum();
7c673cae
FG
35 Status DumpTable(const std::string& out_filename);
36 Status getStatus() { return init_result_; }
37
20effc67 38 Status ShowAllCompressionSizes(
11fdf7f2
TL
39 size_t block_size,
40 const std::vector<std::pair<CompressionType, const char*>>&
20effc67
TL
41 compression_types,
42 int32_t compress_level_from, int32_t compress_level_to,
43 uint32_t max_dict_bytes, uint32_t zstd_max_train_bytes);
44
45 Status ShowCompressionSize(size_t block_size, CompressionType compress_type,
46 const CompressionOptions& compress_opt);
7c673cae
FG
47
48 private:
49 // Get the TableReader implementation for the sst file
50 Status GetTableReader(const std::string& file_path);
51 Status ReadTableProperties(uint64_t table_magic_number,
20effc67
TL
52 RandomAccessFileReader* file, uint64_t file_size,
53 FilePrefetchBuffer* prefetch_buffer);
7c673cae 54
20effc67
TL
55 Status CalculateCompressedTableSize(const TableBuilderOptions& tb_options,
56 size_t block_size,
57 uint64_t* num_data_blocks,
58 uint64_t* compressed_table_size);
7c673cae
FG
59
60 Status SetTableOptionsByMagicNumber(uint64_t table_magic_number);
61 Status SetOldTableOptions();
62
63 // Helper function to call the factory with settings specific to the
64 // factory implementation
65 Status NewTableReader(const ImmutableCFOptions& ioptions,
66 const EnvOptions& soptions,
67 const InternalKeyComparator& internal_comparator,
68 uint64_t file_size,
494da23a 69 std::unique_ptr<TableReader>* table_reader);
7c673cae
FG
70
71 std::string file_name_;
72 uint64_t read_num_;
7c673cae 73 bool output_hex_;
f67539c2 74 bool decode_blob_index_;
7c673cae 75 EnvOptions soptions_;
20effc67
TL
76 // less verbose in stdout/stderr
77 bool silent_;
7c673cae
FG
78
79 // options_ and internal_comparator_ will also be used in
80 // ReadSequential internally (specifically, seek-related operations)
81 Options options_;
82
83 Status init_result_;
494da23a
TL
84 std::unique_ptr<TableReader> table_reader_;
85 std::unique_ptr<RandomAccessFileReader> file_;
7c673cae
FG
86
87 const ImmutableCFOptions ioptions_;
11fdf7f2 88 const MutableCFOptions moptions_;
20effc67 89 ReadOptions read_options_;
7c673cae 90 InternalKeyComparator internal_comparator_;
494da23a 91 std::unique_ptr<TableProperties> table_properties_;
7c673cae
FG
92};
93
f67539c2 94} // namespace ROCKSDB_NAMESPACE
7c673cae
FG
95
96#endif // ROCKSDB_LITE