@nxtedition/rocksdb 7.0.31 → 7.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/binding.cc CHANGED
@@ -814,9 +814,8 @@ NAPI_METHOD(db_open) {
814
814
 
815
815
  rocksdb::Options dbOptions;
816
816
 
817
- const auto parallelismValue = Uint32Property(env, argv[2], "parallelism")
818
- .value_or(std::max<uint32_t>(1, std::thread::hardware_concurrency() / 2));
819
- dbOptions.IncreaseParallelism(parallelismValue);
817
+ dbOptions.IncreaseParallelism(Uint32Property(env, argv[2], "parallelism")
818
+ .value_or(std::max<uint32_t>(1, std::thread::hardware_concurrency() / 2)));
820
819
 
821
820
  dbOptions.create_if_missing = BooleanProperty(env, argv[2], "createIfMissing").value_or(true);
822
821
  dbOptions.error_if_exists = BooleanProperty(env, argv[2], "errorIfExists").value_or(false);
@@ -824,8 +823,6 @@ NAPI_METHOD(db_open) {
824
823
  dbOptions.write_dbid_to_manifest = true;
825
824
  dbOptions.use_adaptive_mutex = true; // We don't have soo many threads in the libuv thread pool...
826
825
  dbOptions.enable_pipelined_write = false; // We only write in the main thread...
827
- dbOptions.max_background_jobs = Uint32Property(env, argv[2], "maxBackgroundJobs")
828
- .value_or(std::max<uint32_t>(2, std::thread::hardware_concurrency() / 8));
829
826
  dbOptions.WAL_ttl_seconds = Uint32Property(env, argv[2], "walTTL").value_or(0) / 1e3;
830
827
  dbOptions.WAL_size_limit_MB = Uint32Property(env, argv[2], "walSizeLimit").value_or(0) / 1e6;
831
828
  dbOptions.wal_compression = BooleanProperty(env, argv[2], "walCompression").value_or(false)
@@ -836,46 +833,6 @@ NAPI_METHOD(db_open) {
836
833
  dbOptions.fail_if_options_file_error = true;
837
834
  dbOptions.manual_wal_flush = BooleanProperty(env, argv[2], "manualWalFlush").value_or(false);
838
835
 
839
- napi_value ret;
840
- NAPI_STATUS_THROWS(napi_create_object(env, &ret));
841
- {
842
- napi_value parallelism;
843
- NAPI_STATUS_THROWS(napi_create_int64(env, parallelismValue, &parallelism));
844
- NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "parallelism", parallelism));
845
-
846
- napi_value createIfMissing;
847
- NAPI_STATUS_THROWS(napi_get_boolean(env, dbOptions.create_if_missing, &createIfMissing));
848
- NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "createIfMissing", createIfMissing));
849
-
850
- napi_value errorIfExists;
851
- NAPI_STATUS_THROWS(napi_get_boolean(env, dbOptions.error_if_exists, &errorIfExists));
852
- NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "errorIfExists", errorIfExists));
853
-
854
- napi_value maxBackgroundJobs;
855
- NAPI_STATUS_THROWS(napi_create_int64(env, dbOptions.max_background_jobs, &maxBackgroundJobs));
856
- NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "maxBackgroundJobs", maxBackgroundJobs));
857
-
858
- napi_value walTTL;
859
- NAPI_STATUS_THROWS(napi_create_int64(env, dbOptions.WAL_ttl_seconds * 1e3, &walTTL));
860
- NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "walTTL", walTTL));
861
-
862
- napi_value walSizeLimit;
863
- NAPI_STATUS_THROWS(napi_create_int64(env, dbOptions.WAL_size_limit_MB * 1e6, &walSizeLimit));
864
- NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "walSizeLimit", walSizeLimit));
865
-
866
- napi_value walCompression;
867
- NAPI_STATUS_THROWS(napi_create_int64(env, dbOptions.wal_compression, &walCompression));
868
- NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "walCompression", walCompression));
869
-
870
- napi_value unorderedWrite;
871
- NAPI_STATUS_THROWS(napi_get_boolean(env, dbOptions.error_if_exists, &unorderedWrite));
872
- NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "unorderedWrite", unorderedWrite));
873
-
874
- napi_value manualWalFlush;
875
- NAPI_STATUS_THROWS(napi_create_int64(env, dbOptions.manual_wal_flush, &manualWalFlush));
876
- NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "manualWalFlush", manualWalFlush));
877
- }
878
-
879
836
  // TODO (feat): dbOptions.listeners
880
837
 
881
838
  const auto infoLogLevel = StringProperty(env, argv[2], "infoLogLevel").value_or("");
@@ -939,7 +896,7 @@ NAPI_METHOD(db_open) {
939
896
  auto worker = new OpenWorker(env, database, argv[3], location, dbOptions, columnsFamilies);
940
897
  worker->Queue(env);
941
898
 
942
- return ret;
899
+ return 0;
943
900
  }
944
901
 
945
902
  struct CloseWorker final : public Worker {
package/index.js CHANGED
@@ -6,11 +6,11 @@ const fs = require('fs')
6
6
  const binding = require('./binding')
7
7
  const { ChainedBatch } = require('./chained-batch')
8
8
  const { Iterator } = require('./iterator')
9
+ const os = require('os')
9
10
 
10
11
  const kContext = Symbol('context')
11
12
  const kColumns = Symbol('columns')
12
13
  const kLocation = Symbol('location')
13
- const kOptions = Symbol('options')
14
14
 
15
15
  class RocksLevel extends AbstractLevel {
16
16
  constructor (location, options, _) {
@@ -25,6 +25,21 @@ class RocksLevel extends AbstractLevel {
25
25
  throw new TypeError("The first argument 'location' must be a non-empty string")
26
26
  }
27
27
 
28
+ options = {
29
+ ...options, // TODO (fix): Other defaults...
30
+ parallelism: options?.parallelism ?? Math.max(1, os.cpus().length / 2),
31
+ createIfMissing: options?.createIfMissing ?? true,
32
+ errorIfExists: options?.errorIfExists ?? false,
33
+ walTTL: options?.walTTL ?? 0,
34
+ walSizeLimit: options?.walSizeLimit ?? 0,
35
+ walCompression: options?.walCompression ?? false,
36
+ unorderedWrite: options?.unorderedWrite ?? false,
37
+ manualWalFlush: options?.manualWalFlush ?? false,
38
+ infoLogLevel: options?.infoLogLevel ?? ''
39
+ }
40
+
41
+ // TODO (fix): Check options.
42
+
28
43
  super({
29
44
  encodings: {
30
45
  buffer: true,
@@ -44,10 +59,6 @@ class RocksLevel extends AbstractLevel {
44
59
  this[kColumns] = {}
45
60
  }
46
61
 
47
- get options () {
48
- return this[kOptions]
49
- }
50
-
51
62
  get sequence () {
52
63
  return Number(binding.db_get_latest_sequence(this[kContext]))
53
64
  }
@@ -72,10 +83,10 @@ class RocksLevel extends AbstractLevel {
72
83
  if (options.createIfMissing) {
73
84
  fs.mkdir(this[kLocation], { recursive: true }, (err) => {
74
85
  if (err) return callback(err)
75
- this[kOptions] = binding.db_open(this[kContext], this[kLocation], options, onOpen)
86
+ binding.db_open(this[kContext], this[kLocation], options, onOpen)
76
87
  })
77
88
  } else {
78
- this[kOptions] = binding.db_open(this[kContext], this[kLocation], options, onOpen)
89
+ binding.db_open(this[kContext], this[kLocation], options, onOpen)
79
90
  }
80
91
  }
81
92
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "7.0.31",
3
+ "version": "7.0.32",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",