@nxtedition/rocksdb 7.0.20 → 7.0.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
@@ -14,7 +14,6 @@
14
14
  #include <rocksdb/slice_transform.h>
15
15
  #include <rocksdb/table.h>
16
16
  #include <rocksdb/write_batch.h>
17
- #include <rocksdb/filter_policy.h>
18
17
 
19
18
  #include <array>
20
19
  #include <memory>
@@ -539,9 +538,7 @@ struct Iterator final : public BaseIterator {
539
538
  };
540
539
 
541
540
  struct Updates {
542
- Updates(Database* database, int64_t seqNumber)
543
- : database_(database),
544
- seqNumber_(seqNumber) {}
541
+ Updates(Database* database, int64_t seqNumber) : database_(database), seqNumber_(seqNumber) {}
545
542
 
546
543
  void Close() { iterator_.reset(); }
547
544
 
@@ -944,7 +941,7 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
944
941
 
945
942
  updates_->seqNumber_ = batch.sequence;
946
943
 
947
- cache_.reserve(batch.writeBatchPtr->Count() * 2);
944
+ cache_.reserve(batch.writeBatchPtr->Count() * 4);
948
945
 
949
946
  return batch.writeBatchPtr->Iterate(this);
950
947
  }
@@ -957,19 +954,31 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
957
954
  return CallFunction(env, callback, 1, argv);
958
955
  }
959
956
 
960
- NAPI_STATUS_RETURN(napi_create_array_with_length(env, cache_.size(), &argv[1]));
961
- for (size_t idx = 0; idx < cache_.size(); idx += 3) {
957
+ NAPI_STATUS_RETURN(napi_create_array_with_length(env, cache_.size() * 4, &argv[1]));
958
+ for (size_t idx = 0; idx < cache_.size(); idx++) {
962
959
  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));
960
+ NAPI_STATUS_RETURN(Convert(env, std::get<0>(cache_[idx]), false, op));
961
+ NAPI_STATUS_RETURN(napi_set_element(env, argv[1], static_cast<int>(idx * 4 + 0), op));
965
962
 
966
963
  napi_value 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));
964
+ NAPI_STATUS_RETURN(Convert(env, std::get<1>(cache_[idx]), false, key));
965
+ NAPI_STATUS_RETURN(napi_set_element(env, argv[1], static_cast<int>(idx * 4 + 1), key));
969
966
 
970
967
  napi_value 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));
968
+ NAPI_STATUS_RETURN(Convert(env, std::get<2>(cache_[idx]), false, val));
969
+ NAPI_STATUS_RETURN(napi_set_element(env, argv[1], static_cast<int>(idx * 4 + 2), val));
970
+
971
+ auto column_family_id = std::get<3>(cache_[idx]);
972
+ auto columns = database_->columns_;
973
+ auto columnIt = std::find_if(columns.begin(), columns.end(),
974
+ [&](const auto& handle) { return handle->GetID() == column_family_id; });
975
+ napi_value column;
976
+ if (columnIt != columns.end()) {
977
+ NAPI_STATUS_RETURN(napi_create_external(env, *columnIt, nullptr, nullptr, &column));
978
+ } else {
979
+ NAPI_STATUS_RETURN(napi_get_null(env, &column));
980
+ }
981
+ NAPI_STATUS_RETURN(napi_set_element(env, argv[1], static_cast<int>(idx * 4 + 3), column));
973
982
  }
974
983
 
975
984
  NAPI_STATUS_RETURN(napi_create_bigint_int64(env, updates_->seqNumber_, &argv[2]));
@@ -982,34 +991,28 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
982
991
  Worker::Destroy(env);
983
992
  }
984
993
 
985
- void Put(const rocksdb::Slice& key, const rocksdb::Slice& value) override {
986
- cache_.emplace_back("put");
987
- cache_.emplace_back(key.ToStringView());
988
- cache_.emplace_back(value.ToStringView());
994
+ rocksdb::Status PutCF(uint32_t column_family_id, const rocksdb::Slice& key, const rocksdb::Slice& value) override {
995
+ cache_.emplace_back("put", key.ToStringView(), value.ToStringView(), column_family_id);
996
+ return rocksdb::Status::OK();
989
997
  }
990
998
 
991
- void Delete(const rocksdb::Slice& key) override {
992
- cache_.emplace_back("del");
993
- cache_.emplace_back(key.ToStringView());
994
- cache_.emplace_back(std::nullopt);
999
+ rocksdb::Status DeleteCF(uint32_t column_family_id, const rocksdb::Slice& key) override {
1000
+ cache_.emplace_back("del", key.ToStringView(), std::nullopt, column_family_id);
1001
+ return rocksdb::Status::OK();
995
1002
  }
996
1003
 
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());
1004
+ rocksdb::Status MergeCF(uint32_t column_family_id, const rocksdb::Slice& key, const rocksdb::Slice& value) override {
1005
+ cache_.emplace_back("merge", key.ToStringView(), value.ToStringView(), column_family_id);
1006
+ return rocksdb::Status::OK();
1001
1007
  }
1002
1008
 
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());
1007
- }
1009
+ void LogData(const rocksdb::Slice& data) override { cache_.emplace_back("data", std::nullopt, data.ToStringView()); }
1008
1010
 
1009
1011
  bool Continue() override { return true; }
1010
1012
 
1011
1013
  private:
1012
- std::vector<std::optional<std::string>> cache_;
1014
+ std::vector<std::tuple<std::optional<std::string>, std::optional<std::string>, std::optional<std::string>, uint32_t>>
1015
+ cache_;
1013
1016
  Updates* updates_;
1014
1017
  };
1015
1018
 
package/index.js CHANGED
@@ -208,12 +208,12 @@ class RocksLevel extends AbstractLevel {
208
208
  return {}
209
209
  }
210
210
 
211
- this.promise = new Promise(resolve => binding.updates_next(this.context, (err, rows, sequence, data) => {
211
+ this.promise = new Promise(resolve => binding.updates_next(this.context, (err, rows, sequence) => {
212
212
  this.promise = null
213
213
  if (err) {
214
214
  resolve(Promise.reject(err))
215
215
  } else {
216
- resolve({ rows, data, sequence: Number(sequence) })
216
+ resolve({ rows, sequence: Number(sequence) })
217
217
  }
218
218
  }))
219
219
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "7.0.20",
3
+ "version": "7.0.21",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
Binary file
Binary file