forked from continuwuation/rocksdb
Summary: Add a new option in sst_dump command to show seq no and value type in raw mode Pull Request resolved: https://github.com/facebook/rocksdb/pull/14166 Test Plan: Sample output ``` sst_dump --file=rocksdb_crashtest_blackbox/000010.sst --command=raw --show_sequence_number_type ... Range deletions: -------------------------------------- HEX 000000000000038D000000000000012B000000000000029A seq: 3016892 type: 15 : 000000000000038D000000000000012B000000000000029E ASCII \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 + \0 \0 \0 \0 \0 \0 : \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 + \0 \0 \0 \0 \0 \0 ------ Data Block # 1 @ 0073 -------------------------------------- HEX 000000000000038D000000000000012B000000000000029D seq: 3004554 type: 0 : ASCII \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 + \0 \0 \0 \0 \0 \0 : ------ HEX 000000000000038D000000000000012B000000000000029D seq: 0 type: 1 : 03000000070605040B0A09080F0E0D0C13121110171615141B1A19181F1E1D1C ASCII \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 + \0 \0 \0 \0 \0 \0 : \0 \0 \0 ``` Reviewed By: hx235 Differential Revision: D88396223 Pulled By: xingbowang fbshipit-source-id: b006cd7f51f941951349e4ec60ed5ef1e838919d
104 lines
4.1 KiB
C++
104 lines
4.1 KiB
C++
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "db/dbformat.h"
|
|
#include "file/writable_file_writer.h"
|
|
#include "options/cf_options.h"
|
|
#include "rocksdb/advanced_options.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
|
|
class SstFileDumper {
|
|
public:
|
|
explicit SstFileDumper(const Options& options, const std::string& file_name,
|
|
Temperature file_temp, size_t readahead_size,
|
|
bool verify_checksum, bool output_hex,
|
|
bool decode_blob_index,
|
|
const EnvOptions& soptions = EnvOptions(),
|
|
bool silent = false,
|
|
bool show_sequence_number_type = false);
|
|
|
|
// read_num_limit limits the total number of keys read. If read_num_limit = 0,
|
|
// then there is no limit. If read_num_limit = 0 or
|
|
// std::numeric_limits<uint64_t>::max(), has_from and has_to are false, then
|
|
// the number of keys read is compared with `num_entries` field in table
|
|
// properties. A Corruption status is returned if they do not match.
|
|
Status ReadSequential(bool print_kv, uint64_t read_num_limit, bool has_from,
|
|
const std::string& from_key, bool has_to,
|
|
const std::string& to_key,
|
|
bool use_from_as_prefix = false);
|
|
|
|
Status ReadTableProperties(
|
|
std::shared_ptr<const TableProperties>* table_properties);
|
|
uint64_t GetReadNumber() { return read_num_; }
|
|
TableProperties* GetInitTableProperties() { return table_properties_.get(); }
|
|
|
|
Status VerifyChecksum();
|
|
Status DumpTable(const std::string& out_filename);
|
|
Status getStatus() { return init_result_; }
|
|
|
|
Status ShowAllCompressionSizes(
|
|
const std::vector<CompressionType>& compression_types,
|
|
int32_t compress_level_from, int32_t compress_level_to);
|
|
|
|
Status ShowCompressionSize(CompressionType compress_type,
|
|
const CompressionOptions& compress_opt);
|
|
|
|
BlockContents& GetMetaIndexContents() { return meta_index_contents_; }
|
|
|
|
private:
|
|
// Get the TableReader implementation for the sst file
|
|
Status GetTableReader(const std::string& file_path);
|
|
Status ReadTableProperties(uint64_t table_magic_number,
|
|
RandomAccessFileReader* file, uint64_t file_size,
|
|
FilePrefetchBuffer* prefetch_buffer);
|
|
|
|
Status CalculateCompressedTableSize(const TableBuilderOptions& tb_options,
|
|
TableProperties* props,
|
|
std::chrono::microseconds* write_time,
|
|
std::chrono::microseconds* read_time);
|
|
|
|
Status SetTableOptionsByMagicNumber(uint64_t table_magic_number);
|
|
Status SetOldTableOptions();
|
|
|
|
// Helper function to call the factory with settings specific to the
|
|
// factory implementation
|
|
Status NewTableReader(const ImmutableOptions& ioptions,
|
|
const EnvOptions& soptions,
|
|
const InternalKeyComparator& internal_comparator,
|
|
uint64_t file_size,
|
|
std::unique_ptr<TableReader>* table_reader);
|
|
|
|
std::string file_name_;
|
|
uint64_t read_num_;
|
|
Temperature file_temp_;
|
|
bool output_hex_;
|
|
bool decode_blob_index_;
|
|
bool show_sequence_number_type_;
|
|
EnvOptions soptions_;
|
|
// less verbose in stdout/stderr
|
|
bool silent_;
|
|
|
|
// options_ and internal_comparator_ will also be used in
|
|
// ReadSequential internally (specifically, seek-related operations)
|
|
Options options_;
|
|
|
|
Status init_result_;
|
|
std::unique_ptr<TableReader> table_reader_;
|
|
std::unique_ptr<RandomAccessFileReader> file_;
|
|
|
|
ImmutableOptions ioptions_;
|
|
const MutableCFOptions moptions_;
|
|
ReadOptions read_options_;
|
|
InternalKeyComparator internal_comparator_;
|
|
std::unique_ptr<TableProperties> table_properties_;
|
|
BlockContents meta_index_contents_;
|
|
};
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|