/Users/deen/code/yugabyte-db/src/yb/rocksdb/tools/sst_dump_tool_imp.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 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 | | // |
6 | | // The following only applies to changes made to this file as part of YugaByte development. |
7 | | // |
8 | | // Portions Copyright (c) YugaByte, Inc. |
9 | | // |
10 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
11 | | // in compliance with the License. You may obtain a copy of the License at |
12 | | // |
13 | | // http://www.apache.org/licenses/LICENSE-2.0 |
14 | | // |
15 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
16 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
17 | | // or implied. See the License for the specific language governing permissions and limitations |
18 | | // under the License. |
19 | | // |
20 | | |
21 | | #ifndef YB_ROCKSDB_TOOLS_SST_DUMP_TOOL_IMP_H |
22 | | #define YB_ROCKSDB_TOOLS_SST_DUMP_TOOL_IMP_H |
23 | | |
24 | | #pragma once |
25 | | #ifndef ROCKSDB_LITE |
26 | | |
27 | | #include "yb/rocksdb/sst_dump_tool.h" |
28 | | |
29 | | #include <memory> |
30 | | #include <string> |
31 | | #include "yb/rocksdb/rocksdb_fwd.h" |
32 | | #include "yb/rocksdb/db/dbformat.h" |
33 | | #include "yb/rocksdb/immutable_options.h" |
34 | | #include "yb/rocksdb/util/file_reader_writer.h" |
35 | | |
36 | | namespace rocksdb { |
37 | | |
38 | | class SstFileReader { |
39 | | public: |
40 | | SstFileReader( |
41 | | const std::string& file_name, bool verify_checksum, OutputFormat format, |
42 | | const DocDBKVFormatter* docdb_formatter = nullptr); |
43 | | ~SstFileReader(); |
44 | | |
45 | | Status ReadSequential(bool print_kv, uint64_t read_num, bool has_from, |
46 | | const std::string& from_key, bool has_to, |
47 | | const std::string& to_key); |
48 | | |
49 | | Status ReadTableProperties( |
50 | | std::shared_ptr<const TableProperties>* table_properties); |
51 | 1 | uint64_t GetReadNumber() { return read_num_; } |
52 | 0 | TableProperties* GetInitTableProperties() { return table_properties_.get(); } |
53 | | |
54 | | Status DumpTable(const std::string& out_filename); |
55 | 5 | Status getStatus() { return init_result_; } |
56 | | |
57 | | int ShowAllCompressionSizes(size_t block_size); |
58 | | |
59 | | private: |
60 | | // Get the TableReader implementation for the sst file |
61 | | Status GetTableReader(const std::string& file_path); |
62 | | Status ReadTableProperties(uint64_t table_magic_number, |
63 | | RandomAccessFileReader* file, uint64_t file_size); |
64 | | |
65 | | uint64_t CalculateCompressedTableSize(const TableBuilderOptions& tb_options, |
66 | | size_t block_size); |
67 | | |
68 | | Status SetTableOptionsByMagicNumber(uint64_t table_magic_number); |
69 | | Status SetOldTableOptions(); |
70 | | |
71 | | // Helper function to call the factory with settings specific to the |
72 | | // factory implementation |
73 | | Status NewTableReader(const ImmutableCFOptions& ioptions, |
74 | | const EnvOptions& soptions, |
75 | | const InternalKeyComparator& internal_comparator, |
76 | | uint64_t file_size, |
77 | | unique_ptr<TableReader>* table_reader); |
78 | | |
79 | | std::string file_name_; |
80 | | uint64_t read_num_; |
81 | | bool verify_checksum_; |
82 | | OutputFormat output_format_ = OutputFormat::kRaw; |
83 | | const DocDBKVFormatter* docdb_kv_formatter_; |
84 | | EnvOptions soptions_; |
85 | | |
86 | | Status init_result_; |
87 | | unique_ptr<TableReader> table_reader_; |
88 | | unique_ptr<RandomAccessFileReader> file_; |
89 | | // options_ and internal_comparator_ will also be used in |
90 | | // ReadSequential internally (specifically, seek-related operations) |
91 | | Options options_; |
92 | | const ImmutableCFOptions ioptions_; |
93 | | std::shared_ptr<InternalKeyComparator> internal_comparator_; |
94 | | unique_ptr<TableProperties> table_properties_; |
95 | | }; |
96 | | |
97 | | } // namespace rocksdb |
98 | | |
99 | | #endif // ROCKSDB_LITE |
100 | | |
101 | | #endif // YB_ROCKSDB_TOOLS_SST_DUMP_TOOL_IMP_H |