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.
8 #include "rocksdb/sst_dump_tool.h"
12 #include "db/dbformat.h"
13 #include "options/cf_options.h"
14 #include "util/file_reader_writer.h"
20 explicit SstFileReader(const std::string
& file_name
, bool verify_checksum
,
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);
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(); }
33 Status
DumpTable(const std::string
& out_filename
);
34 Status
getStatus() { return init_result_
; }
36 int ShowAllCompressionSizes(size_t block_size
);
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
);
44 uint64_t CalculateCompressedTableSize(const TableBuilderOptions
& tb_options
,
47 Status
SetTableOptionsByMagicNumber(uint64_t table_magic_number
);
48 Status
SetOldTableOptions();
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
,
56 unique_ptr
<TableReader
>* table_reader
);
58 std::string file_name_
;
60 bool verify_checksum_
;
64 // options_ and internal_comparator_ will also be used in
65 // ReadSequential internally (specifically, seek-related operations)
69 unique_ptr
<TableReader
> table_reader_
;
70 unique_ptr
<RandomAccessFileReader
> file_
;
72 const ImmutableCFOptions ioptions_
;
73 InternalKeyComparator internal_comparator_
;
74 unique_ptr
<TableProperties
> table_properties_
;
77 } // namespace rocksdb
79 #endif // ROCKSDB_LITE