1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
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).
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
VerifyChecksum();
34 Status
DumpTable(const std::string
& out_filename
);
35 Status
getStatus() { return init_result_
; }
37 int ShowAllCompressionSizes(
39 const std::vector
<std::pair
<CompressionType
, const char*>>&
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
);
48 uint64_t CalculateCompressedTableSize(const TableBuilderOptions
& tb_options
,
51 Status
SetTableOptionsByMagicNumber(uint64_t table_magic_number
);
52 Status
SetOldTableOptions();
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
,
60 unique_ptr
<TableReader
>* table_reader
);
62 std::string file_name_
;
64 bool verify_checksum_
;
68 // options_ and internal_comparator_ will also be used in
69 // ReadSequential internally (specifically, seek-related operations)
73 unique_ptr
<TableReader
> table_reader_
;
74 unique_ptr
<RandomAccessFileReader
> file_
;
76 const ImmutableCFOptions ioptions_
;
77 const MutableCFOptions moptions_
;
78 InternalKeyComparator internal_comparator_
;
79 unique_ptr
<TableProperties
> table_properties_
;
82 } // namespace rocksdb
84 #endif // ROCKSDB_LITE