@nxtedition/rocksdb 13.5.3 → 13.5.7
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
|
@@ -127,11 +127,14 @@ struct BatchIterator : public rocksdb::WriteBatch::Handler {
|
|
|
127
127
|
keyEncoding_(keyEncoding),
|
|
128
128
|
valueEncoding_(valueEncoding) {}
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
rocksdb::Status Read (const rocksdb::WriteBatch& batch) {
|
|
131
|
+
cache_.clear();
|
|
131
132
|
cache_.reserve(batch.Count());
|
|
132
133
|
|
|
133
|
-
|
|
134
|
+
ROCKS_STATUS_RETURN(batch.Iterate(this));
|
|
135
|
+
}
|
|
134
136
|
|
|
137
|
+
napi_status Write(napi_env env, napi_value* result) {
|
|
135
138
|
napi_value putStr;
|
|
136
139
|
NAPI_STATUS_RETURN(napi_create_string_utf8(env, "put", NAPI_AUTO_LENGTH, &putStr));
|
|
137
140
|
|
|
@@ -182,6 +185,11 @@ struct BatchIterator : public rocksdb::WriteBatch::Handler {
|
|
|
182
185
|
return napi_ok;
|
|
183
186
|
}
|
|
184
187
|
|
|
188
|
+
napi_status Iterate(napi_env env, const rocksdb::WriteBatch& batch, napi_value* result) {
|
|
189
|
+
ROCKS_STATUS_RETURN_NAPI(Read(batch));
|
|
190
|
+
return Write(env, result);
|
|
191
|
+
}
|
|
192
|
+
|
|
185
193
|
rocksdb::Status PutCF(uint32_t column_family_id, const rocksdb::Slice& key, const rocksdb::Slice& value) override {
|
|
186
194
|
if (column_ && column_->GetID() != column_family_id) {
|
|
187
195
|
return rocksdb::Status::OK();
|
|
@@ -474,10 +482,10 @@ class Iterator final : public BaseIterator {
|
|
|
474
482
|
rocksdb::ColumnFamilyHandle* column = database->db->DefaultColumnFamily();
|
|
475
483
|
NAPI_STATUS_THROWS(GetProperty(env, options, "column", column));
|
|
476
484
|
|
|
477
|
-
Encoding keyEncoding;
|
|
485
|
+
Encoding keyEncoding = Encoding::String;
|
|
478
486
|
NAPI_STATUS_THROWS(GetProperty(env, options, "keyEncoding", keyEncoding));
|
|
479
487
|
|
|
480
|
-
Encoding valueEncoding;
|
|
488
|
+
Encoding valueEncoding = Encoding::String;
|
|
481
489
|
NAPI_STATUS_THROWS(GetProperty(env, options, "valueEncoding", valueEncoding));
|
|
482
490
|
|
|
483
491
|
rocksdb::ReadOptions readOptions;
|
|
@@ -569,8 +577,6 @@ class Iterator final : public BaseIterator {
|
|
|
569
577
|
rocksdb::PinnableSlice v;
|
|
570
578
|
v.PinSelf(CurrentValue());
|
|
571
579
|
state.values.push_back(std::move(v));
|
|
572
|
-
} else {
|
|
573
|
-
assert(false);
|
|
574
580
|
}
|
|
575
581
|
state.count += 1;
|
|
576
582
|
|
|
@@ -609,7 +615,8 @@ class Iterator final : public BaseIterator {
|
|
|
609
615
|
NAPI_STATUS_RETURN(napi_get_undefined(env, &key));
|
|
610
616
|
NAPI_STATUS_RETURN(Convert(env, std::move(state.values[n]), valueEncoding_, val));
|
|
611
617
|
} else {
|
|
612
|
-
|
|
618
|
+
NAPI_STATUS_RETURN(napi_get_undefined(env, &key));
|
|
619
|
+
NAPI_STATUS_RETURN(napi_get_undefined(env, &val));
|
|
613
620
|
}
|
|
614
621
|
|
|
615
622
|
NAPI_STATUS_RETURN(napi_set_element(env, rows, n * 2 + 0, key));
|
|
@@ -681,7 +688,7 @@ class Iterator final : public BaseIterator {
|
|
|
681
688
|
break;
|
|
682
689
|
}
|
|
683
690
|
|
|
684
|
-
if (deadline > 0 && database_->db->GetEnv()->NowMicros() > deadline) {
|
|
691
|
+
if (n & 0xf == 0 && deadline > 0 && database_->db->GetEnv()->NowMicros() > deadline) {
|
|
685
692
|
break;
|
|
686
693
|
}
|
|
687
694
|
}
|
|
@@ -729,7 +736,7 @@ NAPI_METHOD(db_init) {
|
|
|
729
736
|
napi_valuetype type;
|
|
730
737
|
NAPI_STATUS_THROWS(napi_typeof(env, argv[0], &type));
|
|
731
738
|
|
|
732
|
-
napi_value result;
|
|
739
|
+
napi_value result = 0;
|
|
733
740
|
|
|
734
741
|
if (type == napi_string) {
|
|
735
742
|
std::string location;
|
|
@@ -1870,7 +1877,8 @@ NAPI_METHOD(batch_iterate) {
|
|
|
1870
1877
|
return result;
|
|
1871
1878
|
}
|
|
1872
1879
|
|
|
1873
|
-
|
|
1880
|
+
class Updates : public BatchIterator, public Closable {
|
|
1881
|
+
public:
|
|
1874
1882
|
Updates(Database* database,
|
|
1875
1883
|
const int64_t since,
|
|
1876
1884
|
const bool keys,
|
|
@@ -1891,6 +1899,54 @@ struct Updates : public BatchIterator, public Closable {
|
|
|
1891
1899
|
}
|
|
1892
1900
|
}
|
|
1893
1901
|
|
|
1902
|
+
napi_value nextv(napi_env env, uint32_t count, uint32_t timeout, napi_value callback) {
|
|
1903
|
+
struct State {
|
|
1904
|
+
uint64_t sequence = 0;
|
|
1905
|
+
bool finished = false;
|
|
1906
|
+
};
|
|
1907
|
+
runAsync<State>("updates.next", env, callback,
|
|
1908
|
+
[=](auto& state) {
|
|
1909
|
+
if (!iterator_) {
|
|
1910
|
+
rocksdb::TransactionLogIterator::ReadOptions options;
|
|
1911
|
+
ROCKS_STATUS_RETURN(database_->db->GetUpdatesSince(start_, &iterator_, options));
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
ROCKS_STATUS_RETURN(iterator_->status());
|
|
1915
|
+
|
|
1916
|
+
if (!iterator_->Valid()) {
|
|
1917
|
+
state.finished = true;
|
|
1918
|
+
return rocksdb::Status::OK();
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
auto batchResult = iterator_->GetBatch();
|
|
1922
|
+
Read(*batchResult.writeBatchPtr);
|
|
1923
|
+
state.sequence = batchResult.sequence;
|
|
1924
|
+
|
|
1925
|
+
iterator_->Next();
|
|
1926
|
+
|
|
1927
|
+
return rocksdb::Status::OK();
|
|
1928
|
+
},
|
|
1929
|
+
[=](auto& state, auto env, auto& argv) {
|
|
1930
|
+
argv.resize(2);
|
|
1931
|
+
|
|
1932
|
+
if (!state.finished) {
|
|
1933
|
+
napi_value rows;
|
|
1934
|
+
napi_value sequence;
|
|
1935
|
+
|
|
1936
|
+
NAPI_STATUS_RETURN(Write(env, &rows));
|
|
1937
|
+
NAPI_STATUS_RETURN(napi_create_int64(env, state.sequence, &sequence));
|
|
1938
|
+
|
|
1939
|
+
NAPI_STATUS_RETURN(napi_create_object(env, &argv[1]));
|
|
1940
|
+
NAPI_STATUS_RETURN(napi_set_named_property(env, argv[1], "rows", rows));
|
|
1941
|
+
NAPI_STATUS_RETURN(napi_set_named_property(env, argv[1], "seq", sequence));
|
|
1942
|
+
} else {
|
|
1943
|
+
NAPI_STATUS_RETURN(napi_get_null(env, &argv[1]));
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
return napi_ok;
|
|
1947
|
+
});
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1894
1950
|
rocksdb::Status Close() override {
|
|
1895
1951
|
if (iterator_) {
|
|
1896
1952
|
iterator_.reset();
|
|
@@ -1899,11 +1955,10 @@ struct Updates : public BatchIterator, public Closable {
|
|
|
1899
1955
|
return rocksdb::Status::OK();
|
|
1900
1956
|
}
|
|
1901
1957
|
|
|
1958
|
+
private:
|
|
1902
1959
|
Database* database_;
|
|
1903
1960
|
int64_t start_;
|
|
1904
1961
|
std::unique_ptr<rocksdb::TransactionLogIterator> iterator_;
|
|
1905
|
-
|
|
1906
|
-
private:
|
|
1907
1962
|
napi_ref ref_ = nullptr;
|
|
1908
1963
|
};
|
|
1909
1964
|
|
|
@@ -1958,33 +2013,7 @@ NAPI_METHOD(updates_next) {
|
|
|
1958
2013
|
Updates* updates;
|
|
1959
2014
|
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&updates)));
|
|
1960
2015
|
|
|
1961
|
-
|
|
1962
|
-
rocksdb::TransactionLogIterator::ReadOptions options;
|
|
1963
|
-
ROCKS_STATUS_THROWS_NAPI(updates->database_->db->GetUpdatesSince(updates->start_, &updates->iterator_, options));
|
|
1964
|
-
}
|
|
1965
|
-
|
|
1966
|
-
ROCKS_STATUS_THROWS_NAPI(updates->iterator_->status());
|
|
1967
|
-
|
|
1968
|
-
if (!updates->iterator_->Valid()) {
|
|
1969
|
-
return 0;
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
auto batchResult = updates->iterator_->GetBatch();
|
|
1973
|
-
|
|
1974
|
-
napi_value rows;
|
|
1975
|
-
napi_value sequence;
|
|
1976
|
-
|
|
1977
|
-
NAPI_STATUS_THROWS(updates->Iterate(env, *batchResult.writeBatchPtr, &rows));
|
|
1978
|
-
NAPI_STATUS_THROWS(napi_create_int64(env, batchResult.sequence, &sequence));
|
|
1979
|
-
|
|
1980
|
-
ROCKS_STATUS_THROWS_NAPI(updates->iterator_->status());
|
|
1981
|
-
updates->iterator_->Next();
|
|
1982
|
-
|
|
1983
|
-
napi_value ret;
|
|
1984
|
-
NAPI_STATUS_THROWS(napi_create_object(env, &ret));
|
|
1985
|
-
NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "rows", rows));
|
|
1986
|
-
NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "seq", sequence));
|
|
1987
|
-
return ret;
|
|
2016
|
+
return updates->nextv(env, -1, -1, argv[1]);
|
|
1988
2017
|
} catch (const std::exception& e) {
|
|
1989
2018
|
napi_throw_error(env, nullptr, e.what());
|
|
1990
2019
|
return nullptr;
|
package/binding.gyp
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"/usr/lib/x86_64-linux-gnu/include",
|
|
17
17
|
"/usr/lib/include",
|
|
18
18
|
],
|
|
19
|
-
"cflags": ["-march=
|
|
20
|
-
"
|
|
19
|
+
"cflags": ["-march=znver2", '-mtune=znver3'],
|
|
20
|
+
"cflags_cc": ["-flto", '-march=znver2', '-mtune=znver3'],
|
|
21
21
|
"cflags!": ["-fno-exceptions"],
|
|
22
22
|
"cflags_cc!": ["-fno-exceptions"],
|
|
23
23
|
"ldflags": ["-flto", "-fuse-linker-plugin"],
|
package/deps/rocksdb/rocksdb.gyp
CHANGED
|
@@ -67,15 +67,15 @@
|
|
|
67
67
|
"rocksdb/env/io_posix.cc"
|
|
68
68
|
],
|
|
69
69
|
"defines": ["ROCKSDB_PLATFORM_POSIX=1", "ROCKSDB_LIB_IO_POSIX=1"],
|
|
70
|
-
"
|
|
70
|
+
"cflags_cc": [
|
|
71
71
|
"-fno-omit-frame-pointer",
|
|
72
72
|
"-momit-leaf-frame-pointer",
|
|
73
73
|
"-fno-builtin-memcmp",
|
|
74
74
|
],
|
|
75
|
-
"cflags": ["-std=c++20", "-march=
|
|
75
|
+
"cflags": ["-std=c++20", "-march=znver2", "-mtune=znver3"],
|
|
76
76
|
"cflags!": ["-fno-rtti"],
|
|
77
77
|
"cflags_cc!": ["-fno-rtti"],
|
|
78
|
-
"cflags_cc+": ["-frtti", '-march=
|
|
78
|
+
"cflags_cc+": ["-frtti", '-march=znver2', "-mtune=znver3"],
|
|
79
79
|
}
|
|
80
80
|
],
|
|
81
81
|
[
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"/usr/lib/include",
|
|
117
117
|
],
|
|
118
118
|
"cflags": ["-march=znver1"],
|
|
119
|
-
"
|
|
119
|
+
"cflags_cc": ["-march=znver1", "-flto", "-fcoroutines"],
|
|
120
120
|
"cflags!": ["-fno-exceptions"],
|
|
121
121
|
"cflags_cc!": ["-fno-exceptions"],
|
|
122
122
|
"ldflags": ["-flto", "-fuse-linker-plugin"],
|
|
@@ -128,11 +128,11 @@
|
|
|
128
128
|
"defines": ["OS_MACOSX=1"],
|
|
129
129
|
"direct_dependent_settings": {
|
|
130
130
|
"libraries": [
|
|
131
|
-
"/opt/homebrew/Cellar/zstd/1.5.
|
|
131
|
+
"/opt/homebrew/Cellar/zstd/1.5.7/lib/libzstd.a"
|
|
132
132
|
],
|
|
133
133
|
},
|
|
134
134
|
"include_dirs": [
|
|
135
|
-
"/opt/homebrew/Cellar/zstd/1.5.
|
|
135
|
+
"/opt/homebrew/Cellar/zstd/1.5.7/include"
|
|
136
136
|
],
|
|
137
137
|
"xcode_settings": {
|
|
138
138
|
"OTHER_CPLUSPLUSFLAGS": [
|
package/index.js
CHANGED
|
@@ -271,10 +271,24 @@ class RocksLevel extends AbstractLevel {
|
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
async * updates (options) {
|
|
274
|
+
yield * this.updatesAsync(options)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async * updatesAsync (options) {
|
|
278
|
+
if (this.status !== 'open') {
|
|
279
|
+
throw new ModuleError('Database is not open', {
|
|
280
|
+
code: 'LEVEL_DATABASE_NOT_OPEN'
|
|
281
|
+
})
|
|
282
|
+
}
|
|
283
|
+
|
|
274
284
|
const handle = binding.updates_init(this[kContext], options)
|
|
275
285
|
try {
|
|
276
286
|
while (true) {
|
|
277
|
-
const value =
|
|
287
|
+
const value = await new Promise((resolve, reject) => {
|
|
288
|
+
binding.updates_next(
|
|
289
|
+
handle,
|
|
290
|
+
(err, val) => err ? reject(err) : resolve(val))
|
|
291
|
+
})
|
|
278
292
|
if (!value) {
|
|
279
293
|
break
|
|
280
294
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|