2016-02-09 23:12:00 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2014-11-24 18:04:16 +00:00
|
|
|
// 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.
|
|
|
|
#pragma once
|
2015-10-15 00:08:28 +00:00
|
|
|
#ifndef ROCKSDB_LITE
|
2014-11-24 18:04:16 +00:00
|
|
|
|
|
|
|
#include "rocksdb/sst_dump_tool.h"
|
|
|
|
|
2016-01-13 02:20:06 +00:00
|
|
|
#include <memory>
|
2014-11-24 18:04:16 +00:00
|
|
|
#include <string>
|
|
|
|
#include "db/dbformat.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-17 23:16:11 +00:00
|
|
|
#include "util/file_reader_writer.h"
|
2014-11-24 18:04:16 +00:00
|
|
|
|
|
|
|
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 21:24:07 +00:00
|
|
|
Status DumpTable(const std::string& out_filename);
|
|
|
|
Status getStatus() { return init_result_; }
|
|
|
|
|
2015-07-24 00:05:33 +00:00
|
|
|
int ShowAllCompressionSizes(size_t block_size);
|
|
|
|
|
2014-11-24 18:04:16 +00:00
|
|
|
private:
|
2015-02-26 00:34:26 +00:00
|
|
|
// Get the TableReader implementation for the sst file
|
|
|
|
Status GetTableReader(const std::string& file_path);
|
2014-11-24 18:04:16 +00: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-17 23:16:11 +00:00
|
|
|
RandomAccessFileReader* file, uint64_t file_size);
|
2015-07-24 00:05:33 +00:00
|
|
|
|
|
|
|
uint64_t CalculateCompressedTableSize(const TableBuilderOptions& tb_options,
|
|
|
|
size_t block_size);
|
|
|
|
|
2014-11-24 18:04:16 +00:00
|
|
|
Status SetTableOptionsByMagicNumber(uint64_t table_magic_number);
|
|
|
|
Status SetOldTableOptions();
|
|
|
|
|
2015-02-26 00:34:26 +00: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-17 23:16:11 +00:00
|
|
|
uint64_t file_size,
|
2015-02-26 00:34:26 +00:00
|
|
|
unique_ptr<TableReader>* table_reader);
|
|
|
|
|
2014-11-24 18:04:16 +00:00
|
|
|
std::string file_name_;
|
|
|
|
uint64_t read_num_;
|
|
|
|
bool verify_checksum_;
|
|
|
|
bool output_hex_;
|
|
|
|
EnvOptions soptions_;
|
|
|
|
|
|
|
|
// options_ and internal_comparator_ will also be used in
|
|
|
|
// ReadSequential internally (specifically, seek-related operations)
|
|
|
|
Options options_;
|
Adding pin_l0_filter_and_index_blocks_in_cache feature and related fixes.
Summary:
When a block based table file is opened, if prefetch_index_and_filter is true, it will prefetch the index and filter blocks, putting them into the block cache.
What this feature adds: when a L0 block based table file is opened, if pin_l0_filter_and_index_blocks_in_cache is true in the options (and prefetch_index_and_filter is true), then the filter and index blocks aren't released back to the block cache at the end of BlockBasedTableReader::Open(). Instead the table reader takes ownership of them, hence pinning them, ie. the LRU cache will never push them out. Meanwhile in the table reader, further accesses will not hit the block cache, thus avoiding lock contention.
Test Plan:
'export TEST_TMPDIR=/dev/shm/ && DISABLE_JEMALLOC=1 OPT=-g make all valgrind_check -j32' is OK.
I didn't run the Java tests, I don't have Java set up on my devserver.
Reviewers: sdong
Reviewed By: sdong
Subscribers: andrewkr, dhruba
Differential Revision: https://reviews.facebook.net/D56133
2016-04-01 17:42:39 +00:00
|
|
|
|
|
|
|
Status init_result_;
|
|
|
|
unique_ptr<TableReader> table_reader_;
|
|
|
|
unique_ptr<RandomAccessFileReader> file_;
|
|
|
|
|
2014-11-24 18:04:16 +00:00
|
|
|
const ImmutableCFOptions ioptions_;
|
|
|
|
InternalKeyComparator internal_comparator_;
|
|
|
|
unique_ptr<TableProperties> table_properties_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace rocksdb
|
|
|
|
|
|
|
|
#endif // ROCKSDB_LITE
|