@nxtedition/rocksdb 7.0.64 → 7.0.65

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
@@ -519,7 +519,7 @@ template <typename T, typename U>
519
519
  napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
520
520
  rocksdb::ConfigOptions configOptions;
521
521
 
522
- size_t memtable_memory_budget = 256 * 1024 * 1024;
522
+ uint64_t memtable_memory_budget = 256 * 1024 * 1024;
523
523
  NAPI_STATUS_RETURN(GetProperty(env, options, "memtableMemoryBudget", memtable_memory_budget));
524
524
 
525
525
  std::optional<std::string> compactionOpt;
@@ -555,7 +555,7 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
555
555
 
556
556
  // only compress levels >= 2
557
557
  columnOptions.compression_per_level.resize(columnOptions.num_levels);
558
- for (int i = 0; i < columnOptions.compression_per_level.size(); ++i) {
558
+ for (int i = 0; i < columnOptions.num_levels; ++i) {
559
559
  if (i < 2) {
560
560
  columnOptions.compression_per_level[i] = rocksdb::kNoCompression;
561
561
  } else {
@@ -1107,7 +1107,7 @@ NAPI_METHOD(db_get_property) {
1107
1107
  Database* database;
1108
1108
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
1109
1109
 
1110
- rocksdb::PinnableSlice property;
1110
+ NapiSlice property;
1111
1111
  NAPI_STATUS_THROWS(GetValue(env, argv[1], property));
1112
1112
 
1113
1113
  std::string value;
@@ -1203,7 +1203,7 @@ NAPI_METHOD(iterator_seek) {
1203
1203
  Iterator* iterator;
1204
1204
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&iterator)));
1205
1205
 
1206
- rocksdb::PinnableSlice target;
1206
+ NapiSlice target;
1207
1207
  NAPI_STATUS_THROWS(GetValue(env, argv[1], target));
1208
1208
 
1209
1209
  iterator->first_ = true;
@@ -1338,14 +1338,10 @@ NAPI_METHOD(batch_do) {
1338
1338
  uint32_t length;
1339
1339
  NAPI_STATUS_THROWS(napi_get_array_length(env, elements, &length));
1340
1340
 
1341
- rocksdb::PinnableSlice type;
1342
- rocksdb::PinnableSlice key;
1343
- rocksdb::PinnableSlice value;
1344
-
1345
1341
  for (uint32_t i = 0; i < length; i++) {
1346
- type.Reset();
1347
- key.Reset();
1348
- value.Reset();
1342
+ NapiSlice type;
1343
+ NapiSlice key;
1344
+ NapiSlice value;
1349
1345
 
1350
1346
  napi_value element;
1351
1347
  NAPI_STATUS_THROWS(napi_get_element(env, elements, i, &element));
@@ -1395,10 +1391,10 @@ NAPI_METHOD(batch_put) {
1395
1391
  rocksdb::WriteBatch* batch;
1396
1392
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&batch)));
1397
1393
 
1398
- rocksdb::PinnableSlice key;
1394
+ NapiSlice key;
1399
1395
  NAPI_STATUS_THROWS(GetValue(env, argv[1], key));
1400
1396
 
1401
- rocksdb::PinnableSlice val;
1397
+ NapiSlice val;
1402
1398
  NAPI_STATUS_THROWS(GetValue(env, argv[2], val));
1403
1399
 
1404
1400
  const auto options = argv[3];
@@ -1421,7 +1417,7 @@ NAPI_METHOD(batch_del) {
1421
1417
  rocksdb::WriteBatch* batch;
1422
1418
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&batch)));
1423
1419
 
1424
- rocksdb::PinnableSlice key;
1420
+ NapiSlice key;
1425
1421
  NAPI_STATUS_THROWS(GetValue(env, argv[1], key));
1426
1422
 
1427
1423
  const auto options = argv[2];
@@ -1444,10 +1440,10 @@ NAPI_METHOD(batch_merge) {
1444
1440
  rocksdb::WriteBatch* batch;
1445
1441
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)(&batch)));
1446
1442
 
1447
- rocksdb::PinnableSlice key;
1443
+ NapiSlice key;
1448
1444
  NAPI_STATUS_THROWS(GetValue(env, argv[1], key));
1449
1445
 
1450
- rocksdb::PinnableSlice val;
1446
+ NapiSlice val;
1451
1447
  NAPI_STATUS_THROWS(GetValue(env, argv[2], val));
1452
1448
 
1453
1449
  const auto options = argv[3];
@@ -1496,7 +1492,7 @@ NAPI_METHOD(batch_put_log_data) {
1496
1492
  rocksdb::WriteBatch* batch;
1497
1493
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&batch)));
1498
1494
 
1499
- rocksdb::PinnableSlice logData;
1495
+ NapiSlice logData;
1500
1496
  NAPI_STATUS_THROWS(GetValue(env, argv[1], logData));
1501
1497
 
1502
1498
  ROCKS_STATUS_THROWS_NAPI(batch->PutLogData(logData));
package/binding.gyp CHANGED
@@ -1,83 +1,54 @@
1
1
  {
2
- "variables": { "openssl_fips": "0" },
3
- "targets": [
4
- {
5
- "target_name": "leveldown",
6
- "conditions": [
7
- [
8
- "OS == 'win'",
9
- {
10
- "defines": ["_HAS_EXCEPTIONS=1", "OS_WIN=1"],
11
- "msvs_settings": {
12
- "VCCLCompilerTool": {
13
- "RuntimeTypeInfo": "false",
14
- "EnableFunctionLevelLinking": "true",
15
- "ExceptionHandling": "2",
16
- "DisableSpecificWarnings": [
17
- "4355",
18
- "4530",
19
- "4267",
20
- "4244",
21
- "4506"
2
+ "variables": {"openssl_fips": "0"},
3
+ "targets": [
4
+ {
5
+ "target_name": "leveldown",
6
+ "conditions": [
7
+ [
8
+ "OS == 'linux'",
9
+ {
10
+ "cflags": [
11
+ "-msse4.2",
12
+ "-mpclmul",
13
+ "-mavx",
14
+ "-mavx2",
15
+ "-mbmi",
16
+ "-mlzcnt"
17
+ ],
18
+ "ccflags": ["-flto"],
19
+ "cflags!": ["-fno-exceptions"],
20
+ "cflags_cc!": ["-fno-exceptions"],
21
+ "ldflags": ["-flto", "-fuse-linker-plugin"]
22
+ }
23
+ ],
24
+ [
25
+ "OS == 'mac'",
26
+ {
27
+ "xcode_settings": {
28
+ "WARNING_CFLAGS": [
29
+ "-Wno-sign-compare",
30
+ "-Wno-unused-variable",
31
+ "-Wno-unused-function",
32
+ "-Wno-ignored-qualifiers"
33
+ ],
34
+ "OTHER_CPLUSPLUSFLAGS": [
35
+ "-mmacosx-version-min=12.2.1",
36
+ "-std=c++20",
37
+ "-fno-omit-frame-pointer",
38
+ "-momit-leaf-frame-pointer",
39
+ "-arch x86_64",
40
+ "-arch arm64"
41
+ ],
42
+ "GCC_ENABLE_CPP_RTTI": "YES",
43
+ "GCC_ENABLE_CPP_EXCEPTIONS": "YES",
44
+ "MACOSX_DEPLOYMENT_TARGET": "12.2.1"
45
+ }
46
+ }
22
47
  ]
23
- },
24
- "VCLinkerTool": {
25
- "AdditionalDependencies": ["Shlwapi.lib", "rpcrt4.lib"]
26
- }
27
- }
28
- },
29
- {
30
- "cflags": ["-std=c++20"],
31
- "cflags!": ["-fno-rtti"],
32
- "cflags_cc!": ["-fno-rtti"],
33
- "cflags_cc+": ["-frtti"]
34
- }
35
- ],
36
- [
37
- "OS == 'linux'",
38
- {
39
- "cflags": [
40
- "-msse4.2",
41
- "-mpclmul",
42
- "-mavx",
43
- "-mavx2",
44
- "-mbmi",
45
- "-mlzcnt"
46
48
  ],
47
- "ccflags": ["-flto"],
48
- "cflags!": ["-fno-exceptions"],
49
- "cflags_cc!": ["-fno-exceptions"],
50
- "ldflags": ["-flto", "-fuse-linker-plugin"]
51
- }
52
- ],
53
- [
54
- "OS == 'mac'",
55
- {
56
- "xcode_settings": {
57
- "WARNING_CFLAGS": [
58
- "-Wno-sign-compare",
59
- "-Wno-unused-variable",
60
- "-Wno-unused-function",
61
- "-Wno-ignored-qualifiers"
62
- ],
63
- "OTHER_CPLUSPLUSFLAGS": [
64
- "-mmacosx-version-min=12.2.1",
65
- "-std=c++20",
66
- "-fno-omit-frame-pointer",
67
- "-momit-leaf-frame-pointer",
68
- "-arch x86_64",
69
- "-arch arm64"
70
- ],
71
- "GCC_ENABLE_CPP_RTTI": "YES",
72
- "GCC_ENABLE_CPP_EXCEPTIONS": "YES",
73
- "MACOSX_DEPLOYMENT_TARGET": "12.2.1"
74
- }
75
- }
76
- ]
77
- ],
78
- "dependencies": ["<(module_root_dir)/deps/rocksdb/rocksdb.gyp:rocksdb"],
79
- "include_dirs": ["<!(node -e \"require('napi-macros')\")"],
80
- "sources": ["binding.cc"]
81
- }
82
- ]
49
+ "dependencies": ["<(module_root_dir)/deps/rocksdb/rocksdb.gyp:rocksdb"],
50
+ "include_dirs": ["<!(node -e \"require('napi-macros')\")"],
51
+ "sources": ["binding.cc"]
52
+ }
53
+ ]
83
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "7.0.64",
3
+ "version": "7.0.65",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
Binary file
package/util.h CHANGED
@@ -111,22 +111,31 @@ static napi_status GetString(napi_env env, napi_value from, std::string& to) {
111
111
  return napi_ok;
112
112
  }
113
113
 
114
- void DestroyReference(void* arg1, void* arg2) {
115
- auto env = reinterpret_cast<napi_env>(arg1);
116
- auto ref = reinterpret_cast<napi_ref>(arg2);
117
- napi_delete_reference(env, ref);
118
- }
114
+ class NapiSlice : public rocksdb::Slice {
115
+ public:
116
+ NapiSlice() {}
117
+
118
+ NapiSlice(NapiSlice&& other) = delete;
119
+ NapiSlice& operator=(NapiSlice&& other) = delete;
120
+
121
+ NapiSlice(NapiSlice&) = delete;
122
+ NapiSlice& operator=(NapiSlice&) = delete;
119
123
 
120
- static napi_status GetString(napi_env env, napi_value from, rocksdb::PinnableSlice& to) {
124
+ std::string self_space_;
125
+ };
126
+
127
+ static napi_status GetString(napi_env env, napi_value from, NapiSlice& to) {
121
128
  napi_valuetype type;
122
129
  NAPI_STATUS_RETURN(napi_typeof(env, from, &type));
123
130
 
124
131
  if (type == napi_string) {
125
132
  size_t length = 0;
126
133
  NAPI_STATUS_RETURN(napi_get_value_string_utf8(env, from, nullptr, 0, &length));
127
- to.GetSelf()->resize(length, '\0');
128
- NAPI_STATUS_RETURN(napi_get_value_string_utf8(env, from, &(*to.GetSelf())[0], length + 1, &length));
129
- to.PinSelf();
134
+ to.self_space_.resize(length, '\0');
135
+ NAPI_STATUS_RETURN(napi_get_value_string_utf8(env, from, &to.self_space_[0], length + 1, &length));
136
+
137
+ to.data_ = to.self_space_.data();
138
+ to.size_ = length;
130
139
  } else {
131
140
  bool isBuffer;
132
141
  NAPI_STATUS_RETURN(napi_is_buffer(env, from, &isBuffer));
@@ -136,9 +145,8 @@ static napi_status GetString(napi_env env, napi_value from, rocksdb::PinnableSli
136
145
  size_t length = 0;
137
146
  NAPI_STATUS_RETURN(napi_get_buffer_info(env, from, reinterpret_cast<void**>(&buf), &length));
138
147
 
139
- napi_ref ref;
140
- NAPI_STATUS_RETURN(napi_create_reference(env, from, 1, &ref));
141
- to.PinSlice(rocksdb::Slice(buf, length), DestroyReference, env, ref);
148
+ to.data_ = buf;
149
+ to.size_ = length;
142
150
  } else {
143
151
  return napi_invalid_arg;
144
152
  }
@@ -172,18 +180,11 @@ static napi_status GetValue(napi_env env, napi_value value, uint64_t& result) {
172
180
  return napi_ok;
173
181
  }
174
182
 
175
- static napi_status GetValue(napi_env env, napi_value value, unsigned long& result) {
176
- int64_t result2;
177
- NAPI_STATUS_RETURN(napi_get_value_int64(env, value, &result2));
178
- result = static_cast<unsigned long>(result2);
179
- return napi_ok;
180
- }
181
-
182
183
  static napi_status GetValue(napi_env env, napi_value value, std::string& result) {
183
184
  return GetString(env, value, result);
184
185
  }
185
186
 
186
- static napi_status GetValue(napi_env env, napi_value value, rocksdb::PinnableSlice& result) {
187
+ static napi_status GetValue(napi_env env, napi_value value, NapiSlice& result) {
187
188
  return GetString(env, value, result);
188
189
  }
189
190