hyperbee2 2.0.3 → 2.0.4
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 +3 -1
- package/lib/cache.js +5 -4
- package/lib/compression.js +9 -2
- package/lib/write.js +1 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -182,7 +182,9 @@ class Hyperbee {
|
|
|
182
182
|
children[i] = inflateChild(context, d, ptr, block, activeRequests)
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
const value = new TreeNode(await Promise.all(keys), await Promise.all(children))
|
|
186
|
+
if (!ptr.value) ptr.value = value
|
|
187
|
+
|
|
186
188
|
this.bump(ptr)
|
|
187
189
|
|
|
188
190
|
return ptr.value
|
package/lib/cache.js
CHANGED
|
@@ -10,10 +10,11 @@ module.exports = class NodeCache {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
empty() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
while (this.size > 0) {
|
|
14
|
+
const old = this.oldest()
|
|
15
|
+
this.remove(old)
|
|
16
|
+
old.value = null
|
|
17
|
+
}
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
gc() {
|
package/lib/compression.js
CHANGED
|
@@ -94,7 +94,14 @@ class CompressedArray {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
flush(max, min) {
|
|
97
|
-
|
|
97
|
+
let overflow = false
|
|
98
|
+
for (const d of this.delta) {
|
|
99
|
+
if (d.index < 256) continue // has to be uint3, only happens in rebalances/splits
|
|
100
|
+
overflow = true
|
|
101
|
+
break
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (this.delta.length <= max && !overflow) return this.delta
|
|
98
105
|
|
|
99
106
|
const direct = []
|
|
100
107
|
while (this.delta.length && this.delta[this.delta.length - 1].type !== OP_COHORT) {
|
|
@@ -102,7 +109,7 @@ class CompressedArray {
|
|
|
102
109
|
}
|
|
103
110
|
direct.reverse()
|
|
104
111
|
|
|
105
|
-
if (direct.length > min && direct.length < this.entries.length) {
|
|
112
|
+
if (direct.length > min && direct.length < this.entries.length && !overflow) {
|
|
106
113
|
const co = new DeltaCohort(true, null, [])
|
|
107
114
|
for (const d of direct) {
|
|
108
115
|
co.deltas.push(d)
|
package/lib/write.js
CHANGED
|
@@ -8,7 +8,6 @@ const {
|
|
|
8
8
|
ValuePointer,
|
|
9
9
|
TreeNode,
|
|
10
10
|
TreeNodePointer,
|
|
11
|
-
MIN_KEYS,
|
|
12
11
|
INSERTED,
|
|
13
12
|
NEEDS_SPLIT
|
|
14
13
|
} = require('./tree.js')
|
|
@@ -272,7 +271,7 @@ module.exports = class WriteBatch {
|
|
|
272
271
|
|
|
273
272
|
const v = ptr.value ? this.snapshot.bump(ptr) : await this.snapshot.inflate(ptr)
|
|
274
273
|
|
|
275
|
-
if (v.keys.length >=
|
|
274
|
+
if (v.keys.length >= minKeys) return root
|
|
276
275
|
|
|
277
276
|
const p = parent.value ? this.snapshot.bump(parent) : await this.snapshot.inflate(parent)
|
|
278
277
|
|