leveldb_options.cc 2.1 KB

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