@nxtedition/rocksdb 7.0.18 → 7.0.19

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
@@ -539,11 +539,8 @@ struct Iterator final : public BaseIterator {
539
539
  };
540
540
 
541
541
  struct Updates {
542
- Updates(Database* database, bool values, bool keyAsBuffer, bool valueAsBuffer, int64_t seqNumber)
542
+ Updates(Database* database, int64_t seqNumber)
543
543
  : database_(database),
544
- values_(values),
545
- keyAsBuffer_(keyAsBuffer),
546
- valueAsBuffer_(valueAsBuffer),
547
544
  seqNumber_(seqNumber) {}
548
545
 
549
546
  void Close() { iterator_.reset(); }
@@ -561,9 +558,6 @@ struct Updates {
561
558
  }
562
559
 
563
560
  Database* database_;
564
- const bool values_;
565
- const bool keyAsBuffer_;
566
- const bool valueAsBuffer_;
567
561
  int64_t seqNumber_;
568
562
  std::unique_ptr<rocksdb::TransactionLogIterator> iterator_;
569
563
 
@@ -956,7 +950,7 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
956
950
  }
957
951
 
958
952
  napi_status OnOk(napi_env env, napi_value callback) override {
959
- napi_value argv[4];
953
+ napi_value argv[3];
960
954
  NAPI_STATUS_RETURN(napi_get_null(env, &argv[0]));
961
955
 
962
956
  if (cache_.empty()) {
@@ -964,26 +958,23 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
964
958
  }
965
959
 
966
960
  NAPI_STATUS_RETURN(napi_create_array_with_length(env, cache_.size(), &argv[1]));
967
- for (size_t idx = 0; idx < cache_.size(); idx += 2) {
961
+ for (size_t idx = 0; idx < cache_.size(); idx += 3) {
962
+ napi_value op;
963
+ NAPI_STATUS_RETURN(Convert(env, cache_[idx + 0], false, op));
964
+ NAPI_STATUS_RETURN(napi_set_element(env, argv[1], static_cast<int>(idx + 0), op));
965
+
968
966
  napi_value key;
969
- NAPI_STATUS_RETURN(Convert(env, cache_[idx + 0], updates_->keyAsBuffer_, key));
970
- NAPI_STATUS_RETURN(napi_set_element(env, argv[1], static_cast<int>(idx + 0), key));
967
+ NAPI_STATUS_RETURN(Convert(env, cache_[idx + 1], false, key));
968
+ NAPI_STATUS_RETURN(napi_set_element(env, argv[1], static_cast<int>(idx + 1), key));
971
969
 
972
970
  napi_value val;
973
- NAPI_STATUS_RETURN(Convert(env, cache_[idx + 1], updates_->valueAsBuffer_, val));
974
- NAPI_STATUS_RETURN(napi_set_element(env, argv[1], static_cast<int>(idx + 1), val));
971
+ NAPI_STATUS_RETURN(Convert(env, cache_[idx + 2], false, val));
972
+ NAPI_STATUS_RETURN(napi_set_element(env, argv[1], static_cast<int>(idx + 2), val));
975
973
  }
976
974
 
977
975
  NAPI_STATUS_RETURN(napi_create_bigint_int64(env, updates_->seqNumber_, &argv[2]));
978
976
 
979
- NAPI_STATUS_RETURN(napi_create_array_with_length(env, logData_.size(), &argv[3]));
980
- for (size_t idx = 0; idx < logData_.size(); idx += 1) {
981
- napi_value logData;
982
- NAPI_STATUS_RETURN(Convert(env, logData_[idx], false, logData));
983
- NAPI_STATUS_RETURN(napi_set_element(env, argv[3], static_cast<int>(idx), logData));
984
- }
985
-
986
- return CallFunction(env, callback, 4, argv);
977
+ return CallFunction(env, callback, 3, argv);
987
978
  }
988
979
 
989
980
  void Destroy(napi_env env) override {
@@ -992,28 +983,33 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
992
983
  }
993
984
 
994
985
  void Put(const rocksdb::Slice& key, const rocksdb::Slice& value) override {
995
- cache_.emplace_back(key.ToString());
996
- if (updates_->values_) {
997
- cache_.emplace_back(value.ToString());
998
- } else {
999
- cache_.emplace_back(std::nullopt);
1000
- }
986
+ cache_.emplace_back("put");
987
+ cache_.emplace_back(key.ToStringView());
988
+ cache_.emplace_back(value.ToStringView());
1001
989
  }
1002
990
 
1003
991
  void Delete(const rocksdb::Slice& key) override {
1004
- cache_.emplace_back(key.ToString());
992
+ cache_.emplace_back("del");
993
+ cache_.emplace_back(key.ToStringView());
1005
994
  cache_.emplace_back(std::nullopt);
1006
995
  }
1007
996
 
1008
- void LogData(const rocksdb::Slice& logData) override {
1009
- logData_.emplace_back(logData.ToString());
997
+ void Merge(const rocksdb::Slice& key, const rocksdb::Slice& value) override {
998
+ cache_.emplace_back("merge");
999
+ cache_.emplace_back(key.ToStringView());
1000
+ cache_.emplace_back(value.ToStringView());
1001
+ }
1002
+
1003
+ void LogData(const rocksdb::Slice& data) override {
1004
+ cache_.emplace_back("data");
1005
+ cache_.emplace_back(std::nullopt);
1006
+ cache_.emplace_back(data.ToStringView());
1010
1007
  }
1011
1008
 
1012
1009
  bool Continue() override { return true; }
1013
1010
 
1014
1011
  private:
1015
1012
  std::vector<std::optional<std::string>> cache_;
1016
- std::vector<std::optional<std::string>> logData_;
1017
1013
  Updates* updates_;
1018
1014
  };
1019
1015
 
@@ -1023,12 +1019,9 @@ NAPI_METHOD(updates_init) {
1023
1019
  Database* database;
1024
1020
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
1025
1021
 
1026
- const auto values = BooleanProperty(env, argv[1], "values").value_or(true);
1027
- const bool keyAsBuffer = EncodingIsBuffer(env, argv[1], "keyEncoding");
1028
- const bool valueAsBuffer = EncodingIsBuffer(env, argv[1], "valueEncoding");
1029
1022
  const auto seqNumber = Int64Property(env, argv[1], "since").value_or(database->db_->GetLatestSequenceNumber());
1030
1023
 
1031
- auto updates = std::make_unique<Updates>(database, values, keyAsBuffer, valueAsBuffer, seqNumber);
1024
+ auto updates = std::make_unique<Updates>(database, seqNumber);
1032
1025
 
1033
1026
  napi_value result;
1034
1027
  NAPI_STATUS_THROWS(napi_create_external(env, updates.get(), Finalize<Updates>, updates.get(), &result));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "7.0.18",
3
+ "version": "7.0.19",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",