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).
10 #include "db/dbformat.h"
11 #include "file/writable_file_writer.h"
12 #include "options/cf_options.h"
14 namespace ROCKSDB_NAMESPACE
{
18 explicit SstFileDumper(const Options
& options
, const std::string
& file_name
,
19 size_t readahead_size
, bool verify_checksum
,
20 bool output_hex
, bool decode_blob_index
,
21 const EnvOptions
& soptions
= EnvOptions(),
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);
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(); }
34 Status
VerifyChecksum();
35 Status
DumpTable(const std::string
& out_filename
);
36 Status
getStatus() { return init_result_
; }
38 Status
ShowAllCompressionSizes(
40 const std::vector
<std::pair
<CompressionType
, const char*>>&
42 int32_t compress_level_from
, int32_t compress_level_to
,
43 uint32_t max_dict_bytes
, uint32_t zstd_max_train_bytes
);
45 Status
ShowCompressionSize(size_t block_size
, CompressionType compress_type
,
46 const CompressionOptions
& compress_opt
);
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
,
52 RandomAccessFileReader
* file
, uint64_t file_size
,
53 FilePrefetchBuffer
* prefetch_buffer
);
55 Status
CalculateCompressedTableSize(const TableBuilderOptions
& tb_options
,
57 uint64_t* num_data_blocks
,
58 uint64_t* compressed_table_size
);
60 Status
SetTableOptionsByMagicNumber(uint64_t table_magic_number
);
61 Status
SetOldTableOptions();
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
,
69 std::unique_ptr
<TableReader
>* table_reader
);
71 std::string file_name_
;
74 bool decode_blob_index_
;
76 // less verbose in stdout/stderr
79 // options_ and internal_comparator_ will also be used in
80 // ReadSequential internally (specifically, seek-related operations)
84 std::unique_ptr
<TableReader
> table_reader_
;
85 std::unique_ptr
<RandomAccessFileReader
> file_
;
87 const ImmutableCFOptions ioptions_
;
88 const MutableCFOptions moptions_
;
89 ReadOptions read_options_
;
90 InternalKeyComparator internal_comparator_
;
91 std::unique_ptr
<TableProperties
> table_properties_
;
94 } // namespace ROCKSDB_NAMESPACE
96 #endif // ROCKSDB_LITE