@nxtedition/rocksdb 7.0.17 → 7.0.18
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
|
@@ -956,7 +956,7 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
|
|
|
956
956
|
}
|
|
957
957
|
|
|
958
958
|
napi_status OnOk(napi_env env, napi_value callback) override {
|
|
959
|
-
napi_value argv[
|
|
959
|
+
napi_value argv[4];
|
|
960
960
|
NAPI_STATUS_RETURN(napi_get_null(env, &argv[0]));
|
|
961
961
|
|
|
962
962
|
if (cache_.empty()) {
|
|
@@ -964,7 +964,6 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
|
|
|
964
964
|
}
|
|
965
965
|
|
|
966
966
|
NAPI_STATUS_RETURN(napi_create_array_with_length(env, cache_.size(), &argv[1]));
|
|
967
|
-
|
|
968
967
|
for (size_t idx = 0; idx < cache_.size(); idx += 2) {
|
|
969
968
|
napi_value key;
|
|
970
969
|
NAPI_STATUS_RETURN(Convert(env, cache_[idx + 0], updates_->keyAsBuffer_, key));
|
|
@@ -977,7 +976,14 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
|
|
|
977
976
|
|
|
978
977
|
NAPI_STATUS_RETURN(napi_create_bigint_int64(env, updates_->seqNumber_, &argv[2]));
|
|
979
978
|
|
|
980
|
-
|
|
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);
|
|
981
987
|
}
|
|
982
988
|
|
|
983
989
|
void Destroy(napi_env env) override {
|
|
@@ -999,10 +1005,15 @@ struct UpdatesNextWorker final : public rocksdb::WriteBatch::Handler, public Wor
|
|
|
999
1005
|
cache_.emplace_back(std::nullopt);
|
|
1000
1006
|
}
|
|
1001
1007
|
|
|
1008
|
+
void LogData(const rocksdb::Slice& logData) override {
|
|
1009
|
+
logData_.emplace_back(logData.ToString());
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1002
1012
|
bool Continue() override { return true; }
|
|
1003
1013
|
|
|
1004
1014
|
private:
|
|
1005
1015
|
std::vector<std::optional<std::string>> cache_;
|
|
1016
|
+
std::vector<std::optional<std::string>> logData_;
|
|
1006
1017
|
Updates* updates_;
|
|
1007
1018
|
};
|
|
1008
1019
|
|
|
@@ -1720,6 +1731,23 @@ NAPI_METHOD(batch_write) {
|
|
|
1720
1731
|
return 0;
|
|
1721
1732
|
}
|
|
1722
1733
|
|
|
1734
|
+
NAPI_METHOD(batch_put_log_data) {
|
|
1735
|
+
NAPI_ARGV(4);
|
|
1736
|
+
|
|
1737
|
+
Database* database;
|
|
1738
|
+
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
|
|
1739
|
+
|
|
1740
|
+
rocksdb::WriteBatch* batch;
|
|
1741
|
+
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[1], reinterpret_cast<void**>(&batch)));
|
|
1742
|
+
|
|
1743
|
+
std::string logData;
|
|
1744
|
+
NAPI_STATUS_THROWS(ToString(env, argv[2], logData));
|
|
1745
|
+
|
|
1746
|
+
ROCKS_STATUS_THROWS(batch->PutLogData(logData));
|
|
1747
|
+
|
|
1748
|
+
return 0;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1723
1751
|
NAPI_INIT() {
|
|
1724
1752
|
NAPI_EXPORT_FUNCTION(db_init);
|
|
1725
1753
|
NAPI_EXPORT_FUNCTION(db_open);
|
|
@@ -1748,4 +1776,5 @@ NAPI_INIT() {
|
|
|
1748
1776
|
NAPI_EXPORT_FUNCTION(batch_del);
|
|
1749
1777
|
NAPI_EXPORT_FUNCTION(batch_clear);
|
|
1750
1778
|
NAPI_EXPORT_FUNCTION(batch_write);
|
|
1779
|
+
NAPI_EXPORT_FUNCTION(batch_put_log_data);
|
|
1751
1780
|
}
|
package/chained-batch.js
CHANGED
|
@@ -38,6 +38,11 @@ class ChainedBatch extends AbstractChainedBatch {
|
|
|
38
38
|
_close (callback) {
|
|
39
39
|
process.nextTick(callback)
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
putLogData (data, options) {
|
|
43
|
+
// TODO (fix): Check if open...
|
|
44
|
+
binding.batch_put_log_data(this[kDbContext], this[kBatchContext], data, options)
|
|
45
|
+
}
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
exports.ChainedBatch = ChainedBatch
|
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) => {
|
|
211
|
+
this.promise = new Promise(resolve => binding.updates_next(this.context, (err, rows, sequence, data) => {
|
|
212
212
|
this.promise = null
|
|
213
213
|
if (err) {
|
|
214
214
|
resolve(Promise.reject(err))
|
|
215
215
|
} else {
|
|
216
|
-
resolve({ rows, sequence })
|
|
216
|
+
resolve({ rows, data, sequence: Number(sequence) })
|
|
217
217
|
}
|
|
218
218
|
}))
|
|
219
219
|
|
|
@@ -251,11 +251,11 @@ class RocksLevel extends AbstractLevel {
|
|
|
251
251
|
const updates = new Updates(this, options)
|
|
252
252
|
try {
|
|
253
253
|
while (true) {
|
|
254
|
-
const
|
|
255
|
-
if (!rows) {
|
|
254
|
+
const entry = await updates.next()
|
|
255
|
+
if (!entry.rows) {
|
|
256
256
|
return
|
|
257
257
|
}
|
|
258
|
-
yield
|
|
258
|
+
yield entry
|
|
259
259
|
}
|
|
260
260
|
} finally {
|
|
261
261
|
await updates.close()
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|