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.
236 lines
7.6 KiB
236 lines
7.6 KiB
9 years ago
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||
10 years ago
|
// 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
|
||
|
|
||
8 years ago
|
#include <string>
|
||
10 years ago
|
#include <vector>
|
||
8 years ago
|
|
||
8 years ago
|
#include "db/dbformat.h"
|
||
8 years ago
|
#include "options/db_options.h"
|
||
9 years ago
|
#include "rocksdb/options.h"
|
||
|
#include "util/compression.h"
|
||
10 years ago
|
|
||
|
namespace rocksdb {
|
||
|
|
||
8 years ago
|
// ImmutableCFOptions is a data struct used by RocksDB internal. It contains a
|
||
|
// subset of Options that should not be changed during the entire lifetime
|
||
|
// of DB. Raw pointers defined in this struct do not have ownership to the data
|
||
|
// they point to. Options contains shared_ptr to these data.
|
||
|
struct ImmutableCFOptions {
|
||
8 years ago
|
ImmutableCFOptions();
|
||
8 years ago
|
explicit ImmutableCFOptions(const Options& options);
|
||
|
|
||
8 years ago
|
ImmutableCFOptions(const ImmutableDBOptions& db_options,
|
||
|
const ColumnFamilyOptions& cf_options);
|
||
|
|
||
8 years ago
|
CompactionStyle compaction_style;
|
||
|
|
||
8 years ago
|
CompactionPri compaction_pri;
|
||
|
|
||
8 years ago
|
CompactionOptionsUniversal compaction_options_universal;
|
||
|
CompactionOptionsFIFO compaction_options_fifo;
|
||
|
|
||
|
const SliceTransform* prefix_extractor;
|
||
|
|
||
8 years ago
|
const Comparator* user_comparator;
|
||
8 years ago
|
InternalKeyComparator internal_comparator;
|
||
8 years ago
|
|
||
|
MergeOperator* merge_operator;
|
||
|
|
||
|
const CompactionFilter* compaction_filter;
|
||
|
|
||
|
CompactionFilterFactory* compaction_filter_factory;
|
||
|
|
||
8 years ago
|
int min_write_buffer_number_to_merge;
|
||
|
|
||
|
int max_write_buffer_number_to_maintain;
|
||
|
|
||
8 years ago
|
bool inplace_update_support;
|
||
|
|
||
|
UpdateStatus (*inplace_callback)(char* existing_value,
|
||
|
uint32_t* existing_value_size,
|
||
|
Slice delta_value,
|
||
|
std::string* merged_value);
|
||
|
|
||
|
Logger* info_log;
|
||
|
|
||
|
Statistics* statistics;
|
||
|
|
||
|
InfoLogLevel info_log_level;
|
||
|
|
||
|
Env* env;
|
||
|
|
||
|
// Allow the OS to mmap file for reading sst tables. Default: false
|
||
|
bool allow_mmap_reads;
|
||
|
|
||
|
// Allow the OS to mmap file for writing. Default: false
|
||
|
bool allow_mmap_writes;
|
||
|
|
||
|
std::vector<DbPath> db_paths;
|
||
|
|
||
|
MemTableRepFactory* memtable_factory;
|
||
|
|
||
|
TableFactory* table_factory;
|
||
|
|
||
|
Options::TablePropertiesCollectorFactories
|
||
|
table_properties_collector_factories;
|
||
|
|
||
|
bool advise_random_on_open;
|
||
|
|
||
|
// This options is required by PlainTableReader. May need to move it
|
||
|
// to PlainTalbeOptions just like bloom_bits_per_key
|
||
|
uint32_t bloom_locality;
|
||
|
|
||
|
bool purge_redundant_kvs_while_flush;
|
||
|
|
||
|
bool use_fsync;
|
||
|
|
||
|
std::vector<CompressionType> compression_per_level;
|
||
|
|
||
|
CompressionType bottommost_compression;
|
||
|
|
||
|
CompressionOptions compression_opts;
|
||
|
|
||
|
bool level_compaction_dynamic_level_bytes;
|
||
|
|
||
|
Options::AccessHint access_hint_on_compaction_start;
|
||
|
|
||
|
bool new_table_reader_for_compaction_inputs;
|
||
|
|
||
|
size_t compaction_readahead_size;
|
||
|
|
||
|
int num_levels;
|
||
|
|
||
|
bool optimize_filters_for_hits;
|
||
|
|
||
8 years ago
|
bool force_consistency_checks;
|
||
|
|
||
8 years ago
|
// A vector of EventListeners which call-back functions will be called
|
||
|
// when specific RocksDB event happens.
|
||
|
std::vector<std::shared_ptr<EventListener>> listeners;
|
||
|
|
||
|
std::shared_ptr<Cache> row_cache;
|
||
8 years ago
|
|
||
|
uint32_t max_subcompactions;
|
||
8 years ago
|
|
||
|
const SliceTransform* memtable_insert_with_hint_prefix_extractor;
|
||
8 years ago
|
};
|
||
|
|
||
10 years ago
|
struct MutableCFOptions {
|
||
8 years ago
|
explicit MutableCFOptions(const ColumnFamilyOptions& options)
|
||
10 years ago
|
: write_buffer_size(options.write_buffer_size),
|
||
|
max_write_buffer_number(options.max_write_buffer_number),
|
||
|
arena_block_size(options.arena_block_size),
|
||
9 years ago
|
memtable_prefix_bloom_size_ratio(
|
||
|
options.memtable_prefix_bloom_size_ratio),
|
||
9 years ago
|
memtable_huge_page_size(options.memtable_huge_page_size),
|
||
10 years ago
|
max_successive_merges(options.max_successive_merges),
|
||
|
inplace_update_num_locks(options.inplace_update_num_locks),
|
||
|
disable_auto_compactions(options.disable_auto_compactions),
|
||
9 years ago
|
soft_pending_compaction_bytes_limit(
|
||
|
options.soft_pending_compaction_bytes_limit),
|
||
9 years ago
|
hard_pending_compaction_bytes_limit(
|
||
|
options.hard_pending_compaction_bytes_limit),
|
||
10 years ago
|
level0_file_num_compaction_trigger(
|
||
|
options.level0_file_num_compaction_trigger),
|
||
|
level0_slowdown_writes_trigger(options.level0_slowdown_writes_trigger),
|
||
|
level0_stop_writes_trigger(options.level0_stop_writes_trigger),
|
||
9 years ago
|
max_compaction_bytes(options.max_compaction_bytes),
|
||
10 years ago
|
target_file_size_base(options.target_file_size_base),
|
||
|
target_file_size_multiplier(options.target_file_size_multiplier),
|
||
|
max_bytes_for_level_base(options.max_bytes_for_level_base),
|
||
|
max_bytes_for_level_multiplier(options.max_bytes_for_level_multiplier),
|
||
|
max_bytes_for_level_multiplier_additional(
|
||
|
options.max_bytes_for_level_multiplier_additional),
|
||
|
max_sequential_skip_in_iterations(
|
||
|
options.max_sequential_skip_in_iterations),
|
||
|
paranoid_file_checks(options.paranoid_file_checks),
|
||
9 years ago
|
report_bg_io_stats(options.report_bg_io_stats),
|
||
8 years ago
|
compression(options.compression) {
|
||
8 years ago
|
RefreshDerivedOptions(options.num_levels, options.compaction_style);
|
||
10 years ago
|
}
|
||
8 years ago
|
|
||
10 years ago
|
MutableCFOptions()
|
||
10 years ago
|
: write_buffer_size(0),
|
||
|
max_write_buffer_number(0),
|
||
|
arena_block_size(0),
|
||
9 years ago
|
memtable_prefix_bloom_size_ratio(0),
|
||
9 years ago
|
memtable_huge_page_size(0),
|
||
10 years ago
|
max_successive_merges(0),
|
||
|
inplace_update_num_locks(0),
|
||
|
disable_auto_compactions(false),
|
||
9 years ago
|
soft_pending_compaction_bytes_limit(0),
|
||
9 years ago
|
hard_pending_compaction_bytes_limit(0),
|
||
10 years ago
|
level0_file_num_compaction_trigger(0),
|
||
|
level0_slowdown_writes_trigger(0),
|
||
|
level0_stop_writes_trigger(0),
|
||
9 years ago
|
max_compaction_bytes(0),
|
||
10 years ago
|
target_file_size_base(0),
|
||
|
target_file_size_multiplier(0),
|
||
|
max_bytes_for_level_base(0),
|
||
|
max_bytes_for_level_multiplier(0),
|
||
|
max_sequential_skip_in_iterations(0),
|
||
|
paranoid_file_checks(false),
|
||
9 years ago
|
report_bg_io_stats(false),
|
||
8 years ago
|
compression(Snappy_Supported() ? kSnappyCompression : kNoCompression) {}
|
||
10 years ago
|
|
||
10 years ago
|
// Must be called after any change to MutableCFOptions
|
||
8 years ago
|
void RefreshDerivedOptions(int num_levels, CompactionStyle compaction_style);
|
||
|
|
||
|
void RefreshDerivedOptions(const ImmutableCFOptions& ioptions) {
|
||
|
RefreshDerivedOptions(ioptions.num_levels, ioptions.compaction_style);
|
||
|
}
|
||
10 years ago
|
|
||
|
// Get the max file size in a given level.
|
||
|
uint64_t MaxFileSizeForLevel(int level) const;
|
||
10 years ago
|
int MaxBytesMultiplerAdditional(int level) const {
|
||
|
if (level >=
|
||
|
static_cast<int>(max_bytes_for_level_multiplier_additional.size())) {
|
||
|
return 1;
|
||
|
}
|
||
|
return max_bytes_for_level_multiplier_additional[level];
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
void Dump(Logger* log) const;
|
||
|
|
||
10 years ago
|
// Memtable related options
|
||
10 years ago
|
size_t write_buffer_size;
|
||
10 years ago
|
int max_write_buffer_number;
|
||
10 years ago
|
size_t arena_block_size;
|
||
9 years ago
|
double memtable_prefix_bloom_size_ratio;
|
||
9 years ago
|
size_t memtable_huge_page_size;
|
||
10 years ago
|
size_t max_successive_merges;
|
||
10 years ago
|
size_t inplace_update_num_locks;
|
||
10 years ago
|
|
||
|
// Compaction related options
|
||
10 years ago
|
bool disable_auto_compactions;
|
||
9 years ago
|
uint64_t soft_pending_compaction_bytes_limit;
|
||
9 years ago
|
uint64_t hard_pending_compaction_bytes_limit;
|
||
10 years ago
|
int level0_file_num_compaction_trigger;
|
||
|
int level0_slowdown_writes_trigger;
|
||
|
int level0_stop_writes_trigger;
|
||
9 years ago
|
uint64_t max_compaction_bytes;
|
||
10 years ago
|
uint64_t target_file_size_base;
|
||
10 years ago
|
int target_file_size_multiplier;
|
||
|
uint64_t max_bytes_for_level_base;
|
||
8 years ago
|
double max_bytes_for_level_multiplier;
|
||
10 years ago
|
std::vector<int> max_bytes_for_level_multiplier_additional;
|
||
|
|
||
10 years ago
|
// Misc options
|
||
|
uint64_t max_sequential_skip_in_iterations;
|
||
10 years ago
|
bool paranoid_file_checks;
|
||
9 years ago
|
bool report_bg_io_stats;
|
||
9 years ago
|
CompressionType compression;
|
||
10 years ago
|
|
||
10 years ago
|
// Derived options
|
||
|
// Per-level target file size.
|
||
|
std::vector<uint64_t> max_file_size;
|
||
10 years ago
|
};
|
||
|
|
||
8 years ago
|
uint64_t MultiplyCheckOverflow(uint64_t op1, double op2);
|
||
10 years ago
|
|
||
10 years ago
|
} // namespace rocksdb
|