mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-28 05:43:50 +00:00
3cacd4b4ec
Summary: The definition of the Cache class should not be needed by the vast majority of RocksDB users, so I think it is just distracting to include it in cache.h, which is primarily needed for configuring and creating caches. This change moves the class to a new header advanced_cache.h. It is just cut-and-paste except for modifying the class API comment. In general, operations on shared_ptr<Cache> should continue to work when only a forward declaration of Cache is available, as long as all the Cache instances provided are already shared_ptr. See https://stackoverflow.com/a/17650101/454544 Also, the most common way to customize a Cache is by wrapping an existing implementation, so it makes sense to provide CacheWrapper in the public API. This was a cut-and-paste job except removing the implementation of Name() so that derived classes must provide it. Intended follow-up: consolidate Release() into one function to reduce customization bugs / confusion Pull Request resolved: https://github.com/facebook/rocksdb/pull/11192 Test Plan: `make check` Reviewed By: anand1976 Differential Revision: D43055487 Pulled By: pdillinger fbshipit-source-id: 7b05492df35e0f30b581b4c24c579bc275b6d110
58 lines
2.1 KiB
C++
58 lines
2.1 KiB
C++
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// 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).
|
|
//
|
|
// 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.
|
|
|
|
#include "rocksdb/utilities/leveldb_options.h"
|
|
|
|
#include "rocksdb/advanced_cache.h"
|
|
#include "rocksdb/comparator.h"
|
|
#include "rocksdb/env.h"
|
|
#include "rocksdb/filter_policy.h"
|
|
#include "rocksdb/options.h"
|
|
#include "rocksdb/table.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
|
|
LevelDBOptions::LevelDBOptions()
|
|
: comparator(BytewiseComparator()),
|
|
create_if_missing(false),
|
|
error_if_exists(false),
|
|
paranoid_checks(false),
|
|
env(Env::Default()),
|
|
info_log(nullptr),
|
|
write_buffer_size(4 << 20),
|
|
max_open_files(1000),
|
|
block_cache(nullptr),
|
|
block_size(4096),
|
|
block_restart_interval(16),
|
|
compression(kSnappyCompression),
|
|
filter_policy(nullptr) {}
|
|
|
|
Options ConvertOptions(const LevelDBOptions& leveldb_options) {
|
|
Options options = Options();
|
|
options.create_if_missing = leveldb_options.create_if_missing;
|
|
options.error_if_exists = leveldb_options.error_if_exists;
|
|
options.paranoid_checks = leveldb_options.paranoid_checks;
|
|
options.env = leveldb_options.env;
|
|
options.info_log.reset(leveldb_options.info_log);
|
|
options.write_buffer_size = leveldb_options.write_buffer_size;
|
|
options.max_open_files = leveldb_options.max_open_files;
|
|
options.compression = leveldb_options.compression;
|
|
|
|
BlockBasedTableOptions table_options;
|
|
table_options.block_cache.reset(leveldb_options.block_cache);
|
|
table_options.block_size = leveldb_options.block_size;
|
|
table_options.block_restart_interval = leveldb_options.block_restart_interval;
|
|
table_options.filter_policy.reset(leveldb_options.filter_policy);
|
|
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
|
|
|
return options;
|
|
}
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|