mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-27 02:44:18 +00:00
b35a2f9146
Summary: Although PR https://github.com/facebook/rocksdb/issues/7032 fixes the construction of the `SstFileDumper` in `GetFileDbIdentities` by setting a proper `Env` of the `Options` passed in the constructor, the file path was not corrected accordingly. This actually disables backup engine to use db session ids in the file names since the `db_session_id` is always empty. Now it is fixed by setting the correct path in the construction of `SstFileDumper`. Furthermore, to preserve the Direct IO property that backup engine already has, parameter `EnvOptions` is added to `GetFileDbIdentities` and `SstFileDumper`. The `BackupUsingDirectIO` test is updated accordingly. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7104 Test Plan: backupable_db_test and some manual tests. Reviewed By: ajkr Differential Revision: D22443245 Pulled By: gg814 fbshipit-source-id: 056a9bb8b82947c5e73d7c3fbb62bfe23af5e562
98 lines
3.4 KiB
C++
98 lines
3.4 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
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include "db/dbformat.h"
|
|
#include "file/writable_file_writer.h"
|
|
#include "options/cf_options.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
|
|
class SstFileDumper {
|
|
public:
|
|
explicit SstFileDumper(const Options& options, const std::string& file_name,
|
|
size_t readahead_size, bool verify_checksum,
|
|
bool output_hex, bool decode_blob_index,
|
|
const EnvOptions& soptions = EnvOptions(),
|
|
bool silent = false);
|
|
|
|
Status ReadSequential(bool print_kv, uint64_t read_num, 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_; }
|
|
|
|
int ShowAllCompressionSizes(
|
|
size_t block_size,
|
|
const std::vector<std::pair<CompressionType, const char*>>&
|
|
compression_types,
|
|
int32_t compress_level_from,
|
|
int32_t compress_level_to);
|
|
|
|
int ShowCompressionSize(
|
|
size_t block_size,
|
|
CompressionType compress_type,
|
|
const CompressionOptions& compress_opt);
|
|
|
|
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);
|
|
|
|
uint64_t CalculateCompressedTableSize(const TableBuilderOptions& tb_options,
|
|
size_t block_size,
|
|
uint64_t* num_data_blocks);
|
|
|
|
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 ImmutableCFOptions& 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_;
|
|
bool output_hex_;
|
|
bool decode_blob_index_;
|
|
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_;
|
|
|
|
const ImmutableCFOptions ioptions_;
|
|
const MutableCFOptions moptions_;
|
|
ReadOptions read_options_;
|
|
InternalKeyComparator internal_comparator_;
|
|
std::unique_ptr<TableProperties> table_properties_;
|
|
};
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|
|
|
|
#endif // ROCKSDB_LITE
|