2014-11-24 19:04:16 +01:00
|
|
|
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "rocksdb/sst_dump_tool.h"
|
|
|
|
|
|
|
|
#include <map>
|
2015-07-24 02:05:33 +02:00
|
|
|
#include <sstream>
|
2014-11-24 19:04:16 +01:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "db/dbformat.h"
|
|
|
|
#include "db/memtable.h"
|
|
|
|
#include "db/write_batch_internal.h"
|
|
|
|
#include "rocksdb/db.h"
|
|
|
|
#include "rocksdb/env.h"
|
|
|
|
#include "rocksdb/immutable_options.h"
|
|
|
|
#include "rocksdb/iterator.h"
|
|
|
|
#include "rocksdb/slice_transform.h"
|
|
|
|
#include "rocksdb/status.h"
|
|
|
|
#include "rocksdb/table_properties.h"
|
|
|
|
#include "table/block.h"
|
2015-07-24 02:05:33 +02:00
|
|
|
#include "table/block_based_table_builder.h"
|
2014-11-24 19:04:16 +01:00
|
|
|
#include "table/block_based_table_factory.h"
|
|
|
|
#include "table/block_builder.h"
|
|
|
|
#include "table/format.h"
|
|
|
|
#include "table/meta_blocks.h"
|
|
|
|
#include "table/plain_table_factory.h"
|
Move rate_limiter, write buffering, most perf context instrumentation and most random kill out of Env
Summary: We want to keep Env a think layer for better portability. Less platform dependent codes should be moved out of Env. In this patch, I create a wrapper of file readers and writers, and put rate limiting, write buffering, as well as most perf context instrumentation and random kill out of Env. It will make it easier to maintain multiple Env in the future.
Test Plan: Run all existing unit tests.
Reviewers: anthony, kradhakrishnan, IslamAbdelRahman, yhchiang, igor
Reviewed By: igor
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D42321
2015-07-18 01:16:11 +02:00
|
|
|
#include "util/file_reader_writer.h"
|
2014-11-24 19:04:16 +01:00
|
|
|
#include "util/ldb_cmd.h"
|
|
|
|
#include "util/random.h"
|
|
|
|
#include "util/testharness.h"
|
|
|
|
#include "util/testutil.h"
|
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
class SstFileReader {
|
|
|
|
public:
|
|
|
|
explicit SstFileReader(const std::string& file_name, bool verify_checksum,
|
|
|
|
bool output_hex);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
Status ReadTableProperties(
|
|
|
|
std::shared_ptr<const TableProperties>* table_properties);
|
|
|
|
uint64_t GetReadNumber() { return read_num_; }
|
|
|
|
TableProperties* GetInitTableProperties() { return table_properties_.get(); }
|
|
|
|
|
2014-12-23 22:24:07 +01:00
|
|
|
Status DumpTable(const std::string& out_filename);
|
|
|
|
Status getStatus() { return init_result_; }
|
|
|
|
|
2015-07-24 02:05:33 +02:00
|
|
|
int ShowAllCompressionSizes(size_t block_size);
|
|
|
|
|
2014-11-24 19:04:16 +01:00
|
|
|
private:
|
2015-02-26 01:34:26 +01:00
|
|
|
// Get the TableReader implementation for the sst file
|
|
|
|
Status GetTableReader(const std::string& file_path);
|
2014-11-24 19:04:16 +01:00
|
|
|
Status ReadTableProperties(uint64_t table_magic_number,
|
Move rate_limiter, write buffering, most perf context instrumentation and most random kill out of Env
Summary: We want to keep Env a think layer for better portability. Less platform dependent codes should be moved out of Env. In this patch, I create a wrapper of file readers and writers, and put rate limiting, write buffering, as well as most perf context instrumentation and random kill out of Env. It will make it easier to maintain multiple Env in the future.
Test Plan: Run all existing unit tests.
Reviewers: anthony, kradhakrishnan, IslamAbdelRahman, yhchiang, igor
Reviewed By: igor
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D42321
2015-07-18 01:16:11 +02:00
|
|
|
RandomAccessFileReader* file, uint64_t file_size);
|
2015-07-24 02:05:33 +02:00
|
|
|
|
|
|
|
uint64_t CalculateCompressedTableSize(const TableBuilderOptions& tb_options,
|
|
|
|
size_t block_size);
|
|
|
|
|
2014-11-24 19:04:16 +01:00
|
|
|
Status SetTableOptionsByMagicNumber(uint64_t table_magic_number);
|
|
|
|
Status SetOldTableOptions();
|
|
|
|
|
2015-02-26 01:34:26 +01:00
|
|
|
// 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,
|
Move rate_limiter, write buffering, most perf context instrumentation and most random kill out of Env
Summary: We want to keep Env a think layer for better portability. Less platform dependent codes should be moved out of Env. In this patch, I create a wrapper of file readers and writers, and put rate limiting, write buffering, as well as most perf context instrumentation and random kill out of Env. It will make it easier to maintain multiple Env in the future.
Test Plan: Run all existing unit tests.
Reviewers: anthony, kradhakrishnan, IslamAbdelRahman, yhchiang, igor
Reviewed By: igor
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D42321
2015-07-18 01:16:11 +02:00
|
|
|
uint64_t file_size,
|
2015-02-26 01:34:26 +01:00
|
|
|
unique_ptr<TableReader>* table_reader);
|
|
|
|
|
2014-11-24 19:04:16 +01:00
|
|
|
std::string file_name_;
|
|
|
|
uint64_t read_num_;
|
|
|
|
bool verify_checksum_;
|
|
|
|
bool output_hex_;
|
|
|
|
EnvOptions soptions_;
|
|
|
|
|
|
|
|
Status init_result_;
|
|
|
|
unique_ptr<TableReader> table_reader_;
|
Move rate_limiter, write buffering, most perf context instrumentation and most random kill out of Env
Summary: We want to keep Env a think layer for better portability. Less platform dependent codes should be moved out of Env. In this patch, I create a wrapper of file readers and writers, and put rate limiting, write buffering, as well as most perf context instrumentation and random kill out of Env. It will make it easier to maintain multiple Env in the future.
Test Plan: Run all existing unit tests.
Reviewers: anthony, kradhakrishnan, IslamAbdelRahman, yhchiang, igor
Reviewed By: igor
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D42321
2015-07-18 01:16:11 +02:00
|
|
|
unique_ptr<RandomAccessFileReader> file_;
|
2014-11-24 19:04:16 +01:00
|
|
|
// options_ and internal_comparator_ will also be used in
|
|
|
|
// ReadSequential internally (specifically, seek-related operations)
|
|
|
|
Options options_;
|
|
|
|
const ImmutableCFOptions ioptions_;
|
|
|
|
InternalKeyComparator internal_comparator_;
|
|
|
|
unique_ptr<TableProperties> table_properties_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace rocksdb
|
|
|
|
|
|
|
|
#endif // ROCKSDB_LITE
|