fork of https://github.com/oxigraph/rocksdb and https://github.com/facebook/rocksdb for nextgraph and oxigraph
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
196 lines
8.3 KiB
196 lines
8.3 KiB
9 years ago
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||
8 years ago
|
// 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).
|
||
11 years ago
|
//
|
||
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a BSD-style license that can be
|
||
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
||
|
|
||
|
#pragma once
|
||
|
#include <stdint.h>
|
||
|
|
||
11 years ago
|
#include <memory>
|
||
|
#include <string>
|
||
|
|
||
8 years ago
|
#include "db/dbformat.h"
|
||
|
#include "options/options_helper.h"
|
||
|
#include "options/options_parser.h"
|
||
11 years ago
|
#include "rocksdb/flush_block_policy.h"
|
||
11 years ago
|
#include "rocksdb/table.h"
|
||
|
|
||
|
namespace rocksdb {
|
||
|
|
||
|
struct EnvOptions;
|
||
|
|
||
|
class BlockBasedTableBuilder;
|
||
|
|
||
7 years ago
|
// A class used to track actual bytes written from the tail in the recent SST
|
||
|
// file opens, and provide a suggestion for following open.
|
||
|
class TailPrefetchStats {
|
||
|
public:
|
||
|
void RecordEffectiveSize(size_t len);
|
||
|
// 0 indicates no information to determine.
|
||
|
size_t GetSuggestedPrefetchSize();
|
||
|
|
||
|
private:
|
||
|
const static size_t kNumTracked = 32;
|
||
|
size_t records_[kNumTracked];
|
||
|
port::Mutex mutex_;
|
||
|
size_t next_ = 0;
|
||
|
size_t num_records_ = 0;
|
||
|
};
|
||
|
|
||
11 years ago
|
class BlockBasedTableFactory : public TableFactory {
|
||
11 years ago
|
public:
|
||
11 years ago
|
explicit BlockBasedTableFactory(
|
||
11 years ago
|
const BlockBasedTableOptions& table_options = BlockBasedTableOptions());
|
||
11 years ago
|
|
||
11 years ago
|
~BlockBasedTableFactory() {}
|
||
11 years ago
|
|
||
8 years ago
|
const char* Name() const override { return kName.c_str(); }
|
||
11 years ago
|
|
||
9 years ago
|
Status NewTableReader(
|
||
|
const TableReaderOptions& table_reader_options,
|
||
6 years ago
|
std::unique_ptr<RandomAccessFileReader>&& file, uint64_t file_size,
|
||
|
std::unique_ptr<TableReader>* table_reader,
|
||
9 years ago
|
bool prefetch_index_and_filter_in_cache = true) const override;
|
||
11 years ago
|
|
||
11 years ago
|
TableBuilder* NewTableBuilder(
|
||
10 years ago
|
const TableBuilderOptions& table_builder_options,
|
||
9 years ago
|
uint32_t column_family_id, WritableFileWriter* file) const override;
|
||
11 years ago
|
|
||
11 years ago
|
// Sanitizes the specified DB Options.
|
||
10 years ago
|
Status SanitizeOptions(const DBOptions& db_opts,
|
||
|
const ColumnFamilyOptions& cf_opts) const override;
|
||
11 years ago
|
|
||
10 years ago
|
std::string GetPrintableTableOptions() const override;
|
||
|
|
||
8 years ago
|
Status GetOptionString(std::string* opt_string,
|
||
|
const std::string& delimiter) const override;
|
||
|
|
||
9 years ago
|
const BlockBasedTableOptions& table_options() const;
|
||
10 years ago
|
|
||
9 years ago
|
void* GetOptions() override { return &table_options_; }
|
||
|
|
||
8 years ago
|
bool IsDeleteRangeSupported() const override { return true; }
|
||
|
|
||
8 years ago
|
static const std::string kName;
|
||
|
|
||
11 years ago
|
private:
|
||
11 years ago
|
BlockBasedTableOptions table_options_;
|
||
7 years ago
|
mutable TailPrefetchStats tail_prefetch_stats_;
|
||
11 years ago
|
};
|
||
|
|
||
11 years ago
|
extern const std::string kHashIndexPrefixesBlock;
|
||
|
extern const std::string kHashIndexPrefixesMetadataBlock;
|
||
10 years ago
|
extern const std::string kPropTrue;
|
||
|
extern const std::string kPropFalse;
|
||
11 years ago
|
|
||
8 years ago
|
#ifndef ROCKSDB_LITE
|
||
|
extern Status VerifyBlockBasedTableFactory(
|
||
|
const BlockBasedTableFactory* base_tf,
|
||
|
const BlockBasedTableFactory* file_tf,
|
||
|
OptionsSanityCheckLevel sanity_check_level);
|
||
|
|
||
|
static std::unordered_map<std::string, OptionTypeInfo>
|
||
|
block_based_table_type_info = {
|
||
|
/* currently not supported
|
||
|
std::shared_ptr<Cache> block_cache = nullptr;
|
||
|
std::shared_ptr<Cache> block_cache_compressed = nullptr;
|
||
|
*/
|
||
|
{"flush_block_policy_factory",
|
||
|
{offsetof(struct BlockBasedTableOptions, flush_block_policy_factory),
|
||
|
OptionType::kFlushBlockPolicyFactory, OptionVerificationType::kByName,
|
||
|
false, 0}},
|
||
|
{"cache_index_and_filter_blocks",
|
||
|
{offsetof(struct BlockBasedTableOptions,
|
||
|
cache_index_and_filter_blocks),
|
||
|
OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"cache_index_and_filter_blocks_with_high_priority",
|
||
|
{offsetof(struct BlockBasedTableOptions,
|
||
|
cache_index_and_filter_blocks_with_high_priority),
|
||
|
OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"pin_l0_filter_and_index_blocks_in_cache",
|
||
|
{offsetof(struct BlockBasedTableOptions,
|
||
|
pin_l0_filter_and_index_blocks_in_cache),
|
||
|
OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"index_type",
|
||
|
{offsetof(struct BlockBasedTableOptions, index_type),
|
||
|
OptionType::kBlockBasedTableIndexType,
|
||
|
OptionVerificationType::kNormal, false, 0}},
|
||
|
{"hash_index_allow_collision",
|
||
|
{offsetof(struct BlockBasedTableOptions, hash_index_allow_collision),
|
||
|
OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
|
||
7 years ago
|
{"data_block_index_type",
|
||
|
{offsetof(struct BlockBasedTableOptions, data_block_index_type),
|
||
|
OptionType::kBlockBasedTableDataBlockIndexType,
|
||
|
OptionVerificationType::kNormal, false, 0}},
|
||
6 years ago
|
{"index_shortening",
|
||
|
{offsetof(struct BlockBasedTableOptions, index_shortening),
|
||
|
OptionType::kBlockBasedTableIndexShorteningMode,
|
||
|
OptionVerificationType::kNormal, false, 0}},
|
||
6 years ago
|
{"data_block_hash_table_util_ratio",
|
||
|
{offsetof(struct BlockBasedTableOptions,
|
||
|
data_block_hash_table_util_ratio),
|
||
|
OptionType::kDouble, OptionVerificationType::kNormal, false, 0}},
|
||
8 years ago
|
{"checksum",
|
||
|
{offsetof(struct BlockBasedTableOptions, checksum),
|
||
|
OptionType::kChecksumType, OptionVerificationType::kNormal, false,
|
||
|
0}},
|
||
|
{"no_block_cache",
|
||
|
{offsetof(struct BlockBasedTableOptions, no_block_cache),
|
||
|
OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"block_size",
|
||
|
{offsetof(struct BlockBasedTableOptions, block_size),
|
||
|
OptionType::kSizeT, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"block_size_deviation",
|
||
|
{offsetof(struct BlockBasedTableOptions, block_size_deviation),
|
||
|
OptionType::kInt, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"block_restart_interval",
|
||
|
{offsetof(struct BlockBasedTableOptions, block_restart_interval),
|
||
|
OptionType::kInt, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"index_block_restart_interval",
|
||
|
{offsetof(struct BlockBasedTableOptions, index_block_restart_interval),
|
||
|
OptionType::kInt, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"index_per_partition",
|
||
|
{0, OptionType::kUInt64T, OptionVerificationType::kDeprecated, false,
|
||
|
0}},
|
||
|
{"metadata_block_size",
|
||
|
{offsetof(struct BlockBasedTableOptions, metadata_block_size),
|
||
|
OptionType::kUInt64T, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"partition_filters",
|
||
|
{offsetof(struct BlockBasedTableOptions, partition_filters),
|
||
|
OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"filter_policy",
|
||
|
{offsetof(struct BlockBasedTableOptions, filter_policy),
|
||
|
OptionType::kFilterPolicy, OptionVerificationType::kByName, false,
|
||
|
0}},
|
||
|
{"whole_key_filtering",
|
||
|
{offsetof(struct BlockBasedTableOptions, whole_key_filtering),
|
||
|
OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"skip_table_builder_flush",
|
||
|
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated, false,
|
||
|
0}},
|
||
|
{"format_version",
|
||
|
{offsetof(struct BlockBasedTableOptions, format_version),
|
||
|
OptionType::kUInt32T, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"verify_compression",
|
||
|
{offsetof(struct BlockBasedTableOptions, verify_compression),
|
||
|
OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"read_amp_bytes_per_bit",
|
||
|
{offsetof(struct BlockBasedTableOptions, read_amp_bytes_per_bit),
|
||
7 years ago
|
OptionType::kSizeT, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"enable_index_compression",
|
||
|
{offsetof(struct BlockBasedTableOptions, enable_index_compression),
|
||
7 years ago
|
OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"block_align",
|
||
|
{offsetof(struct BlockBasedTableOptions, block_align),
|
||
7 years ago
|
OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}},
|
||
|
{"pin_top_level_index_and_filter",
|
||
|
{offsetof(struct BlockBasedTableOptions,
|
||
|
pin_top_level_index_and_filter),
|
||
7 years ago
|
OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}}};
|
||
8 years ago
|
#endif // !ROCKSDB_LITE
|
||
11 years ago
|
} // namespace rocksdb
|