]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | // This source code is licensed under the BSD-style license found in the | |
3 | // LICENSE file in the root directory of this source tree. An additional grant | |
4 | // of patent rights can be found in the PATENTS file in the same directory. | |
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 | ||
16 | namespace rocksdb { | |
17 | ||
18 | class SstFileReader { | |
19 | public: | |
20 | explicit SstFileReader(const std::string& file_name, bool verify_checksum, | |
21 | bool output_hex); | |
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 | ||
33 | Status DumpTable(const std::string& out_filename); | |
34 | Status getStatus() { return init_result_; } | |
35 | ||
36 | int ShowAllCompressionSizes(size_t block_size); | |
37 | ||
38 | private: | |
39 | // Get the TableReader implementation for the sst file | |
40 | Status GetTableReader(const std::string& file_path); | |
41 | Status ReadTableProperties(uint64_t table_magic_number, | |
42 | RandomAccessFileReader* file, uint64_t file_size); | |
43 | ||
44 | uint64_t CalculateCompressedTableSize(const TableBuilderOptions& tb_options, | |
45 | size_t block_size); | |
46 | ||
47 | Status SetTableOptionsByMagicNumber(uint64_t table_magic_number); | |
48 | Status SetOldTableOptions(); | |
49 | ||
50 | // Helper function to call the factory with settings specific to the | |
51 | // factory implementation | |
52 | Status NewTableReader(const ImmutableCFOptions& ioptions, | |
53 | const EnvOptions& soptions, | |
54 | const InternalKeyComparator& internal_comparator, | |
55 | uint64_t file_size, | |
56 | unique_ptr<TableReader>* table_reader); | |
57 | ||
58 | std::string file_name_; | |
59 | uint64_t read_num_; | |
60 | bool verify_checksum_; | |
61 | bool output_hex_; | |
62 | EnvOptions soptions_; | |
63 | ||
64 | // options_ and internal_comparator_ will also be used in | |
65 | // ReadSequential internally (specifically, seek-related operations) | |
66 | Options options_; | |
67 | ||
68 | Status init_result_; | |
69 | unique_ptr<TableReader> table_reader_; | |
70 | unique_ptr<RandomAccessFileReader> file_; | |
71 | ||
72 | const ImmutableCFOptions ioptions_; | |
73 | InternalKeyComparator internal_comparator_; | |
74 | unique_ptr<TableProperties> table_properties_; | |
75 | }; | |
76 | ||
77 | } // namespace rocksdb | |
78 | ||
79 | #endif // ROCKSDB_LITE |