]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/utilities/leveldb_options/leveldb_options.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rocksdb / utilities / leveldb_options / leveldb_options.cc
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
5 //
6 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file. See the AUTHORS file for names of contributors.
9
10 #include "rocksdb/utilities/leveldb_options.h"
11 #include "rocksdb/cache.h"
12 #include "rocksdb/comparator.h"
13 #include "rocksdb/env.h"
14 #include "rocksdb/filter_policy.h"
15 #include "rocksdb/options.h"
16 #include "rocksdb/table.h"
17
18 namespace rocksdb {
19
20 LevelDBOptions::LevelDBOptions()
21 : comparator(BytewiseComparator()),
22 create_if_missing(false),
23 error_if_exists(false),
24 paranoid_checks(false),
25 env(Env::Default()),
26 info_log(nullptr),
27 write_buffer_size(4 << 20),
28 max_open_files(1000),
29 block_cache(nullptr),
30 block_size(4096),
31 block_restart_interval(16),
32 compression(kSnappyCompression),
33 filter_policy(nullptr) {}
34
35 Options ConvertOptions(const LevelDBOptions& leveldb_options) {
36 Options options = Options();
37 options.create_if_missing = leveldb_options.create_if_missing;
38 options.error_if_exists = leveldb_options.error_if_exists;
39 options.paranoid_checks = leveldb_options.paranoid_checks;
40 options.env = leveldb_options.env;
41 options.info_log.reset(leveldb_options.info_log);
42 options.write_buffer_size = leveldb_options.write_buffer_size;
43 options.max_open_files = leveldb_options.max_open_files;
44 options.compression = leveldb_options.compression;
45
46 BlockBasedTableOptions table_options;
47 table_options.block_cache.reset(leveldb_options.block_cache);
48 table_options.block_size = leveldb_options.block_size;
49 table_options.block_restart_interval = leveldb_options.block_restart_interval;
50 table_options.filter_policy.reset(leveldb_options.filter_policy);
51 options.table_factory.reset(NewBlockBasedTableFactory(table_options));
52
53 return options;
54 }
55
56 } // namespace rocksdb