2016-02-09 23:12:00 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2014-10-01 23:19: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.
|
|
|
|
|
2016-09-02 21:16:31 +00:00
|
|
|
#include "util/cf_options.h"
|
2015-09-11 21:31:23 +00:00
|
|
|
|
2014-10-17 00:22:28 +00:00
|
|
|
#ifndef __STDC_FORMAT_MACROS
|
|
|
|
#define __STDC_FORMAT_MACROS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
2014-10-01 23:19:16 +00:00
|
|
|
#include <cassert>
|
2016-09-14 04:11:59 +00:00
|
|
|
#include <limits>
|
2014-10-17 00:22:28 +00:00
|
|
|
#include <string>
|
2015-07-11 16:54:33 +00:00
|
|
|
#include "port/port.h"
|
2014-10-17 00:22:28 +00:00
|
|
|
#include "rocksdb/env.h"
|
2014-10-01 23:19:16 +00:00
|
|
|
#include "rocksdb/options.h"
|
2016-09-23 23:34:04 +00:00
|
|
|
#include "util/db_options.h"
|
2014-10-01 23:19:16 +00:00
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
2016-09-02 21:16:31 +00:00
|
|
|
ImmutableCFOptions::ImmutableCFOptions(const Options& options)
|
2016-09-23 23:34:04 +00:00
|
|
|
: ImmutableCFOptions(ImmutableDBOptions(options), options) {}
|
|
|
|
|
|
|
|
ImmutableCFOptions::ImmutableCFOptions(const ImmutableDBOptions& db_options,
|
|
|
|
const ColumnFamilyOptions& cf_options)
|
|
|
|
: compaction_style(cf_options.compaction_style),
|
|
|
|
compaction_pri(cf_options.compaction_pri),
|
|
|
|
compaction_options_universal(cf_options.compaction_options_universal),
|
|
|
|
compaction_options_fifo(cf_options.compaction_options_fifo),
|
|
|
|
prefix_extractor(cf_options.prefix_extractor.get()),
|
2016-10-21 18:31:42 +00:00
|
|
|
user_comparator(cf_options.comparator),
|
2016-11-21 20:07:09 +00:00
|
|
|
internal_comparator(InternalKeyComparator(cf_options.comparator)),
|
2016-09-23 23:34:04 +00:00
|
|
|
merge_operator(cf_options.merge_operator.get()),
|
|
|
|
compaction_filter(cf_options.compaction_filter),
|
|
|
|
compaction_filter_factory(cf_options.compaction_filter_factory.get()),
|
|
|
|
min_write_buffer_number_to_merge(
|
|
|
|
cf_options.min_write_buffer_number_to_merge),
|
|
|
|
max_write_buffer_number_to_maintain(
|
|
|
|
cf_options.max_write_buffer_number_to_maintain),
|
|
|
|
inplace_update_support(cf_options.inplace_update_support),
|
|
|
|
inplace_callback(cf_options.inplace_callback),
|
|
|
|
info_log(db_options.info_log.get()),
|
|
|
|
statistics(db_options.statistics.get()),
|
|
|
|
env(db_options.env),
|
|
|
|
allow_mmap_reads(db_options.allow_mmap_reads),
|
|
|
|
allow_mmap_writes(db_options.allow_mmap_writes),
|
|
|
|
db_paths(db_options.db_paths),
|
|
|
|
memtable_factory(cf_options.memtable_factory.get()),
|
|
|
|
table_factory(cf_options.table_factory.get()),
|
2016-09-02 21:16:31 +00:00
|
|
|
table_properties_collector_factories(
|
2016-09-23 23:34:04 +00:00
|
|
|
cf_options.table_properties_collector_factories),
|
|
|
|
advise_random_on_open(db_options.advise_random_on_open),
|
|
|
|
bloom_locality(cf_options.bloom_locality),
|
|
|
|
purge_redundant_kvs_while_flush(
|
|
|
|
cf_options.purge_redundant_kvs_while_flush),
|
|
|
|
disable_data_sync(db_options.disable_data_sync),
|
|
|
|
use_fsync(db_options.use_fsync),
|
|
|
|
compression_per_level(cf_options.compression_per_level),
|
|
|
|
bottommost_compression(cf_options.bottommost_compression),
|
|
|
|
compression_opts(cf_options.compression_opts),
|
2016-09-02 21:16:31 +00:00
|
|
|
level_compaction_dynamic_level_bytes(
|
2016-09-23 23:34:04 +00:00
|
|
|
cf_options.level_compaction_dynamic_level_bytes),
|
|
|
|
access_hint_on_compaction_start(
|
|
|
|
db_options.access_hint_on_compaction_start),
|
2016-09-02 21:16:31 +00:00
|
|
|
new_table_reader_for_compaction_inputs(
|
2016-09-23 23:34:04 +00:00
|
|
|
db_options.new_table_reader_for_compaction_inputs),
|
|
|
|
compaction_readahead_size(db_options.compaction_readahead_size),
|
|
|
|
num_levels(cf_options.num_levels),
|
|
|
|
optimize_filters_for_hits(cf_options.optimize_filters_for_hits),
|
2016-10-08 00:21:45 +00:00
|
|
|
force_consistency_checks(cf_options.force_consistency_checks),
|
2016-09-23 23:34:04 +00:00
|
|
|
listeners(db_options.listeners),
|
|
|
|
row_cache(db_options.row_cache),
|
2016-11-14 02:58:17 +00:00
|
|
|
max_subcompactions(db_options.max_subcompactions),
|
|
|
|
memtable_insert_with_hint_prefix_extractor(
|
|
|
|
cf_options.memtable_insert_with_hint_prefix_extractor.get()) {}
|
2016-09-02 21:16:31 +00:00
|
|
|
|
2014-10-01 23:19:16 +00:00
|
|
|
// Multiple two operands. If they overflow, return op1.
|
2016-11-02 04:05:32 +00:00
|
|
|
uint64_t MultiplyCheckOverflow(uint64_t op1, double op2) {
|
|
|
|
if (op1 == 0 || op2 <= 0) {
|
2014-10-01 23:19:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2016-11-02 04:05:32 +00:00
|
|
|
if (port::kMaxUint64 / op1 < op2) {
|
2014-10-01 23:19:16 +00:00
|
|
|
return op1;
|
|
|
|
}
|
2016-11-02 04:05:32 +00:00
|
|
|
return static_cast<uint64_t>(op1 * op2);
|
2014-10-01 23:19:16 +00:00
|
|
|
}
|
|
|
|
|
2016-09-14 04:11:59 +00:00
|
|
|
void MutableCFOptions::RefreshDerivedOptions(int num_levels,
|
|
|
|
CompactionStyle compaction_style) {
|
|
|
|
max_file_size.resize(num_levels);
|
|
|
|
for (int i = 0; i < num_levels; ++i) {
|
|
|
|
if (i == 0 && compaction_style == kCompactionStyleUniversal) {
|
2014-10-01 23:19:16 +00:00
|
|
|
max_file_size[i] = ULLONG_MAX;
|
|
|
|
} else if (i > 1) {
|
|
|
|
max_file_size[i] = MultiplyCheckOverflow(max_file_size[i - 1],
|
|
|
|
target_file_size_multiplier);
|
|
|
|
} else {
|
|
|
|
max_file_size[i] = target_file_size_base;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t MutableCFOptions::MaxFileSizeForLevel(int level) const {
|
|
|
|
assert(level >= 0);
|
|
|
|
assert(level < (int)max_file_size.size());
|
|
|
|
return max_file_size[level];
|
|
|
|
}
|
|
|
|
|
2014-10-17 00:22:28 +00:00
|
|
|
void MutableCFOptions::Dump(Logger* log) const {
|
|
|
|
// Memtable related options
|
2015-07-13 19:11:05 +00:00
|
|
|
Log(log, " write_buffer_size: %" ROCKSDB_PRIszt,
|
|
|
|
write_buffer_size);
|
2014-10-17 00:22:28 +00:00
|
|
|
Log(log, " max_write_buffer_number: %d",
|
|
|
|
max_write_buffer_number);
|
2015-07-13 19:11:05 +00:00
|
|
|
Log(log, " arena_block_size: %" ROCKSDB_PRIszt,
|
|
|
|
arena_block_size);
|
2016-06-04 00:02:10 +00:00
|
|
|
Log(log, " memtable_prefix_bloom_ratio: %f",
|
|
|
|
memtable_prefix_bloom_size_ratio);
|
2016-09-14 04:11:59 +00:00
|
|
|
Log(log, " memtable_huge_page_size: %" ROCKSDB_PRIszt,
|
2016-07-27 01:05:30 +00:00
|
|
|
memtable_huge_page_size);
|
2015-07-01 23:13:49 +00:00
|
|
|
Log(log, " max_successive_merges: %" ROCKSDB_PRIszt,
|
2014-10-17 00:22:28 +00:00
|
|
|
max_successive_merges);
|
2016-09-14 04:11:59 +00:00
|
|
|
Log(log, " inplace_update_num_locks: %" ROCKSDB_PRIszt,
|
|
|
|
inplace_update_num_locks);
|
2014-10-17 00:22:28 +00:00
|
|
|
Log(log, " disable_auto_compactions: %d",
|
|
|
|
disable_auto_compactions);
|
2015-11-19 02:10:20 +00:00
|
|
|
Log(log, " soft_pending_compaction_bytes_limit: %" PRIu64,
|
|
|
|
soft_pending_compaction_bytes_limit);
|
2015-09-11 21:31:23 +00:00
|
|
|
Log(log, " hard_pending_compaction_bytes_limit: %" PRIu64,
|
|
|
|
hard_pending_compaction_bytes_limit);
|
2014-10-17 00:22:28 +00:00
|
|
|
Log(log, " level0_file_num_compaction_trigger: %d",
|
|
|
|
level0_file_num_compaction_trigger);
|
|
|
|
Log(log, " level0_slowdown_writes_trigger: %d",
|
|
|
|
level0_slowdown_writes_trigger);
|
|
|
|
Log(log, " level0_stop_writes_trigger: %d",
|
|
|
|
level0_stop_writes_trigger);
|
2016-06-16 23:02:52 +00:00
|
|
|
Log(log, " max_compaction_bytes: %" PRIu64,
|
|
|
|
max_compaction_bytes);
|
2014-11-11 21:47:22 +00:00
|
|
|
Log(log, " target_file_size_base: %" PRIu64,
|
2014-10-17 00:22:28 +00:00
|
|
|
target_file_size_base);
|
|
|
|
Log(log, " target_file_size_multiplier: %d",
|
|
|
|
target_file_size_multiplier);
|
|
|
|
Log(log, " max_bytes_for_level_base: %" PRIu64,
|
|
|
|
max_bytes_for_level_base);
|
2016-11-02 04:05:32 +00:00
|
|
|
Log(log, " max_bytes_for_level_multiplier: %f",
|
2014-10-17 00:22:28 +00:00
|
|
|
max_bytes_for_level_multiplier);
|
|
|
|
std::string result;
|
|
|
|
char buf[10];
|
|
|
|
for (const auto m : max_bytes_for_level_multiplier_additional) {
|
|
|
|
snprintf(buf, sizeof(buf), "%d, ", m);
|
|
|
|
result += buf;
|
|
|
|
}
|
2016-10-08 00:16:13 +00:00
|
|
|
if (result.size() >= 2) {
|
|
|
|
result.resize(result.size() - 2);
|
|
|
|
} else {
|
|
|
|
result = "";
|
|
|
|
}
|
|
|
|
|
2014-10-17 00:22:28 +00:00
|
|
|
Log(log, "max_bytes_for_level_multiplier_additional: %s", result.c_str());
|
2014-11-18 18:20:10 +00:00
|
|
|
Log(log, " verify_checksums_in_compaction: %d",
|
|
|
|
verify_checksums_in_compaction);
|
2014-10-23 22:37:14 +00:00
|
|
|
Log(log, " max_sequential_skip_in_iterations: %" PRIu64,
|
|
|
|
max_sequential_skip_in_iterations);
|
2016-09-14 04:11:59 +00:00
|
|
|
Log(log, " paranoid_file_checks: %d",
|
|
|
|
paranoid_file_checks);
|
|
|
|
Log(log, " report_bg_io_stats: %d", report_bg_io_stats);
|
|
|
|
Log(log, " compression: %d",
|
|
|
|
static_cast<int>(compression));
|
|
|
|
Log(log, " min_partial_merge_operands: %" PRIu32,
|
|
|
|
min_partial_merge_operands);
|
2014-10-17 00:22:28 +00:00
|
|
|
}
|
|
|
|
|
2014-10-01 23:19:16 +00:00
|
|
|
} // namespace rocksdb
|