@nxtedition/rocksdb 5.2.17 → 5.2.21

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
@@ -41,7 +41,7 @@ static void iterator_do_close (napi_env env, Iterator* iterator, napi_value cb);
41
41
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&iterator));
42
42
 
43
43
  #define NAPI_BATCH_CONTEXT() \
44
- leveldb::WriteBatch* batch = nullptr; \
44
+ rocksdb::WriteBatch* batch = nullptr; \
45
45
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&batch));
46
46
 
47
47
  static bool IsString (napi_env env, napi_value value) {
@@ -158,7 +158,7 @@ static std::string ToString (napi_env env, napi_value from, const std::string& d
158
158
  return defaultValue;
159
159
  }
160
160
 
161
- static std::string StringProperty (napi_env env, napi_value obj, const std::string& key) {
161
+ static std::string StringProperty (napi_env env, napi_value obj, const std::string& key, const std::string& defaultValue = "") {
162
162
  if (HasProperty(env, obj, key)) {
163
163
  napi_value value = GetProperty(env, obj, key);
164
164
  if (IsString(env, value)) {
@@ -166,7 +166,7 @@ static std::string StringProperty (napi_env env, napi_value obj, const std::stri
166
166
  }
167
167
  }
168
168
 
169
- return "";
169
+ return defaultValue;
170
170
  }
171
171
 
172
172
  static size_t StringOrBufferLength (napi_env env, napi_value value) {
@@ -267,7 +267,7 @@ struct BaseWorker {
267
267
  self->DoExecute();
268
268
  }
269
269
 
270
- bool SetStatus (const leveldb::Status& status) {
270
+ bool SetStatus (const rocksdb::Status& status) {
271
271
  status_ = status;
272
272
  return status.ok();
273
273
  }
@@ -340,7 +340,7 @@ struct BaseWorker {
340
340
  private:
341
341
  napi_ref callbackRef_;
342
342
  napi_async_work asyncWork_;
343
- leveldb::Status status_;
343
+ rocksdb::Status status_;
344
344
  };
345
345
 
346
346
  /**
@@ -352,17 +352,17 @@ struct Database {
352
352
  ref_(nullptr),
353
353
  priorityWork_(0) {}
354
354
 
355
- leveldb::Status Open (const leveldb::Options& options,
355
+ rocksdb::Status Open (const rocksdb::Options& options,
356
356
  const bool readOnly,
357
357
  const char* location) {
358
358
  if (readOnly) {
359
- leveldb::DB* db = nullptr;
359
+ rocksdb::DB* db = nullptr;
360
360
  const auto status = rocksdb::DB::OpenForReadOnly(options, location, &db);
361
361
  db_.reset(db);
362
362
  return status;
363
363
  } else {
364
- leveldb::DB* db = nullptr;
365
- const auto status = leveldb::DB::Open(options, location, &db);
364
+ rocksdb::DB* db = nullptr;
365
+ const auto status = rocksdb::DB::Open(options, location, &db);
366
366
  db_.reset(db);
367
367
  return status;
368
368
  }
@@ -372,36 +372,36 @@ struct Database {
372
372
  db_.reset();
373
373
  }
374
374
 
375
- leveldb::Status Put (const leveldb::WriteOptions& options,
375
+ rocksdb::Status Put (const rocksdb::WriteOptions& options,
376
376
  const std::string& key,
377
377
  const std::string& value) {
378
378
  return db_->Put(options, db_->DefaultColumnFamily(), key, value);
379
379
  }
380
380
 
381
- leveldb::Status Get (const leveldb::ReadOptions& options,
381
+ rocksdb::Status Get (const rocksdb::ReadOptions& options,
382
382
  const std::string& key,
383
383
  rocksdb::PinnableSlice& value) {
384
384
  return db_->Get(options, db_->DefaultColumnFamily(), key, &value);
385
385
  }
386
386
 
387
- leveldb::Status Del (const leveldb::WriteOptions& options,
387
+ rocksdb::Status Del (const rocksdb::WriteOptions& options,
388
388
  const std::string& key) {
389
389
  return db_->Delete(options, db_->DefaultColumnFamily(), key);
390
390
  }
391
391
 
392
- leveldb::Status WriteBatch (const leveldb::WriteOptions& options,
393
- leveldb::WriteBatch* batch) {
392
+ rocksdb::Status WriteBatch (const rocksdb::WriteOptions& options,
393
+ rocksdb::WriteBatch* batch) {
394
394
  return db_->Write(options, batch);
395
395
  }
396
396
 
397
- uint64_t ApproximateSize (const leveldb::Range* range) {
397
+ uint64_t ApproximateSize (const rocksdb::Range* range) {
398
398
  uint64_t size = 0;
399
399
  db_->GetApproximateSizes(range, 1, &size);
400
400
  return size;
401
401
  }
402
402
 
403
- void CompactRange (const leveldb::Slice* start,
404
- const leveldb::Slice* end) {
403
+ void CompactRange (const rocksdb::Slice* start,
404
+ const rocksdb::Slice* end) {
405
405
  rocksdb::CompactRangeOptions options;
406
406
  db_->CompactRange(options, start, end);
407
407
  }
@@ -410,15 +410,15 @@ struct Database {
410
410
  db_->GetProperty(property, &value);
411
411
  }
412
412
 
413
- const leveldb::Snapshot* NewSnapshot () {
413
+ const rocksdb::Snapshot* NewSnapshot () {
414
414
  return db_->GetSnapshot();
415
415
  }
416
416
 
417
- leveldb::Iterator* NewIterator (const leveldb::ReadOptions& options) {
417
+ rocksdb::Iterator* NewIterator (const rocksdb::ReadOptions& options) {
418
418
  return db_->NewIterator(options);
419
419
  }
420
420
 
421
- void ReleaseSnapshot (const leveldb::Snapshot* snapshot) {
421
+ void ReleaseSnapshot (const rocksdb::Snapshot* snapshot) {
422
422
  return db_->ReleaseSnapshot(snapshot);
423
423
  }
424
424
 
@@ -449,7 +449,7 @@ struct Database {
449
449
  return priorityWork_ > 0;
450
450
  }
451
451
 
452
- std::unique_ptr<leveldb::DB> db_;
452
+ std::unique_ptr<rocksdb::DB> db_;
453
453
  BaseWorker* pendingCloseWorker_;
454
454
  std::set<Iterator*> iterators_;
455
455
  napi_ref ref_;
@@ -487,7 +487,7 @@ struct BaseIterator {
487
487
  : database_(database),
488
488
  snapshot_(database->NewSnapshot()),
489
489
  dbIterator_(database->NewIterator([&]{
490
- leveldb::ReadOptions options;
490
+ rocksdb::ReadOptions options;
491
491
  options.fill_cache = fillCache;
492
492
  options.verify_checksums = false;
493
493
  options.snapshot = snapshot_;
@@ -617,19 +617,19 @@ struct BaseIterator {
617
617
  Next();
618
618
  }
619
619
 
620
- leveldb::Slice CurrentKey () const {
620
+ rocksdb::Slice CurrentKey () const {
621
621
  return dbIterator_->key();
622
622
  }
623
623
 
624
- leveldb::Slice CurrentValue () const {
624
+ rocksdb::Slice CurrentValue () const {
625
625
  return dbIterator_->value();
626
626
  }
627
627
 
628
- leveldb::Status Status () const {
628
+ rocksdb::Status Status () const {
629
629
  return dbIterator_->status();
630
630
  }
631
631
 
632
- bool OutOfRange (const leveldb::Slice& target) const {
632
+ bool OutOfRange (const rocksdb::Slice& target) const {
633
633
  if (lte_) {
634
634
  if (target.compare(*lte_) > 0) return true;
635
635
  } else if (lt_) {
@@ -648,8 +648,8 @@ struct BaseIterator {
648
648
  Database* database_;
649
649
 
650
650
  private:
651
- const leveldb::Snapshot* snapshot_;
652
- leveldb::Iterator* dbIterator_;
651
+ const rocksdb::Snapshot* snapshot_;
652
+ rocksdb::Iterator* dbIterator_;
653
653
  bool didSeek_;
654
654
  const bool reverse_;
655
655
  const std::string* lt_;
@@ -681,9 +681,6 @@ struct Iterator final : public BaseIterator {
681
681
  valueAsBuffer_(valueAsBuffer),
682
682
  highWaterMarkBytes_(highWaterMarkBytes),
683
683
  first_(true),
684
- nexting_(false),
685
- isClosing_(false),
686
- closeWorker_(nullptr),
687
684
  ref_(nullptr) {
688
685
  }
689
686
 
@@ -740,9 +737,6 @@ struct Iterator final : public BaseIterator {
740
737
  const bool valueAsBuffer_;
741
738
  const uint32_t highWaterMarkBytes_;
742
739
  bool first_;
743
- bool nexting_;
744
- bool isClosing_;
745
- BaseWorker* closeWorker_;
746
740
  std::vector<std::string> cache_;
747
741
 
748
742
  private:
@@ -755,7 +749,7 @@ private:
755
749
  * the guarantee that no db operations will be in-flight at this time.
756
750
  */
757
751
  static void env_cleanup_hook (void* arg) {
758
- Database* database = reinterpret_cast<Database*>(arg);
752
+ auto database = reinterpret_cast<Database*>(arg);
759
753
 
760
754
  // Do everything that db_close() does but synchronously. We're expecting that GC
761
755
  // did not (yet) collect the database because that would be a user mistake (not
@@ -776,7 +770,7 @@ static void env_cleanup_hook (void* arg) {
776
770
 
777
771
  static void FinalizeDatabase (napi_env env, void* data, void* hint) {
778
772
  if (data) {
779
- Database* database = (Database*)data;
773
+ auto database = reinterpret_cast<Database*>(data);
780
774
  napi_remove_env_cleanup_hook(env, env_cleanup_hook, database);
781
775
  if (database->ref_) napi_delete_reference(env, database->ref_);
782
776
  delete database;
@@ -784,7 +778,7 @@ static void FinalizeDatabase (napi_env env, void* data, void* hint) {
784
778
  }
785
779
 
786
780
  NAPI_METHOD(db_init) {
787
- Database* database = new Database();
781
+ auto database = new Database();
788
782
  napi_add_env_cleanup_hook(env, env_cleanup_hook, database);
789
783
 
790
784
  napi_value result;
@@ -798,11 +792,7 @@ NAPI_METHOD(db_init) {
798
792
  return result;
799
793
  }
800
794
 
801
- /**
802
- * Worker class for opening a database.
803
- * TODO: shouldn't this be a PriorityWorker?
804
- */
805
- struct OpenWorker final : public BaseWorker {
795
+ struct OpenWorker final : public PriorityWorker {
806
796
  OpenWorker (napi_env env,
807
797
  Database* database,
808
798
  napi_value callback,
@@ -818,14 +808,14 @@ struct OpenWorker final : public BaseWorker {
818
808
  const uint32_t cacheSize,
819
809
  const std::string& infoLogLevel,
820
810
  const bool readOnly)
821
- : BaseWorker(env, database, callback, "leveldown.db.open"),
811
+ : PriorityWorker(env, database, callback, "leveldown.db.open"),
822
812
  readOnly_(readOnly),
823
813
  location_(location) {
824
814
  options_.create_if_missing = createIfMissing;
825
815
  options_.error_if_exists = errorIfExists;
826
816
  options_.compression = compression
827
- ? leveldb::kSnappyCompression
828
- : leveldb::kNoCompression;
817
+ ? rocksdb::kSnappyCompression
818
+ : rocksdb::kNoCompression;
829
819
  options_.write_buffer_size = writeBufferSize;
830
820
  options_.max_open_files = maxOpenFiles;
831
821
  options_.max_log_file_size = maxFileSize;
@@ -873,7 +863,7 @@ struct OpenWorker final : public BaseWorker {
873
863
  SetStatus(database_->Open(options_, readOnly_, location_.c_str()));
874
864
  }
875
865
 
876
- leveldb::Options options_;
866
+ rocksdb::Options options_;
877
867
  const bool readOnly_;
878
868
  const std::string location_;
879
869
  };
@@ -933,13 +923,6 @@ NAPI_METHOD(db_close) {
933
923
 
934
924
  const auto callback = argv[1];
935
925
 
936
- napi_value noop;
937
- napi_create_function(env, nullptr, 0, noop_callback, nullptr, &noop);
938
-
939
- for (auto it : database->iterators_) {
940
- iterator_do_close(env, it, noop);
941
- }
942
-
943
926
  auto worker = new CloseWorker(env, database, callback);
944
927
 
945
928
  if (!database->HasPriorityWork()) {
@@ -963,7 +946,7 @@ struct PutWorker final : public PriorityWorker {
963
946
  }
964
947
 
965
948
  void DoExecute () override {
966
- leveldb::WriteOptions options;
949
+ rocksdb::WriteOptions options;
967
950
  options.sync = sync_;
968
951
  SetStatus(database_->Put(options, key_, value_));
969
952
  }
@@ -1000,7 +983,7 @@ struct GetWorker final : public PriorityWorker {
1000
983
  }
1001
984
 
1002
985
  void DoExecute () override {
1003
- leveldb::ReadOptions options;
986
+ rocksdb::ReadOptions options;
1004
987
  options.fill_cache = fillCache_;
1005
988
  SetStatus(database_->Get(options, key_, value_));
1006
989
  }
@@ -1057,7 +1040,7 @@ struct GetManyWorker final : public PriorityWorker {
1057
1040
  void DoExecute () override {
1058
1041
  cache_.reserve(keys_.size());
1059
1042
 
1060
- leveldb::ReadOptions options;
1043
+ rocksdb::ReadOptions options;
1061
1044
  options.snapshot = snapshot_;
1062
1045
  options.fill_cache = fillCache_;
1063
1046
 
@@ -1109,7 +1092,7 @@ private:
1109
1092
  const bool valueAsBuffer_;
1110
1093
  std::vector<rocksdb::PinnableSlice> cache_;
1111
1094
  const bool fillCache_;
1112
- const leveldb::Snapshot* snapshot_;
1095
+ const rocksdb::Snapshot* snapshot_;
1113
1096
  };
1114
1097
 
1115
1098
  NAPI_METHOD(db_get_many) {
@@ -1139,7 +1122,7 @@ struct DelWorker final : public PriorityWorker {
1139
1122
  }
1140
1123
 
1141
1124
  void DoExecute () override {
1142
- leveldb::WriteOptions options;
1125
+ rocksdb::WriteOptions options;
1143
1126
  options.sync = sync_;
1144
1127
  SetStatus(database_->Del(options, key_));
1145
1128
  }
@@ -1181,10 +1164,9 @@ struct ClearWorker final : public PriorityWorker {
1181
1164
 
1182
1165
  // TODO: add option
1183
1166
  const uint32_t hwm = 16 * 1024;
1184
- leveldb::WriteBatch batch;
1185
1167
 
1186
- leveldb::WriteOptions options;
1187
- options.sync = false;
1168
+ rocksdb::WriteBatch batch;
1169
+ rocksdb::WriteOptions options;
1188
1170
 
1189
1171
  while (true) {
1190
1172
  size_t bytesRead = 0;
@@ -1245,7 +1227,7 @@ struct ApproximateSizeWorker final : public PriorityWorker {
1245
1227
  start_(start), end_(end) {}
1246
1228
 
1247
1229
  void DoExecute () override {
1248
- leveldb::Range range(start_, end_);
1230
+ rocksdb::Range range(start_, end_);
1249
1231
  size_ = database_->ApproximateSize(&range);
1250
1232
  }
1251
1233
 
@@ -1285,8 +1267,8 @@ struct CompactRangeWorker final : public PriorityWorker {
1285
1267
  start_(start), end_(end) {}
1286
1268
 
1287
1269
  void DoExecute () override {
1288
- leveldb::Slice start = start_;
1289
- leveldb::Slice end = end_;
1270
+ rocksdb::Slice start = start_;
1271
+ rocksdb::Slice end = end_;
1290
1272
  database_->CompactRange(&start, &end);
1291
1273
  }
1292
1274
 
@@ -1333,8 +1315,8 @@ struct DestroyWorker final : public BaseWorker {
1333
1315
  ~DestroyWorker () {}
1334
1316
 
1335
1317
  void DoExecute () override {
1336
- leveldb::Options options;
1337
- SetStatus(leveldb::DestroyDB(location_, options));
1318
+ rocksdb::Options options;
1319
+ SetStatus(rocksdb::DestroyDB(location_, options));
1338
1320
  }
1339
1321
 
1340
1322
  const std::string location_;
@@ -1360,8 +1342,8 @@ struct RepairWorker final : public BaseWorker {
1360
1342
  location_(location) {}
1361
1343
 
1362
1344
  void DoExecute () override {
1363
- leveldb::Options options;
1364
- SetStatus(leveldb::RepairDB(location_, options));
1345
+ rocksdb::Options options;
1346
+ SetStatus(rocksdb::RepairDB(location_, options));
1365
1347
  }
1366
1348
 
1367
1349
  const std::string location_;
@@ -1424,10 +1406,6 @@ NAPI_METHOD(iterator_seek) {
1424
1406
  NAPI_ARGV(2);
1425
1407
  NAPI_ITERATOR_CONTEXT();
1426
1408
 
1427
- if (iterator->isClosing_) {
1428
- napi_throw_error(env, nullptr, "iterator has closed");
1429
- }
1430
-
1431
1409
  const auto target = ToString(env, argv[1]);
1432
1410
  iterator->first_ = true;
1433
1411
  iterator->Seek(target);
@@ -1455,28 +1433,14 @@ private:
1455
1433
  Iterator* iterator_;
1456
1434
  };
1457
1435
 
1458
- /**
1459
- * Called by NAPI_METHOD(iterator_) and also when closing
1460
- * open iterators during NAPI_METHOD(db_close).
1461
- */
1462
- static void iterator_do_close (napi_env env, Iterator* iterator, napi_value cb) {
1463
- if (!iterator->isClosing_) {
1464
- auto worker = new CloseIteratorWorker(env, iterator, cb);
1465
- iterator->isClosing_ = true;
1466
-
1467
- if (iterator->nexting_) {
1468
- iterator->closeWorker_ = worker;
1469
- } else {
1470
- worker->Queue(env);
1471
- }
1472
- }
1473
- }
1474
-
1475
1436
  NAPI_METHOD(iterator_close) {
1476
1437
  NAPI_ARGV(2);
1477
1438
  NAPI_ITERATOR_CONTEXT();
1478
1439
 
1479
- iterator_do_close(env, iterator, argv[1]);
1440
+ const auto callback = argv[1];
1441
+
1442
+ auto worker = new CloseIteratorWorker(env, iterator, callback);
1443
+ worker->Queue(env);
1480
1444
 
1481
1445
  return 0;
1482
1446
  }
@@ -1530,14 +1494,6 @@ struct NextWorker final : public BaseWorker {
1530
1494
  }
1531
1495
 
1532
1496
  void DoFinally (napi_env env) override {
1533
- // clean up & handle the next/end state
1534
- iterator_->nexting_ = false;
1535
-
1536
- if (iterator_->closeWorker_) {
1537
- iterator_->closeWorker_->Queue(env);
1538
- iterator_->closeWorker_ = nullptr;
1539
- }
1540
-
1541
1497
  BaseWorker::DoFinally(env);
1542
1498
  }
1543
1499
 
@@ -1557,48 +1513,63 @@ NAPI_METHOD(iterator_nextv) {
1557
1513
 
1558
1514
  const auto callback = argv[2];
1559
1515
 
1560
- if (iterator->isClosing_) {
1561
- napi_value argv = CreateCodeError(env, "LEVEL_ITERATOR_NOT_OPEN", "Iterator is not open");
1562
- NAPI_STATUS_THROWS(CallFunction(env, callback, 1, &argv));
1563
- return 0;
1564
- }
1565
-
1566
1516
  auto worker = new NextWorker(env, iterator, size, callback);
1567
- iterator->nexting_ = true;
1568
1517
  worker->Queue(env);
1569
1518
 
1570
1519
  return 0;
1571
1520
  }
1572
1521
 
1573
- /**
1574
- * Worker class for batch write operation.
1575
- */
1576
1522
  struct BatchWorker final : public PriorityWorker {
1577
1523
  BatchWorker (napi_env env,
1578
1524
  Database* database,
1579
1525
  napi_value callback,
1580
- leveldb::WriteBatch* batch,
1581
- const bool sync,
1582
- const bool hasData)
1583
- : PriorityWorker(env, database, callback, "rocks_level.batch.do"),
1584
- batch_(batch), hasData_(hasData) {
1585
- options_.sync = sync;
1586
- }
1526
+ napi_value array,
1527
+ const bool sync)
1528
+ : PriorityWorker(env, database, callback, "rocks_level.batch.do"), sync_(sync) {
1529
+ uint32_t length;
1530
+ NAPI_STATUS_THROWS_VOID(napi_get_array_length(env, array, &length));
1587
1531
 
1588
- ~BatchWorker () {
1589
- delete batch_;
1532
+ for (uint32_t i = 0; i < length; i++) {
1533
+ napi_value element;
1534
+ NAPI_STATUS_THROWS_VOID(napi_get_element(env, array, i, &element));
1535
+
1536
+ if (!IsObject(env, element)) continue;
1537
+
1538
+ const auto type = StringProperty(env, element, "type");
1539
+
1540
+ if (type == "del") {
1541
+ if (!HasProperty(env, element, "key")) continue;
1542
+ const auto key = ToString(env, GetProperty(env, element, "key"));
1543
+
1544
+ batch_.Delete(key);
1545
+ if (!hasData_) hasData_ = true;
1546
+ } else if (type == "put") {
1547
+ if (!HasProperty(env, element, "key")) continue;
1548
+ if (!HasProperty(env, element, "value")) continue;
1549
+
1550
+ const auto key = ToString(env, GetProperty(env, element, "key"));
1551
+ const auto value = ToString(env, GetProperty(env, element, "value"));
1552
+
1553
+ batch_.Put(key, value);
1554
+ if (!hasData_) hasData_ = true;
1555
+ }
1556
+ }
1590
1557
  }
1591
1558
 
1592
1559
  void DoExecute () override {
1593
1560
  if (hasData_) {
1594
- SetStatus(database_->WriteBatch(options_, batch_));
1561
+ rocksdb::WriteOptions options;
1562
+ options.sync = sync_;
1563
+ SetStatus(database_->WriteBatch(options, &batch_));
1564
+ } else {
1565
+ SetStatus(rocksdb::Status::OK());
1595
1566
  }
1596
1567
  }
1597
1568
 
1598
1569
  private:
1599
- leveldb::WriteOptions options_;
1600
- leveldb::WriteBatch* batch_;
1601
- const bool hasData_;
1570
+ rocksdb::WriteBatch batch_;
1571
+ const bool sync_;
1572
+ bool hasData_;
1602
1573
  };
1603
1574
 
1604
1575
  NAPI_METHOD(batch_do) {
@@ -1609,39 +1580,7 @@ NAPI_METHOD(batch_do) {
1609
1580
  const auto sync = BooleanProperty(env, argv[2], "sync", false);
1610
1581
  const auto callback = argv[3];
1611
1582
 
1612
- uint32_t length;
1613
- napi_get_array_length(env, array, &length);
1614
-
1615
- leveldb::WriteBatch* batch = new leveldb::WriteBatch();
1616
- bool hasData = false;
1617
-
1618
- for (uint32_t i = 0; i < length; i++) {
1619
- napi_value element;
1620
- napi_get_element(env, array, i, &element);
1621
-
1622
- if (!IsObject(env, element)) continue;
1623
-
1624
- std::string type = StringProperty(env, element, "type");
1625
-
1626
- if (type == "del") {
1627
- if (!HasProperty(env, element, "key")) continue;
1628
- const auto key = ToString(env, GetProperty(env, element, "key"));
1629
-
1630
- batch->Delete(key);
1631
- if (!hasData) hasData = true;
1632
- } else if (type == "put") {
1633
- if (!HasProperty(env, element, "key")) continue;
1634
- if (!HasProperty(env, element, "value")) continue;
1635
-
1636
- const auto key = ToString(env, GetProperty(env, element, "key"));
1637
- const auto value = ToString(env, GetProperty(env, element, "value"));
1638
-
1639
- batch->Put(key, value);
1640
- if (!hasData) hasData = true;
1641
- }
1642
- }
1643
-
1644
- auto worker = new BatchWorker(env, database, callback, batch, sync, hasData);
1583
+ auto worker = new BatchWorker(env, database, callback, array, sync);
1645
1584
  worker->Queue(env);
1646
1585
 
1647
1586
  return 0;
@@ -1649,7 +1588,7 @@ NAPI_METHOD(batch_do) {
1649
1588
 
1650
1589
  static void FinalizeBatch (napi_env env, void* data, void* hint) {
1651
1590
  if (data) {
1652
- delete reinterpret_cast<leveldb::WriteBatch*>(data);
1591
+ delete reinterpret_cast<rocksdb::WriteBatch*>(data);
1653
1592
  }
1654
1593
  }
1655
1594
 
@@ -1657,12 +1596,10 @@ NAPI_METHOD(batch_init) {
1657
1596
  NAPI_ARGV(1);
1658
1597
  NAPI_DB_CONTEXT();
1659
1598
 
1660
- auto batch = new leveldb::WriteBatch();
1599
+ auto batch = new rocksdb::WriteBatch();
1661
1600
 
1662
1601
  napi_value result;
1663
- NAPI_STATUS_THROWS(napi_create_external(env, batch,
1664
- FinalizeBatch,
1665
- nullptr, &result));
1602
+ NAPI_STATUS_THROWS(napi_create_external(env, batch, FinalizeBatch, nullptr, &result));
1666
1603
  return result;
1667
1604
  }
1668
1605
 
@@ -1714,7 +1651,7 @@ struct BatchWriteWorker final : public PriorityWorker {
1714
1651
  }
1715
1652
 
1716
1653
  void DoExecute () override {
1717
- leveldb::WriteOptions options;
1654
+ rocksdb::WriteOptions options;
1718
1655
  options.sync = sync_;
1719
1656
  SetStatus(database_->WriteBatch(options, batch_));
1720
1657
  }
@@ -1725,7 +1662,7 @@ struct BatchWriteWorker final : public PriorityWorker {
1725
1662
  }
1726
1663
 
1727
1664
  private:
1728
- leveldb::WriteBatch* batch_;
1665
+ rocksdb::WriteBatch* batch_;
1729
1666
  const bool sync_;
1730
1667
  napi_ref batchRef_;
1731
1668
  };
package/binding.gyp CHANGED
@@ -1,4 +1,7 @@
1
1
  {
2
+ "variables": {
3
+ "openssl_fips" : "0"
4
+ },
2
5
  "targets": [{
3
6
  "target_name": "leveldown"
4
7
  , "conditions": [
@@ -1,4 +1,7 @@
1
1
  {
2
+ "variables": {
3
+ "openssl_fips" : "0"
4
+ },
2
5
  'targets': [{
3
6
  'target_name': 'rocksdb'
4
7
  , 'type': 'static_library'
@@ -1,4 +1,7 @@
1
- {'targets': [{
1
+ {
2
+ "variables": {
3
+ "openssl_fips" : "0"
4
+ }, 'targets': [{
2
5
  'variables': {
3
6
  'conditions': [
4
7
  ['OS=="linux"', {'os_include': 'linux'}]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "5.2.17",
3
+ "version": "5.2.21",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",