@nxtedition/rocksdb 7.1.28 → 7.1.30

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
@@ -608,6 +608,24 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
608
608
  }
609
609
  }
610
610
 
611
+ std::optional<std::string> compactionPriority;
612
+ NAPI_STATUS_RETURN(GetProperty(env, options, "compactionPriority", compactionPriority));
613
+ if (compactionPriority) {
614
+ if (compactionPriority == "byCompensatedSize") {
615
+ columnOptions.compaction_pri = rocksdb::kByCompensatedSize;
616
+ } else if (compactionPriority == "oldestLargestSeqFirst") {
617
+ columnOptions.compaction_pri = rocksdb::kOldestLargestSeqFirst;
618
+ } else if (compactionPriority == "smallestSeqFirst") {
619
+ columnOptions.compaction_pri = rocksdb::kOldestSmallestSeqFirst;
620
+ } else if (compactionPriority == "overlappingRatio") {
621
+ columnOptions.compaction_pri = rocksdb::kMinOverlappingRatio;
622
+ } else if (compactionPriority == "roundRobin") {
623
+ columnOptions.compaction_pri = rocksdb::kRoundRobin;
624
+ } else {
625
+ // Throw?
626
+ }
627
+ }
628
+
611
629
  uint32_t cacheSize = 8 << 20;
612
630
  NAPI_STATUS_RETURN(GetProperty(env, options, "cacheSize", cacheSize));
613
631
 
@@ -661,6 +679,21 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
661
679
  return napi_ok;
662
680
  }
663
681
 
682
+ NAPI_METHOD(db_get_identity) {
683
+ NAPI_ARGV(1);
684
+
685
+ Database* database;
686
+ NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
687
+
688
+ std::string identity;
689
+ ROCKS_STATUS_THROWS_NAPI(database->db->GetDbIdentity(identity));
690
+
691
+ napi_value result;
692
+ NAPI_STATUS_THROWS(Convert(env, &identity, Encoding::String, result));
693
+
694
+ return result;
695
+ }
696
+
664
697
  NAPI_METHOD(db_open) {
665
698
  NAPI_ARGV(4);
666
699
 
@@ -1520,6 +1553,9 @@ NAPI_METHOD(batch_write) {
1520
1553
  bool sync = false;
1521
1554
  NAPI_STATUS_THROWS(GetProperty(env, options, "sync", sync));
1522
1555
 
1556
+ bool lowPriority = false;
1557
+ NAPI_STATUS_THROWS(GetProperty(env, options, "lowPriority", lowPriority));
1558
+
1523
1559
  napi_ref batchRef;
1524
1560
  NAPI_STATUS_THROWS(napi_create_reference(env, argv[1], 1, &batchRef));
1525
1561
 
@@ -1528,6 +1564,7 @@ NAPI_METHOD(batch_write) {
1528
1564
  [=](int64_t& seq) {
1529
1565
  rocksdb::WriteOptions writeOptions;
1530
1566
  writeOptions.sync = sync;
1567
+ writeOptions.low_pri = lowPriority;
1531
1568
 
1532
1569
  // TODO (fix): Better way to get batch sequence?
1533
1570
  seq = database->db->GetLatestSequenceNumber() + 1;
@@ -1679,6 +1716,7 @@ NAPI_METHOD(db_flush_wal) {
1679
1716
  NAPI_INIT() {
1680
1717
  NAPI_EXPORT_FUNCTION(db_init);
1681
1718
  NAPI_EXPORT_FUNCTION(db_open);
1719
+ NAPI_EXPORT_FUNCTION(db_get_identity);
1682
1720
  NAPI_EXPORT_FUNCTION(db_close);
1683
1721
  NAPI_EXPORT_FUNCTION(db_get_many);
1684
1722
  NAPI_EXPORT_FUNCTION(db_clear);
package/index.js CHANGED
@@ -253,6 +253,10 @@ class RocksLevel extends AbstractLevel {
253
253
  return new Iterator(this, this[kContext], options ?? EMPTY)
254
254
  }
255
255
 
256
+ get identity () {
257
+ return binding.db_get_identity(this[kContext])
258
+ }
259
+
256
260
  getProperty (property) {
257
261
  if (typeof property !== 'string') {
258
262
  throw new TypeError("The first argument 'property' must be a string")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "7.1.28",
3
+ "version": "7.1.30",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -36,7 +36,7 @@
36
36
  "rimraf": "^3.0.0",
37
37
  "standard": "^17.0.0",
38
38
  "tape": "^5.6.1",
39
- "tempy": "^3.0.0"
39
+ "tempy": "^1.0.1"
40
40
  },
41
41
  "standard": {
42
42
  "ignore": [
Binary file