@nxtedition/rocksdb 7.0.63 → 7.0.67
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 +435 -908
- package/binding.gyp +50 -79
- package/deps/rocksdb/rocksdb/db/wal_manager.cc +4 -0
- package/index.js +47 -131
- package/max_rev_operator.h +3 -0
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/util.h +339 -0
package/binding.gyp
CHANGED
|
@@ -1,83 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
"variables": {"openssl_fips": "0"},
|
|
3
|
+
"targets": [
|
|
4
|
+
{
|
|
5
|
+
"target_name": "leveldown",
|
|
6
|
+
"conditions": [
|
|
7
|
+
[
|
|
8
|
+
"OS == 'linux'",
|
|
9
|
+
{
|
|
10
|
+
"cflags": [
|
|
11
|
+
"-msse4.2",
|
|
12
|
+
"-mpclmul",
|
|
13
|
+
"-mavx",
|
|
14
|
+
"-mavx2",
|
|
15
|
+
"-mbmi",
|
|
16
|
+
"-mlzcnt"
|
|
17
|
+
],
|
|
18
|
+
"ccflags": ["-flto"],
|
|
19
|
+
"cflags!": ["-fno-exceptions"],
|
|
20
|
+
"cflags_cc!": ["-fno-exceptions"],
|
|
21
|
+
"ldflags": ["-flto", "-fuse-linker-plugin"]
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
"OS == 'mac'",
|
|
26
|
+
{
|
|
27
|
+
"xcode_settings": {
|
|
28
|
+
"WARNING_CFLAGS": [
|
|
29
|
+
"-Wno-sign-compare",
|
|
30
|
+
"-Wno-unused-variable",
|
|
31
|
+
"-Wno-unused-function",
|
|
32
|
+
"-Wno-ignored-qualifiers"
|
|
33
|
+
],
|
|
34
|
+
"OTHER_CPLUSPLUSFLAGS": [
|
|
35
|
+
"-mmacosx-version-min=12.2.1",
|
|
36
|
+
"-std=c++20",
|
|
37
|
+
"-fno-omit-frame-pointer",
|
|
38
|
+
"-momit-leaf-frame-pointer",
|
|
39
|
+
"-arch x86_64",
|
|
40
|
+
"-arch arm64"
|
|
41
|
+
],
|
|
42
|
+
"GCC_ENABLE_CPP_RTTI": "YES",
|
|
43
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
44
|
+
"MACOSX_DEPLOYMENT_TARGET": "12.2.1"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
22
47
|
]
|
|
23
|
-
},
|
|
24
|
-
"VCLinkerTool": {
|
|
25
|
-
"AdditionalDependencies": ["Shlwapi.lib", "rpcrt4.lib"]
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"cflags": ["-std=c++20"],
|
|
31
|
-
"cflags!": ["-fno-rtti"],
|
|
32
|
-
"cflags_cc!": ["-fno-rtti"],
|
|
33
|
-
"cflags_cc+": ["-frtti"]
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
[
|
|
37
|
-
"OS == 'linux'",
|
|
38
|
-
{
|
|
39
|
-
"cflags": [
|
|
40
|
-
"-msse4.2",
|
|
41
|
-
"-mpclmul",
|
|
42
|
-
"-mavx",
|
|
43
|
-
"-mavx2",
|
|
44
|
-
"-mbmi",
|
|
45
|
-
"-mlzcnt"
|
|
46
48
|
],
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
],
|
|
53
|
-
[
|
|
54
|
-
"OS == 'mac'",
|
|
55
|
-
{
|
|
56
|
-
"xcode_settings": {
|
|
57
|
-
"WARNING_CFLAGS": [
|
|
58
|
-
"-Wno-sign-compare",
|
|
59
|
-
"-Wno-unused-variable",
|
|
60
|
-
"-Wno-unused-function",
|
|
61
|
-
"-Wno-ignored-qualifiers"
|
|
62
|
-
],
|
|
63
|
-
"OTHER_CPLUSPLUSFLAGS": [
|
|
64
|
-
"-mmacosx-version-min=12.2.1",
|
|
65
|
-
"-std=c++20",
|
|
66
|
-
"-fno-omit-frame-pointer",
|
|
67
|
-
"-momit-leaf-frame-pointer",
|
|
68
|
-
"-arch x86_64",
|
|
69
|
-
"-arch arm64"
|
|
70
|
-
],
|
|
71
|
-
"GCC_ENABLE_CPP_RTTI": "YES",
|
|
72
|
-
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
73
|
-
"MACOSX_DEPLOYMENT_TARGET": "12.2.1"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
],
|
|
78
|
-
"dependencies": ["<(module_root_dir)/deps/rocksdb/rocksdb.gyp:rocksdb"],
|
|
79
|
-
"include_dirs": ["<!(node -e \"require('napi-macros')\")"],
|
|
80
|
-
"sources": ["binding.cc"]
|
|
81
|
-
}
|
|
82
|
-
]
|
|
49
|
+
"dependencies": ["<(module_root_dir)/deps/rocksdb/rocksdb.gyp:rocksdb"],
|
|
50
|
+
"include_dirs": ["<!(node -e \"require('napi-macros')\")"],
|
|
51
|
+
"sources": ["binding.cc"]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
83
54
|
}
|
|
@@ -120,6 +120,10 @@ Status WalManager::GetUpdatesSince(
|
|
|
120
120
|
return s;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
std::sort(std::begin(*wal_files), std::end(*wal_files), [](auto& lhs, auto& rhs) {
|
|
124
|
+
return lhs->StartSequence() > rhs->StartSequence();
|
|
125
|
+
});
|
|
126
|
+
|
|
123
127
|
s = RetainProbableWalFiles(*wal_files, seq);
|
|
124
128
|
if (!s.ok()) {
|
|
125
129
|
return s;
|
package/index.js
CHANGED
|
@@ -17,6 +17,10 @@ const kColumns = Symbol('columns')
|
|
|
17
17
|
const kLocation = Symbol('location')
|
|
18
18
|
const kPromise = Symbol('promise')
|
|
19
19
|
const kUpdates = Symbol('updates')
|
|
20
|
+
const kRef = Symbol('ref')
|
|
21
|
+
const kUnref = Symbol('unref')
|
|
22
|
+
const kRefs = Symbol('refs')
|
|
23
|
+
const kPendingClose = Symbol('pendingClose')
|
|
20
24
|
|
|
21
25
|
const EMPTY = {}
|
|
22
26
|
|
|
@@ -66,6 +70,9 @@ class RocksLevel extends AbstractLevel {
|
|
|
66
70
|
this[kContext] = binding.db_init()
|
|
67
71
|
this[kColumns] = {}
|
|
68
72
|
|
|
73
|
+
this[kRefs] = 0
|
|
74
|
+
this[kPendingClose] = null
|
|
75
|
+
|
|
69
76
|
// .updates(...) uses 'update' listener.
|
|
70
77
|
this.setMaxListeners(100)
|
|
71
78
|
}
|
|
@@ -101,8 +108,23 @@ class RocksLevel extends AbstractLevel {
|
|
|
101
108
|
}
|
|
102
109
|
}
|
|
103
110
|
|
|
111
|
+
[kRef] () {
|
|
112
|
+
this[kRefs]++
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
[kUnref] () {
|
|
116
|
+
this[kRefs]--
|
|
117
|
+
if (this[kRefs] === 0 && this[kPendingClose]) {
|
|
118
|
+
this[kPendingClose]()
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
104
122
|
_close (callback) {
|
|
105
|
-
|
|
123
|
+
if (this[kRefs]) {
|
|
124
|
+
this[kPendingClose] = callback
|
|
125
|
+
} else {
|
|
126
|
+
binding.db_close(this[kContext], callback)
|
|
127
|
+
}
|
|
106
128
|
}
|
|
107
129
|
|
|
108
130
|
_put (key, value, options, callback) {
|
|
@@ -137,9 +159,14 @@ class RocksLevel extends AbstractLevel {
|
|
|
137
159
|
callback = fromCallback(callback, kPromise)
|
|
138
160
|
|
|
139
161
|
try {
|
|
140
|
-
|
|
162
|
+
this[kRef]()
|
|
163
|
+
binding.db_get_many(this[kContext], keys, options ?? EMPTY, (err, val) => {
|
|
164
|
+
callback(err, val)
|
|
165
|
+
this[kUnref]()
|
|
166
|
+
})
|
|
141
167
|
} catch (err) {
|
|
142
168
|
process.nextTick(callback, err)
|
|
169
|
+
this[kUnref]()
|
|
143
170
|
}
|
|
144
171
|
|
|
145
172
|
return callback[kPromise]
|
|
@@ -222,36 +249,6 @@ class RocksLevel extends AbstractLevel {
|
|
|
222
249
|
return binding.db_get_property(this[kContext], property)
|
|
223
250
|
}
|
|
224
251
|
|
|
225
|
-
async getCurrentWALFile () {
|
|
226
|
-
if (this.status !== 'open') {
|
|
227
|
-
throw new ModuleError('Database is not open', {
|
|
228
|
-
code: 'LEVEL_DATABASE_NOT_OPEN'
|
|
229
|
-
})
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return binding.db_get_current_wal_file(this[kContext])
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
async getSortedWALFiles () {
|
|
236
|
-
if (this.status !== 'open') {
|
|
237
|
-
throw new ModuleError('Database is not open', {
|
|
238
|
-
code: 'LEVEL_DATABASE_NOT_OPEN'
|
|
239
|
-
})
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return binding.db_get_sorted_wal_files(this[kContext])
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
async flushWAL (options) {
|
|
246
|
-
if (this.status !== 'open') {
|
|
247
|
-
throw new ModuleError('Database is not open', {
|
|
248
|
-
code: 'LEVEL_DATABASE_NOT_OPEN'
|
|
249
|
-
})
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
binding.db_flush_wal(this[kContext], options)
|
|
253
|
-
}
|
|
254
|
-
|
|
255
252
|
async query (options) {
|
|
256
253
|
if (this.status !== 'open') {
|
|
257
254
|
throw new ModuleError('Database is not open', {
|
|
@@ -259,17 +256,9 @@ class RocksLevel extends AbstractLevel {
|
|
|
259
256
|
})
|
|
260
257
|
}
|
|
261
258
|
|
|
262
|
-
const context = binding.iterator_init(this[kContext], options)
|
|
263
|
-
const resource = {
|
|
264
|
-
callback: null,
|
|
265
|
-
close (callback) {
|
|
266
|
-
this.callback = callback
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
259
|
+
const context = binding.iterator_init(this[kContext], options ?? {})
|
|
270
260
|
try {
|
|
271
|
-
this
|
|
272
|
-
|
|
261
|
+
this[kRef]()
|
|
273
262
|
const limit = options.limit ?? 1000
|
|
274
263
|
return await new Promise((resolve, reject) => binding.iterator_nextv(context, limit, (err, rows, finished) => {
|
|
275
264
|
if (err) {
|
|
@@ -283,11 +272,8 @@ class RocksLevel extends AbstractLevel {
|
|
|
283
272
|
}
|
|
284
273
|
}))
|
|
285
274
|
} finally {
|
|
286
|
-
this.detachResource(resource)
|
|
287
275
|
binding.iterator_close(context)
|
|
288
|
-
|
|
289
|
-
resource.callback()
|
|
290
|
-
}
|
|
276
|
+
this[kUnref]()
|
|
291
277
|
}
|
|
292
278
|
}
|
|
293
279
|
|
|
@@ -347,29 +333,6 @@ class RocksLevel extends AbstractLevel {
|
|
|
347
333
|
|
|
348
334
|
const db = this
|
|
349
335
|
|
|
350
|
-
async function * _updates (options) {
|
|
351
|
-
let first = true
|
|
352
|
-
for await (const update of db[kUpdates]({ ...options, since: Math.max(0, options.since - 1024) })) {
|
|
353
|
-
if (first) {
|
|
354
|
-
if (update.sequence > options.since) {
|
|
355
|
-
// HACK
|
|
356
|
-
db.emit('warning', `Invalid update sequence ${update.sequence} > ${options.since}. Starting from 0.`)
|
|
357
|
-
first = null
|
|
358
|
-
break
|
|
359
|
-
} else {
|
|
360
|
-
first = false
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
yield update
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
if (first === null) {
|
|
367
|
-
for await (const update of db[kUpdates]({ ...options, since: 0 })) {
|
|
368
|
-
yield update
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
336
|
try {
|
|
374
337
|
let since = options.since
|
|
375
338
|
while (true) {
|
|
@@ -401,15 +364,12 @@ class RocksLevel extends AbstractLevel {
|
|
|
401
364
|
try {
|
|
402
365
|
if (since <= db.sequence) {
|
|
403
366
|
let first = true
|
|
404
|
-
for await (const update of
|
|
367
|
+
for await (const update of db[kUpdates]({
|
|
405
368
|
...options,
|
|
369
|
+
signal: ac.signal,
|
|
406
370
|
// HACK: https://github.com/facebook/rocksdb/issues/10476
|
|
407
|
-
since: Math.max(0, options.since
|
|
371
|
+
since: Math.max(0, options.since)
|
|
408
372
|
})) {
|
|
409
|
-
if (ac.signal.aborted) {
|
|
410
|
-
throw new AbortError()
|
|
411
|
-
}
|
|
412
|
-
|
|
413
373
|
if (first) {
|
|
414
374
|
if (update.sequence > since) {
|
|
415
375
|
db.emit('warning', `Invalid updates sequence ${update.sequence} > ${options.since}.`)
|
|
@@ -435,10 +395,6 @@ class RocksLevel extends AbstractLevel {
|
|
|
435
395
|
|
|
436
396
|
let first = true
|
|
437
397
|
for await (const update of buffer) {
|
|
438
|
-
if (ac.signal.aborted) {
|
|
439
|
-
throw new AbortError()
|
|
440
|
-
}
|
|
441
|
-
|
|
442
398
|
if (first) {
|
|
443
399
|
if (update.sequence > since) {
|
|
444
400
|
db.emit('warning', `Invalid batch sequence ${update.sequence} > ${options.since}.`)
|
|
@@ -457,72 +413,32 @@ class RocksLevel extends AbstractLevel {
|
|
|
457
413
|
}
|
|
458
414
|
}
|
|
459
415
|
|
|
460
|
-
async * [kUpdates] (options) {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
this.db.attachResource(this)
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
async next () {
|
|
471
|
-
if (this.closed) {
|
|
472
|
-
return {}
|
|
416
|
+
async * [kUpdates] ({ signal, ...options }) {
|
|
417
|
+
const context = binding.updates_init(this[kContext], options)
|
|
418
|
+
this[kRef]()
|
|
419
|
+
try {
|
|
420
|
+
while (true) {
|
|
421
|
+
if (signal?.aborted) {
|
|
422
|
+
throw new AbortError()
|
|
473
423
|
}
|
|
474
424
|
|
|
475
|
-
|
|
476
|
-
this.promise = null
|
|
425
|
+
const entry = await new Promise((resolve, reject) => binding.updates_next(context, (err, rows, sequence, count) => {
|
|
477
426
|
if (err) {
|
|
478
|
-
|
|
427
|
+
reject(err)
|
|
479
428
|
} else {
|
|
480
429
|
resolve({ rows, sequence, count })
|
|
481
430
|
}
|
|
482
431
|
}))
|
|
483
432
|
|
|
484
|
-
return this.promise
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
async close (callback) {
|
|
488
|
-
try {
|
|
489
|
-
await this.promise
|
|
490
|
-
} catch {
|
|
491
|
-
// Do nothing...
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
try {
|
|
495
|
-
if (!this.closed) {
|
|
496
|
-
this.closed = true
|
|
497
|
-
binding.updates_close(this.context)
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if (callback) {
|
|
501
|
-
process.nextTick(callback)
|
|
502
|
-
}
|
|
503
|
-
} catch (err) {
|
|
504
|
-
if (callback) {
|
|
505
|
-
process.nextTick(callback, err)
|
|
506
|
-
} else {
|
|
507
|
-
throw err
|
|
508
|
-
}
|
|
509
|
-
} finally {
|
|
510
|
-
this.db.detachResource(this)
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
const updates = new Updates(this, options)
|
|
516
|
-
try {
|
|
517
|
-
while (true) {
|
|
518
|
-
const entry = await updates.next()
|
|
519
433
|
if (!entry.rows) {
|
|
520
434
|
return
|
|
521
435
|
}
|
|
436
|
+
|
|
522
437
|
yield entry
|
|
523
438
|
}
|
|
524
439
|
} finally {
|
|
525
|
-
|
|
440
|
+
binding.updates_close(context)
|
|
441
|
+
this[kUnref]()
|
|
526
442
|
}
|
|
527
443
|
}
|
|
528
444
|
}
|
package/max_rev_operator.h
CHANGED
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|