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).
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.
10 #include "rocksdb/utilities/leveldb_options.h"
12 #include "rocksdb/cache.h"
13 #include "rocksdb/comparator.h"
14 #include "rocksdb/env.h"
15 #include "rocksdb/filter_policy.h"
16 #include "rocksdb/options.h"
17 #include "rocksdb/table.h"
19 namespace ROCKSDB_NAMESPACE
{
21 LevelDBOptions::LevelDBOptions()
22 : comparator(BytewiseComparator()),
23 create_if_missing(false),
24 error_if_exists(false),
25 paranoid_checks(false),
28 write_buffer_size(4 << 20),
32 block_restart_interval(16),
33 compression(kSnappyCompression
),
34 filter_policy(nullptr) {}
36 Options
ConvertOptions(const LevelDBOptions
& leveldb_options
) {
37 Options options
= Options();
38 options
.create_if_missing
= leveldb_options
.create_if_missing
;
39 options
.error_if_exists
= leveldb_options
.error_if_exists
;
40 options
.paranoid_checks
= leveldb_options
.paranoid_checks
;
41 options
.env
= leveldb_options
.env
;
42 options
.info_log
.reset(leveldb_options
.info_log
);
43 options
.write_buffer_size
= leveldb_options
.write_buffer_size
;
44 options
.max_open_files
= leveldb_options
.max_open_files
;
45 options
.compression
= leveldb_options
.compression
;
47 BlockBasedTableOptions table_options
;
48 table_options
.block_cache
.reset(leveldb_options
.block_cache
);
49 table_options
.block_size
= leveldb_options
.block_size
;
50 table_options
.block_restart_interval
= leveldb_options
.block_restart_interval
;
51 table_options
.filter_policy
.reset(leveldb_options
.filter_policy
);
52 options
.table_factory
.reset(NewBlockBasedTableFactory(table_options
));
57 } // namespace ROCKSDB_NAMESPACE