mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-27 02:44:18 +00:00
d9f4875e52
Summary: BlockBasedTable pre-fetches the filter and index blocks on Open call. This is an optimistic optimization targeted for runtime scenario. The optimization is unnecessary for sst_dump_tool - Added a provision to disable pre-fetching of index and filter blocks in BlockBasedTable - Disabled pre-fetching for the sst_dump tool Stack for reference : #01 0x00000000005ed944 in snappy::InternalUncompress<snappy::SnappyArrayWriter> () from /home/engshare/third-party2/snappy/1.0.3/src/snappy-1.0.3/snappy.cc:148 #02 0x00000000005edeee in snappy::RawUncompress () from /home/engshare/third-party2/snappy/1.0.3/src/snappy-1.0.3/snappy.cc:947 #03 0x00000000004e0b4d in rocksdb::UncompressBlockContents () from /data/users/paultuckfield/rocksdb/./util/compression.h:69 #04 0x00000000004e145c in rocksdb::ReadBlockContents () from /data/users/paultuckfield/rocksdb/table/format.cc:334 #05 0x00000000004ca424 in rocksdb::(anonymous namespace)::ReadBlockFromFile () from /data/users/paultuckfield/rocksdb/table/block_based_table_reader.cc:70 #06 0x00000000004cccad in rocksdb::BlockBasedTable::CreateIndexReader () from /data/users/paultuckfield/rocksdb/table/block_based_table_reader.cc:173 #07 0x00000000004d17e5 in rocksdb::BlockBasedTable::Open () from /data/users/paultuckfield/rocksdb/table/block_based_table_reader.cc:553 #08 0x00000000004c8184 in rocksdb::BlockBasedTableFactory::NewTableReader () from /data/users/paultuckfield/rocksdb/table/block_based_table_factory.cc:51 #09 0x0000000000598463 in rocksdb::SstFileReader::NewTableReader () from /data/users/paultuckfield/rocksdb/util/sst_dump_tool.cc:69 #10 0x00000000005986c2 in rocksdb::SstFileReader::SstFileReader () from /data/users/paultuckfield/rocksdb/util/sst_dump_tool.cc:26 #11 0x0000000000599047 in rocksdb::SSTDumpTool::Run () from /data/users/paultuckfield/rocksdb/util/sst_dump_tool.cc:332 #12 0x0000000000409b06 in main () from /data/users/paultuckfield/rocksdb/tools/sst_dump.cc:12 Test Plan: - Added a unit test to trigger the code. - Also did some manual verification. - Passed all unit tests task #6296048 Reviewers: igor, rven, sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D34041
91 lines
3 KiB
C++
91 lines
3 KiB
C++
// 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>
|
|
#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.h"
|
|
#include "rocksdb/table_properties.h"
|
|
#include "table/block.h"
|
|
#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"
|
|
#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(); }
|
|
|
|
Status DumpTable(const std::string& out_filename);
|
|
Status getStatus() { return init_result_; }
|
|
|
|
private:
|
|
// Get the TableReader implementation for the sst file
|
|
Status GetTableReader(const std::string& file_path);
|
|
Status ReadTableProperties(uint64_t table_magic_number,
|
|
RandomAccessFile* file, uint64_t file_size);
|
|
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,
|
|
unique_ptr<RandomAccessFile>&& file, uint64_t file_size,
|
|
unique_ptr<TableReader>* table_reader);
|
|
|
|
std::string file_name_;
|
|
uint64_t read_num_;
|
|
bool verify_checksum_;
|
|
bool output_hex_;
|
|
EnvOptions soptions_;
|
|
|
|
Status init_result_;
|
|
unique_ptr<TableReader> table_reader_;
|
|
unique_ptr<RandomAccessFile> file_;
|
|
// 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
|