@nxtedition/rocksdb 7.0.33 → 7.0.36
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 +23 -14
- package/index.js +6 -1
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
package/binding.cc
CHANGED
|
@@ -544,7 +544,13 @@ struct Updates {
|
|
|
544
544
|
bool values,
|
|
545
545
|
bool data,
|
|
546
546
|
const rocksdb::ColumnFamilyHandle* column)
|
|
547
|
-
: database_(database),
|
|
547
|
+
: database_(database),
|
|
548
|
+
sequence_(seqNumber),
|
|
549
|
+
start_(seqNumber),
|
|
550
|
+
keys_(keys),
|
|
551
|
+
values_(values),
|
|
552
|
+
data_(data),
|
|
553
|
+
column_(column) {}
|
|
548
554
|
|
|
549
555
|
void Close() { iterator_.reset(); }
|
|
550
556
|
|
|
@@ -561,7 +567,8 @@ struct Updates {
|
|
|
561
567
|
}
|
|
562
568
|
|
|
563
569
|
Database* database_;
|
|
564
|
-
int64_t
|
|
570
|
+
int64_t sequence_;
|
|
571
|
+
int64_t start_;
|
|
565
572
|
std::unique_ptr<rocksdb::TransactionLogIterator> iterator_;
|
|
566
573
|
bool keys_;
|
|
567
574
|
bool values_;
|
|
@@ -940,24 +947,23 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
|
|
|
940
947
|
}
|
|
941
948
|
|
|
942
949
|
rocksdb::Status Execute(Database& database) override {
|
|
943
|
-
rocksdb::TransactionLogIterator::ReadOptions options;
|
|
944
|
-
|
|
945
950
|
if (!updates_->iterator_) {
|
|
946
|
-
|
|
951
|
+
rocksdb::TransactionLogIterator::ReadOptions options;
|
|
952
|
+
const auto status = database_->db_->GetUpdatesSince(updates_->sequence_, &updates_->iterator_, options);
|
|
947
953
|
if (!status.ok()) {
|
|
948
954
|
return status;
|
|
949
955
|
}
|
|
950
|
-
} else {
|
|
956
|
+
} else if (updates_->iterator_->Valid()) {
|
|
951
957
|
updates_->iterator_->Next();
|
|
952
958
|
}
|
|
953
959
|
|
|
954
|
-
if (!updates_->iterator_->Valid()) {
|
|
960
|
+
if (!updates_->iterator_->Valid() || !updates_->iterator_->status().ok()) {
|
|
955
961
|
return updates_->iterator_->status();
|
|
956
962
|
}
|
|
957
963
|
|
|
958
964
|
auto batch = updates_->iterator_->GetBatch();
|
|
959
965
|
|
|
960
|
-
updates_->
|
|
966
|
+
updates_->sequence_ = batch.sequence;
|
|
961
967
|
|
|
962
968
|
count_ = batch.writeBatchPtr->Count();
|
|
963
969
|
cache_.reserve(batch.writeBatchPtr->Count() * 4);
|
|
@@ -966,11 +972,11 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
|
|
|
966
972
|
}
|
|
967
973
|
|
|
968
974
|
napi_status OnOk(napi_env env, napi_value callback) override {
|
|
969
|
-
napi_value argv[
|
|
975
|
+
napi_value argv[5];
|
|
970
976
|
|
|
971
977
|
NAPI_STATUS_RETURN(napi_get_null(env, &argv[0]));
|
|
972
978
|
|
|
973
|
-
if (
|
|
979
|
+
if (count_ == -1) {
|
|
974
980
|
return CallFunction(env, callback, 1, argv);
|
|
975
981
|
}
|
|
976
982
|
|
|
@@ -981,11 +987,13 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
|
|
|
981
987
|
NAPI_STATUS_RETURN(napi_set_element(env, argv[1], idx, val));
|
|
982
988
|
}
|
|
983
989
|
|
|
984
|
-
NAPI_STATUS_RETURN(napi_create_int64(env, updates_->
|
|
990
|
+
NAPI_STATUS_RETURN(napi_create_int64(env, updates_->sequence_, &argv[2]));
|
|
985
991
|
|
|
986
992
|
NAPI_STATUS_RETURN(napi_create_int64(env, count_, &argv[3]));
|
|
987
993
|
|
|
988
|
-
|
|
994
|
+
NAPI_STATUS_RETURN(napi_create_int64(env, updates_->start_, &argv[4]));
|
|
995
|
+
|
|
996
|
+
return CallFunction(env, callback, 5, argv);
|
|
989
997
|
}
|
|
990
998
|
|
|
991
999
|
void Destroy(napi_env env) override {
|
|
@@ -1060,7 +1068,7 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
|
|
|
1060
1068
|
return rocksdb::Status::OK();
|
|
1061
1069
|
}
|
|
1062
1070
|
|
|
1063
|
-
cache_.emplace_back("
|
|
1071
|
+
cache_.emplace_back("merge");
|
|
1064
1072
|
|
|
1065
1073
|
if (updates_->keys_) {
|
|
1066
1074
|
cache_.emplace_back(key.ToStringView());
|
|
@@ -1095,7 +1103,7 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
|
|
|
1095
1103
|
bool Continue() override { return true; }
|
|
1096
1104
|
|
|
1097
1105
|
private:
|
|
1098
|
-
|
|
1106
|
+
int64_t count_ = -1;
|
|
1099
1107
|
std::vector<std::optional<std::string>> cache_;
|
|
1100
1108
|
Updates* updates_;
|
|
1101
1109
|
};
|
|
@@ -1126,6 +1134,7 @@ NAPI_METHOD(updates_init) {
|
|
|
1126
1134
|
NAPI_STATUS_THROWS(napi_get_named_property(env, argv[1], "data", &dataProperty));
|
|
1127
1135
|
NAPI_STATUS_THROWS(napi_get_value_bool(env, dataProperty, &data));
|
|
1128
1136
|
|
|
1137
|
+
// TODO (fix): Needs to support { column: null }
|
|
1129
1138
|
rocksdb::ColumnFamilyHandle* column;
|
|
1130
1139
|
NAPI_STATUS_THROWS(GetColumnFamily(database, env, argv[1], &column, false));
|
|
1131
1140
|
|
package/index.js
CHANGED
|
@@ -245,6 +245,11 @@ class RocksLevel extends AbstractLevel {
|
|
|
245
245
|
column: options?.column ?? null
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
// HACK: We don't properly check for nully column in binding.
|
|
249
|
+
if (!options.column) {
|
|
250
|
+
delete options.column
|
|
251
|
+
}
|
|
252
|
+
|
|
248
253
|
if (typeof options.since !== 'number') {
|
|
249
254
|
throw new TypeError("'since' must be nully or a number")
|
|
250
255
|
}
|
|
@@ -261,7 +266,7 @@ class RocksLevel extends AbstractLevel {
|
|
|
261
266
|
throw new TypeError("'data' must be nully or a boolean")
|
|
262
267
|
}
|
|
263
268
|
|
|
264
|
-
if (typeof options.column !== 'object') {
|
|
269
|
+
if (options.column !== undefined && typeof options.column !== 'object') {
|
|
265
270
|
throw new TypeError("'column' must be nully or a object")
|
|
266
271
|
}
|
|
267
272
|
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|