mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-30 04:41:49 +00:00
e7c434c364
Summary: Summary: Added a new option to ColumnFamllyOptions - optimize_filters_for_hits. This option can be used in the case where most accesses to the store are key hits and we dont need to optimize performance for key misses. This is useful when you have a very large database and most of your lookups succeed. The option allows the store to not store and use filters in the last level (the largest level which contains data). These filters can take a large amount of space for large databases (in memory and on-disk). For the last level, these filters are only useful for key misses and not for key hits. If we are not optimizing for key misses, we can choose to not store these filters for that level. This option is only provided for BlockBasedTable. We skip the filters when we are compacting Test Plan: 1. Modified db_test toalso run tests with an additonal option (skip_filters_on_last_level) 2. Added another unit test to db_test which specifically tests that filters are being skipped Reviewers: rven, igor, sdong Reviewed By: sdong Subscribers: lgalanis, yoshinorim, MarkCallaghan, rven, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D33717
96 lines
3.5 KiB
C++
96 lines
3.5 KiB
C++
// 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.
|
|
|
|
#ifndef ROCKSDB_LITE
|
|
#include "table/plain_table_factory.h"
|
|
|
|
#include <memory>
|
|
#include <stdint.h>
|
|
#include "db/dbformat.h"
|
|
#include "table/plain_table_builder.h"
|
|
#include "table/plain_table_reader.h"
|
|
#include "port/port.h"
|
|
|
|
namespace rocksdb {
|
|
|
|
Status PlainTableFactory::NewTableReader(const ImmutableCFOptions& ioptions,
|
|
const EnvOptions& env_options,
|
|
const InternalKeyComparator& icomp,
|
|
unique_ptr<RandomAccessFile>&& file,
|
|
uint64_t file_size,
|
|
unique_ptr<TableReader>* table) const {
|
|
return PlainTableReader::Open(ioptions, env_options, icomp, std::move(file),
|
|
file_size, table, bloom_bits_per_key_,
|
|
hash_table_ratio_, index_sparseness_,
|
|
huge_page_tlb_size_, full_scan_mode_);
|
|
}
|
|
|
|
TableBuilder* PlainTableFactory::NewTableBuilder(
|
|
const ImmutableCFOptions& ioptions,
|
|
const InternalKeyComparator& internal_comparator, WritableFile* file,
|
|
const CompressionType, const CompressionOptions&,
|
|
const bool skip_filters) const {
|
|
|
|
// Ignore the skip_filters flag. PlainTable format is optimized for small
|
|
// in-memory dbs. The skip_filters optimization is not useful for plain
|
|
// tables
|
|
//
|
|
return new PlainTableBuilder(ioptions, file, user_key_len_, encoding_type_,
|
|
index_sparseness_, bloom_bits_per_key_, 6,
|
|
huge_page_tlb_size_, hash_table_ratio_,
|
|
store_index_in_file_);
|
|
}
|
|
|
|
std::string PlainTableFactory::GetPrintableTableOptions() const {
|
|
std::string ret;
|
|
ret.reserve(20000);
|
|
const int kBufferSize = 200;
|
|
char buffer[kBufferSize];
|
|
|
|
snprintf(buffer, kBufferSize, " user_key_len: %u\n",
|
|
user_key_len_);
|
|
ret.append(buffer);
|
|
snprintf(buffer, kBufferSize, " bloom_bits_per_key: %d\n",
|
|
bloom_bits_per_key_);
|
|
ret.append(buffer);
|
|
snprintf(buffer, kBufferSize, " hash_table_ratio: %lf\n",
|
|
hash_table_ratio_);
|
|
ret.append(buffer);
|
|
snprintf(buffer, kBufferSize, " index_sparseness: %zu\n",
|
|
index_sparseness_);
|
|
ret.append(buffer);
|
|
snprintf(buffer, kBufferSize, " huge_page_tlb_size: %zu\n",
|
|
huge_page_tlb_size_);
|
|
ret.append(buffer);
|
|
snprintf(buffer, kBufferSize, " encoding_type: %d\n",
|
|
encoding_type_);
|
|
ret.append(buffer);
|
|
snprintf(buffer, kBufferSize, " full_scan_mode: %d\n",
|
|
full_scan_mode_);
|
|
ret.append(buffer);
|
|
snprintf(buffer, kBufferSize, " store_index_in_file: %d\n",
|
|
store_index_in_file_);
|
|
ret.append(buffer);
|
|
return ret;
|
|
}
|
|
|
|
extern TableFactory* NewPlainTableFactory(const PlainTableOptions& options) {
|
|
return new PlainTableFactory(options);
|
|
}
|
|
|
|
const std::string PlainTablePropertyNames::kPrefixExtractorName =
|
|
"rocksdb.prefix.extractor.name";
|
|
|
|
const std::string PlainTablePropertyNames::kEncodingType =
|
|
"rocksdb.plain.table.encoding.type";
|
|
|
|
const std::string PlainTablePropertyNames::kBloomVersion =
|
|
"rocksdb.plain.table.bloom.version";
|
|
|
|
const std::string PlainTablePropertyNames::kNumBloomBlocks =
|
|
"rocksdb.plain.table.bloom.numblocks";
|
|
|
|
} // namespace rocksdb
|
|
#endif // ROCKSDB_LITE
|