rocksdb-native 2.3.1 → 2.4.0
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/index.js
CHANGED
|
@@ -76,7 +76,9 @@ const RocksDB = module.exports = class RocksDB extends ReadyResource {
|
|
|
76
76
|
|
|
77
77
|
RocksDB._instances.add(this)
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
await promise
|
|
80
|
+
|
|
81
|
+
for (const snapshot of this._snapshots) snapshot._init()
|
|
80
82
|
|
|
81
83
|
function onopen (err) {
|
|
82
84
|
if (err) req.reject(new Error(err))
|
|
@@ -98,7 +100,7 @@ const RocksDB = module.exports = class RocksDB extends ReadyResource {
|
|
|
98
100
|
|
|
99
101
|
RocksDB._instances.delete(this)
|
|
100
102
|
|
|
101
|
-
|
|
103
|
+
await promise
|
|
102
104
|
|
|
103
105
|
function onclose (err) {
|
|
104
106
|
if (err) req.reject(new Error(err))
|
|
@@ -110,12 +112,12 @@ const RocksDB = module.exports = class RocksDB extends ReadyResource {
|
|
|
110
112
|
return new Snapshot(this, opts)
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
iterator (opts) {
|
|
114
|
-
return new Iterator(this, opts)
|
|
115
|
+
iterator (range, opts) {
|
|
116
|
+
return new Iterator(this, { ...range, ...opts })
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
async peek (opts) {
|
|
118
|
-
for await (const value of this.iterator({ ...opts, limit: 1 })) { // eslint-disable-line no-unreachable-loop
|
|
119
|
+
async peek (range, opts) {
|
|
120
|
+
for await (const value of this.iterator({ ...range, ...opts, limit: 1 })) { // eslint-disable-line no-unreachable-loop
|
|
119
121
|
return value
|
|
120
122
|
}
|
|
121
123
|
|
package/lib/batch.js
CHANGED
|
@@ -117,7 +117,7 @@ exports.ReadBatch = class RocksDBReadBatch extends RocksDBBatch {
|
|
|
117
117
|
this._snapshot = snapshot
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
_init () {
|
|
121
121
|
this._handle = binding.readInit(this)
|
|
122
122
|
this._buffer = binding.readBuffer(this._handle, this._capacity)
|
|
123
123
|
}
|
|
@@ -161,7 +161,7 @@ exports.ReadBatch = class RocksDBReadBatch extends RocksDBBatch {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
|
|
164
|
-
|
|
164
|
+
_init () {
|
|
165
165
|
this._handle = binding.writeInit(this)
|
|
166
166
|
this._buffer = binding.writeBuffer(this._handle, this._capacity)
|
|
167
167
|
}
|
package/lib/snapshot.js
CHANGED
|
@@ -3,19 +3,24 @@ const binding = require('../binding')
|
|
|
3
3
|
module.exports = class RocksDBSnapshot {
|
|
4
4
|
constructor (db) {
|
|
5
5
|
this._db = db
|
|
6
|
+
this._db._snapshots.add(this)
|
|
6
7
|
|
|
7
|
-
this._handle =
|
|
8
|
+
this._handle = null
|
|
8
9
|
|
|
9
|
-
this.
|
|
10
|
+
if (db.opened === true) this._init()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
_init () {
|
|
14
|
+
this._handle = binding.snapshotCreate(this._db._handle)
|
|
10
15
|
}
|
|
11
16
|
|
|
12
17
|
destroy () {
|
|
18
|
+
this._db._snapshots.delete(this)
|
|
19
|
+
|
|
13
20
|
if (this._handle === null) return
|
|
14
21
|
|
|
15
22
|
binding.snapshotDestroy(this._handle)
|
|
16
23
|
|
|
17
24
|
this._handle = null
|
|
18
|
-
|
|
19
|
-
this._db._snapshots.delete(this)
|
|
20
25
|
}
|
|
21
26
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|