/Users/deen/code/yugabyte-db/src/yb/rocksdb/utilities/leveldb_options/leveldb_options.cc
Line | Count | Source |
1 | | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | | // This source code is licensed under the BSD-style license found in the |
3 | | // LICENSE file in the root directory of this source tree. An additional grant |
4 | | // of patent rights can be found in the PATENTS file in the same directory. |
5 | | // |
6 | | // The following only applies to changes made to this file as part of YugaByte development. |
7 | | // |
8 | | // Portions Copyright (c) YugaByte, Inc. |
9 | | // |
10 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
11 | | // in compliance with the License. You may obtain a copy of the License at |
12 | | // |
13 | | // http://www.apache.org/licenses/LICENSE-2.0 |
14 | | // |
15 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
16 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
17 | | // or implied. See the License for the specific language governing permissions and limitations |
18 | | // under the License. |
19 | | // |
20 | | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. |
21 | | // Use of this source code is governed by a BSD-style license that can be |
22 | | // found in the LICENSE file. See the AUTHORS file for names of contributors. |
23 | | |
24 | | #include "yb/rocksdb/utilities/leveldb_options.h" |
25 | | #include "yb/rocksdb/cache.h" |
26 | | #include "yb/rocksdb/comparator.h" |
27 | | #include "yb/rocksdb/env.h" |
28 | | #include "yb/rocksdb/filter_policy.h" |
29 | | #include "yb/rocksdb/options.h" |
30 | | #include "yb/rocksdb/table.h" |
31 | | |
32 | | namespace rocksdb { |
33 | | |
34 | | LevelDBOptions::LevelDBOptions() |
35 | | : comparator(BytewiseComparator()), |
36 | | create_if_missing(false), |
37 | | error_if_exists(false), |
38 | | paranoid_checks(false), |
39 | | env(Env::Default()), |
40 | | info_log(nullptr), |
41 | | write_buffer_size(4 << 20), |
42 | | max_open_files(1000), |
43 | | block_cache(nullptr), |
44 | | block_size(4096), |
45 | | block_restart_interval(16), |
46 | | compression(kSnappyCompression), |
47 | 1 | filter_policy(nullptr) {} |
48 | | |
49 | 1 | Options ConvertOptions(const LevelDBOptions& leveldb_options) { |
50 | 1 | Options options = Options(); |
51 | 1 | options.create_if_missing = leveldb_options.create_if_missing; |
52 | 1 | options.error_if_exists = leveldb_options.error_if_exists; |
53 | 1 | options.paranoid_checks = leveldb_options.paranoid_checks; |
54 | 1 | options.env = leveldb_options.env; |
55 | 1 | options.info_log.reset(leveldb_options.info_log); |
56 | 1 | options.write_buffer_size = leveldb_options.write_buffer_size; |
57 | 1 | options.max_open_files = leveldb_options.max_open_files; |
58 | 1 | options.compression = leveldb_options.compression; |
59 | | |
60 | 1 | BlockBasedTableOptions table_options; |
61 | 1 | table_options.block_cache.reset(leveldb_options.block_cache); |
62 | 1 | table_options.block_size = leveldb_options.block_size; |
63 | 1 | table_options.block_restart_interval = leveldb_options.block_restart_interval; |
64 | 1 | table_options.filter_policy.reset(leveldb_options.filter_policy); |
65 | 1 | options.table_factory.reset(NewBlockBasedTableFactory(table_options)); |
66 | | |
67 | 1 | return options; |
68 | 1 | } |
69 | | |
70 | | } // namespace rocksdb |