serializable-bptree 8.3.4 → 8.3.5
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/dist/cjs/index.cjs
CHANGED
|
@@ -1608,28 +1608,28 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1608
1608
|
searchConfigs = {
|
|
1609
1609
|
gt: {
|
|
1610
1610
|
asc: {
|
|
1611
|
-
start: (tx, v) => tx.
|
|
1611
|
+
start: (tx, v) => tx.findUpperBoundLeaf(v[0]),
|
|
1612
1612
|
end: () => null,
|
|
1613
1613
|
direction: 1,
|
|
1614
1614
|
earlyTerminate: false
|
|
1615
1615
|
},
|
|
1616
1616
|
desc: {
|
|
1617
1617
|
start: (tx) => tx.rightestNode(),
|
|
1618
|
-
end: (tx, v) => tx.
|
|
1618
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1619
1619
|
direction: -1,
|
|
1620
1620
|
earlyTerminate: true
|
|
1621
1621
|
}
|
|
1622
1622
|
},
|
|
1623
1623
|
gte: {
|
|
1624
1624
|
asc: {
|
|
1625
|
-
start: (tx, v) => tx.
|
|
1625
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1626
1626
|
end: () => null,
|
|
1627
1627
|
direction: 1,
|
|
1628
1628
|
earlyTerminate: false
|
|
1629
1629
|
},
|
|
1630
1630
|
desc: {
|
|
1631
1631
|
start: (tx) => tx.rightestNode(),
|
|
1632
|
-
end: (tx, v) => tx.
|
|
1632
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1633
1633
|
direction: -1,
|
|
1634
1634
|
earlyTerminate: true
|
|
1635
1635
|
}
|
|
@@ -1637,12 +1637,12 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1637
1637
|
lt: {
|
|
1638
1638
|
asc: {
|
|
1639
1639
|
start: (tx) => tx.leftestNode(),
|
|
1640
|
-
end: (tx, v) => tx.
|
|
1640
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1641
1641
|
direction: 1,
|
|
1642
1642
|
earlyTerminate: true
|
|
1643
1643
|
},
|
|
1644
1644
|
desc: {
|
|
1645
|
-
start: (tx, v) => tx.
|
|
1645
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1646
1646
|
end: () => null,
|
|
1647
1647
|
direction: -1,
|
|
1648
1648
|
earlyTerminate: false
|
|
@@ -1651,12 +1651,12 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1651
1651
|
lte: {
|
|
1652
1652
|
asc: {
|
|
1653
1653
|
start: (tx) => tx.leftestNode(),
|
|
1654
|
-
end: (tx, v) => tx.
|
|
1654
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1655
1655
|
direction: 1,
|
|
1656
1656
|
earlyTerminate: true
|
|
1657
1657
|
},
|
|
1658
1658
|
desc: {
|
|
1659
|
-
start: (tx, v) => tx.
|
|
1659
|
+
start: (tx, v) => tx.findUpperBoundLeaf(v[0]),
|
|
1660
1660
|
end: () => null,
|
|
1661
1661
|
direction: -1,
|
|
1662
1662
|
earlyTerminate: false
|
|
@@ -1664,14 +1664,14 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1664
1664
|
},
|
|
1665
1665
|
equal: {
|
|
1666
1666
|
asc: {
|
|
1667
|
-
start: (tx, v) => tx.
|
|
1668
|
-
end: (tx, v) => tx.
|
|
1667
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1668
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1669
1669
|
direction: 1,
|
|
1670
1670
|
earlyTerminate: true
|
|
1671
1671
|
},
|
|
1672
1672
|
desc: {
|
|
1673
|
-
start: (tx, v) => tx.
|
|
1674
|
-
end: (tx, v) => tx.
|
|
1673
|
+
start: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1674
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1675
1675
|
direction: -1,
|
|
1676
1676
|
earlyTerminate: true
|
|
1677
1677
|
}
|
|
@@ -1692,42 +1692,42 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1692
1692
|
},
|
|
1693
1693
|
or: {
|
|
1694
1694
|
asc: {
|
|
1695
|
-
start: (tx, v) => tx.
|
|
1696
|
-
end: (tx, v) => tx.
|
|
1695
|
+
start: (tx, v) => tx.findLowerBoundLeaf(tx.lowestValue(v)),
|
|
1696
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(tx.highestValue(v), 1),
|
|
1697
1697
|
direction: 1,
|
|
1698
1698
|
earlyTerminate: false
|
|
1699
1699
|
},
|
|
1700
1700
|
desc: {
|
|
1701
|
-
start: (tx, v) => tx.
|
|
1702
|
-
end: (tx, v) => tx.
|
|
1701
|
+
start: (tx, v) => tx.findOuterBoundaryLeaf(tx.highestValue(v), 1),
|
|
1702
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(tx.lowestValue(v), -1),
|
|
1703
1703
|
direction: -1,
|
|
1704
1704
|
earlyTerminate: false
|
|
1705
1705
|
}
|
|
1706
1706
|
},
|
|
1707
1707
|
primaryGt: {
|
|
1708
1708
|
asc: {
|
|
1709
|
-
start: (tx, v) => tx.
|
|
1709
|
+
start: (tx, v) => tx.findUpperBoundLeaf(v[0]),
|
|
1710
1710
|
end: () => null,
|
|
1711
1711
|
direction: 1,
|
|
1712
1712
|
earlyTerminate: false
|
|
1713
1713
|
},
|
|
1714
1714
|
desc: {
|
|
1715
1715
|
start: (tx) => tx.rightestNode(),
|
|
1716
|
-
end: (tx, v) => tx.
|
|
1716
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1717
1717
|
direction: -1,
|
|
1718
1718
|
earlyTerminate: true
|
|
1719
1719
|
}
|
|
1720
1720
|
},
|
|
1721
1721
|
primaryGte: {
|
|
1722
1722
|
asc: {
|
|
1723
|
-
start: (tx, v) => tx.
|
|
1723
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1724
1724
|
end: () => null,
|
|
1725
1725
|
direction: 1,
|
|
1726
1726
|
earlyTerminate: false
|
|
1727
1727
|
},
|
|
1728
1728
|
desc: {
|
|
1729
1729
|
start: (tx) => tx.rightestNode(),
|
|
1730
|
-
end: (tx, v) => tx.
|
|
1730
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1731
1731
|
direction: -1,
|
|
1732
1732
|
earlyTerminate: true
|
|
1733
1733
|
}
|
|
@@ -1735,12 +1735,12 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1735
1735
|
primaryLt: {
|
|
1736
1736
|
asc: {
|
|
1737
1737
|
start: (tx) => tx.leftestNode(),
|
|
1738
|
-
end: (tx, v) => tx.
|
|
1738
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1739
1739
|
direction: 1,
|
|
1740
1740
|
earlyTerminate: true
|
|
1741
1741
|
},
|
|
1742
1742
|
desc: {
|
|
1743
|
-
start: (tx, v) => tx.
|
|
1743
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1744
1744
|
end: () => null,
|
|
1745
1745
|
direction: -1,
|
|
1746
1746
|
earlyTerminate: false
|
|
@@ -1749,12 +1749,12 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1749
1749
|
primaryLte: {
|
|
1750
1750
|
asc: {
|
|
1751
1751
|
start: (tx) => tx.leftestNode(),
|
|
1752
|
-
end: (tx, v) => tx.
|
|
1752
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1753
1753
|
direction: 1,
|
|
1754
1754
|
earlyTerminate: true
|
|
1755
1755
|
},
|
|
1756
1756
|
desc: {
|
|
1757
|
-
start: (tx, v) => tx.
|
|
1757
|
+
start: (tx, v) => tx.findUpperBoundLeaf(v[0]),
|
|
1758
1758
|
end: () => null,
|
|
1759
1759
|
direction: -1,
|
|
1760
1760
|
earlyTerminate: false
|
|
@@ -1762,14 +1762,14 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1762
1762
|
},
|
|
1763
1763
|
primaryEqual: {
|
|
1764
1764
|
asc: {
|
|
1765
|
-
start: (tx, v) => tx.
|
|
1766
|
-
end: (tx, v) => tx.
|
|
1765
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1766
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1767
1767
|
direction: 1,
|
|
1768
1768
|
earlyTerminate: true
|
|
1769
1769
|
},
|
|
1770
1770
|
desc: {
|
|
1771
|
-
start: (tx, v) => tx.
|
|
1772
|
-
end: (tx, v) => tx.
|
|
1771
|
+
start: (tx, v) => tx.findUpperBoundLeaf(v[0]),
|
|
1772
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1773
1773
|
direction: -1,
|
|
1774
1774
|
earlyTerminate: true
|
|
1775
1775
|
}
|
|
@@ -1790,14 +1790,14 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1790
1790
|
},
|
|
1791
1791
|
primaryOr: {
|
|
1792
1792
|
asc: {
|
|
1793
|
-
start: (tx, v) => tx.
|
|
1794
|
-
end: (tx, v) => tx.
|
|
1793
|
+
start: (tx, v) => tx.findLowerBoundLeaf(tx.lowestPrimaryValue(v)),
|
|
1794
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(tx.highestPrimaryValue(v), 1),
|
|
1795
1795
|
direction: 1,
|
|
1796
1796
|
earlyTerminate: false
|
|
1797
1797
|
},
|
|
1798
1798
|
desc: {
|
|
1799
|
-
start: (tx, v) => tx.
|
|
1800
|
-
end: (tx, v) => tx.
|
|
1799
|
+
start: (tx, v) => tx.findUpperBoundLeaf(tx.highestPrimaryValue(v)),
|
|
1800
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(tx.lowestPrimaryValue(v), -1),
|
|
1801
1801
|
direction: -1,
|
|
1802
1802
|
earlyTerminate: false
|
|
1803
1803
|
}
|
|
@@ -1969,17 +1969,19 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1969
1969
|
let endKey = null;
|
|
1970
1970
|
let startValues = [];
|
|
1971
1971
|
let endValues = [];
|
|
1972
|
-
for (
|
|
1972
|
+
for (let i = 0, len = startCandidates.length; i < len; i++) {
|
|
1973
|
+
const key = startCandidates[i];
|
|
1973
1974
|
if (key in condition) {
|
|
1974
1975
|
startKey = key;
|
|
1975
|
-
startValues = this.ensureValues(condition[key]);
|
|
1976
|
+
startValues = _BPTreeTransaction._multiValueKeys.includes(key) ? this.ensureValues(condition[key]) : [condition[key]];
|
|
1976
1977
|
break;
|
|
1977
1978
|
}
|
|
1978
1979
|
}
|
|
1979
|
-
for (
|
|
1980
|
+
for (let i = 0, len = endCandidates.length; i < len; i++) {
|
|
1981
|
+
const key = endCandidates[i];
|
|
1980
1982
|
if (key in condition) {
|
|
1981
1983
|
endKey = key;
|
|
1982
|
-
endValues = this.ensureValues(condition[key]);
|
|
1984
|
+
endValues = _BPTreeTransaction._multiValueKeys.includes(key) ? this.ensureValues(condition[key]) : [condition[key]];
|
|
1983
1985
|
break;
|
|
1984
1986
|
}
|
|
1985
1987
|
}
|
|
@@ -2009,6 +2011,11 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
2009
2011
|
"primaryOr",
|
|
2010
2012
|
"or"
|
|
2011
2013
|
];
|
|
2014
|
+
// Condition keys that accept multiple values (V[]) rather than a single value (V)
|
|
2015
|
+
static _multiValueKeys = [
|
|
2016
|
+
"or",
|
|
2017
|
+
"primaryOr"
|
|
2018
|
+
];
|
|
2012
2019
|
constructor(rootTx, mvccRoot, mvcc, strategy, comparator, option) {
|
|
2013
2020
|
this.rootTx = rootTx === null ? this : rootTx;
|
|
2014
2021
|
this.mvccRoot = mvccRoot;
|
|
@@ -2247,7 +2254,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2247
2254
|
this._insertInParent(parentNode, midValue, newSiblingNodeRecursive);
|
|
2248
2255
|
}
|
|
2249
2256
|
}
|
|
2250
|
-
|
|
2257
|
+
locateLeaf(value) {
|
|
2251
2258
|
let node = this.getNode(this.rootId);
|
|
2252
2259
|
while (!node.leaf) {
|
|
2253
2260
|
const { index } = this._binarySearchValues(node.values, value, false, true);
|
|
@@ -2255,7 +2262,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2255
2262
|
}
|
|
2256
2263
|
return node;
|
|
2257
2264
|
}
|
|
2258
|
-
|
|
2265
|
+
findLowerBoundLeaf(value) {
|
|
2259
2266
|
let node = this.getNode(this.rootId);
|
|
2260
2267
|
while (!node.leaf) {
|
|
2261
2268
|
const { index } = this._binarySearchValues(node.values, value, true, false);
|
|
@@ -2263,7 +2270,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2263
2270
|
}
|
|
2264
2271
|
return node;
|
|
2265
2272
|
}
|
|
2266
|
-
|
|
2273
|
+
findUpperBoundLeaf(value) {
|
|
2267
2274
|
let node = this.getNode(this.rootId);
|
|
2268
2275
|
while (!node.leaf) {
|
|
2269
2276
|
const { index } = this._binarySearchValues(node.values, value, true, true);
|
|
@@ -2271,15 +2278,8 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2271
2278
|
}
|
|
2272
2279
|
return node;
|
|
2273
2280
|
}
|
|
2274
|
-
|
|
2275
|
-
const
|
|
2276
|
-
if (!node.next) {
|
|
2277
|
-
return null;
|
|
2278
|
-
}
|
|
2279
|
-
return this.getNode(node.next);
|
|
2280
|
-
}
|
|
2281
|
-
insertableEndNode(value, direction) {
|
|
2282
|
-
const insertableNode = direction === -1 ? this.insertableNodeByPrimary(value) : this.insertableRightestNodeByPrimary(value);
|
|
2281
|
+
findOuterBoundaryLeaf(value, direction) {
|
|
2282
|
+
const insertableNode = direction === -1 ? this.findLowerBoundLeaf(value) : this.findUpperBoundLeaf(value);
|
|
2283
2283
|
let key;
|
|
2284
2284
|
switch (direction) {
|
|
2285
2285
|
case -1:
|
|
@@ -2391,7 +2391,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2391
2391
|
}
|
|
2392
2392
|
}
|
|
2393
2393
|
exists(key, value) {
|
|
2394
|
-
const node = this.
|
|
2394
|
+
const node = this.locateLeaf(value);
|
|
2395
2395
|
const { index, found } = this._binarySearchValues(node.values, value);
|
|
2396
2396
|
if (found) {
|
|
2397
2397
|
const keys = node.keys[index];
|
|
@@ -2488,7 +2488,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2488
2488
|
return map;
|
|
2489
2489
|
}
|
|
2490
2490
|
insert(key, value) {
|
|
2491
|
-
let before = this.
|
|
2491
|
+
let before = this.locateLeaf(value);
|
|
2492
2492
|
before = this._insertAtLeaf(before, key, value);
|
|
2493
2493
|
if (before.values.length === this.order) {
|
|
2494
2494
|
let after = this._createNode(
|
|
@@ -2516,7 +2516,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2516
2516
|
let currentLeaf = null;
|
|
2517
2517
|
let modified = false;
|
|
2518
2518
|
for (const [key, value] of sorted) {
|
|
2519
|
-
const targetLeaf = this.
|
|
2519
|
+
const targetLeaf = this.locateLeaf(value);
|
|
2520
2520
|
if (currentLeaf !== null && currentLeaf.id === targetLeaf.id) {
|
|
2521
2521
|
} else {
|
|
2522
2522
|
if (currentLeaf !== null && modified) {
|
|
@@ -2758,7 +2758,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2758
2758
|
if (value === void 0) {
|
|
2759
2759
|
return;
|
|
2760
2760
|
}
|
|
2761
|
-
let node = this.
|
|
2761
|
+
let node = this.findLowerBoundLeaf(value);
|
|
2762
2762
|
let found = false;
|
|
2763
2763
|
while (true) {
|
|
2764
2764
|
let i = node.values.length;
|
|
@@ -3348,7 +3348,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3348
3348
|
await this._insertInParent(parentNode, midValue, newSiblingNodeRecursive);
|
|
3349
3349
|
}
|
|
3350
3350
|
}
|
|
3351
|
-
async
|
|
3351
|
+
async locateLeaf(value) {
|
|
3352
3352
|
let node = await this.getNode(this.rootId);
|
|
3353
3353
|
while (!node.leaf) {
|
|
3354
3354
|
const { index } = this._binarySearchValues(node.values, value, false, true);
|
|
@@ -3356,7 +3356,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3356
3356
|
}
|
|
3357
3357
|
return node;
|
|
3358
3358
|
}
|
|
3359
|
-
async
|
|
3359
|
+
async findLowerBoundLeaf(value) {
|
|
3360
3360
|
let node = await this.getNode(this.rootId);
|
|
3361
3361
|
while (!node.leaf) {
|
|
3362
3362
|
const { index } = this._binarySearchValues(node.values, value, true, false);
|
|
@@ -3364,7 +3364,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3364
3364
|
}
|
|
3365
3365
|
return node;
|
|
3366
3366
|
}
|
|
3367
|
-
async
|
|
3367
|
+
async findUpperBoundLeaf(value) {
|
|
3368
3368
|
let node = await this.getNode(this.rootId);
|
|
3369
3369
|
while (!node.leaf) {
|
|
3370
3370
|
const { index } = this._binarySearchValues(node.values, value, true, true);
|
|
@@ -3372,15 +3372,8 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3372
3372
|
}
|
|
3373
3373
|
return node;
|
|
3374
3374
|
}
|
|
3375
|
-
async
|
|
3376
|
-
const
|
|
3377
|
-
if (!node.next) {
|
|
3378
|
-
return null;
|
|
3379
|
-
}
|
|
3380
|
-
return await this.getNode(node.next);
|
|
3381
|
-
}
|
|
3382
|
-
async insertableEndNode(value, direction) {
|
|
3383
|
-
const insertableNode = direction === -1 ? await this.insertableNodeByPrimary(value) : await this.insertableRightestNodeByPrimary(value);
|
|
3375
|
+
async findOuterBoundaryLeaf(value, direction) {
|
|
3376
|
+
const insertableNode = direction === -1 ? await this.findLowerBoundLeaf(value) : await this.findUpperBoundLeaf(value);
|
|
3384
3377
|
let key;
|
|
3385
3378
|
switch (direction) {
|
|
3386
3379
|
case -1:
|
|
@@ -3501,7 +3494,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3501
3494
|
}
|
|
3502
3495
|
}
|
|
3503
3496
|
async exists(key, value) {
|
|
3504
|
-
const node = await this.
|
|
3497
|
+
const node = await this.locateLeaf(value);
|
|
3505
3498
|
const { index, found } = this._binarySearchValues(node.values, value);
|
|
3506
3499
|
if (found) {
|
|
3507
3500
|
const keys = node.keys[index];
|
|
@@ -3599,7 +3592,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3599
3592
|
}
|
|
3600
3593
|
async insert(key, value) {
|
|
3601
3594
|
return this.writeLock(0, async () => {
|
|
3602
|
-
let before = await this.
|
|
3595
|
+
let before = await this.locateLeaf(value);
|
|
3603
3596
|
before = await this._insertAtLeaf(before, key, value);
|
|
3604
3597
|
if (before.values.length === this.order) {
|
|
3605
3598
|
let after = await this._createNode(
|
|
@@ -3629,7 +3622,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3629
3622
|
let currentLeaf = null;
|
|
3630
3623
|
let modified = false;
|
|
3631
3624
|
for (const [key, value] of sorted) {
|
|
3632
|
-
const targetLeaf = await this.
|
|
3625
|
+
const targetLeaf = await this.locateLeaf(value);
|
|
3633
3626
|
if (currentLeaf !== null && currentLeaf.id === targetLeaf.id) {
|
|
3634
3627
|
} else {
|
|
3635
3628
|
if (currentLeaf !== null && modified) {
|
|
@@ -3873,7 +3866,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3873
3866
|
if (value === void 0) {
|
|
3874
3867
|
return;
|
|
3875
3868
|
}
|
|
3876
|
-
let node = await this.
|
|
3869
|
+
let node = await this.findLowerBoundLeaf(value);
|
|
3877
3870
|
let found = false;
|
|
3878
3871
|
while (true) {
|
|
3879
3872
|
let i = node.values.length;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1572,28 +1572,28 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1572
1572
|
searchConfigs = {
|
|
1573
1573
|
gt: {
|
|
1574
1574
|
asc: {
|
|
1575
|
-
start: (tx, v) => tx.
|
|
1575
|
+
start: (tx, v) => tx.findUpperBoundLeaf(v[0]),
|
|
1576
1576
|
end: () => null,
|
|
1577
1577
|
direction: 1,
|
|
1578
1578
|
earlyTerminate: false
|
|
1579
1579
|
},
|
|
1580
1580
|
desc: {
|
|
1581
1581
|
start: (tx) => tx.rightestNode(),
|
|
1582
|
-
end: (tx, v) => tx.
|
|
1582
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1583
1583
|
direction: -1,
|
|
1584
1584
|
earlyTerminate: true
|
|
1585
1585
|
}
|
|
1586
1586
|
},
|
|
1587
1587
|
gte: {
|
|
1588
1588
|
asc: {
|
|
1589
|
-
start: (tx, v) => tx.
|
|
1589
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1590
1590
|
end: () => null,
|
|
1591
1591
|
direction: 1,
|
|
1592
1592
|
earlyTerminate: false
|
|
1593
1593
|
},
|
|
1594
1594
|
desc: {
|
|
1595
1595
|
start: (tx) => tx.rightestNode(),
|
|
1596
|
-
end: (tx, v) => tx.
|
|
1596
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1597
1597
|
direction: -1,
|
|
1598
1598
|
earlyTerminate: true
|
|
1599
1599
|
}
|
|
@@ -1601,12 +1601,12 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1601
1601
|
lt: {
|
|
1602
1602
|
asc: {
|
|
1603
1603
|
start: (tx) => tx.leftestNode(),
|
|
1604
|
-
end: (tx, v) => tx.
|
|
1604
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1605
1605
|
direction: 1,
|
|
1606
1606
|
earlyTerminate: true
|
|
1607
1607
|
},
|
|
1608
1608
|
desc: {
|
|
1609
|
-
start: (tx, v) => tx.
|
|
1609
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1610
1610
|
end: () => null,
|
|
1611
1611
|
direction: -1,
|
|
1612
1612
|
earlyTerminate: false
|
|
@@ -1615,12 +1615,12 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1615
1615
|
lte: {
|
|
1616
1616
|
asc: {
|
|
1617
1617
|
start: (tx) => tx.leftestNode(),
|
|
1618
|
-
end: (tx, v) => tx.
|
|
1618
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1619
1619
|
direction: 1,
|
|
1620
1620
|
earlyTerminate: true
|
|
1621
1621
|
},
|
|
1622
1622
|
desc: {
|
|
1623
|
-
start: (tx, v) => tx.
|
|
1623
|
+
start: (tx, v) => tx.findUpperBoundLeaf(v[0]),
|
|
1624
1624
|
end: () => null,
|
|
1625
1625
|
direction: -1,
|
|
1626
1626
|
earlyTerminate: false
|
|
@@ -1628,14 +1628,14 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1628
1628
|
},
|
|
1629
1629
|
equal: {
|
|
1630
1630
|
asc: {
|
|
1631
|
-
start: (tx, v) => tx.
|
|
1632
|
-
end: (tx, v) => tx.
|
|
1631
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1632
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1633
1633
|
direction: 1,
|
|
1634
1634
|
earlyTerminate: true
|
|
1635
1635
|
},
|
|
1636
1636
|
desc: {
|
|
1637
|
-
start: (tx, v) => tx.
|
|
1638
|
-
end: (tx, v) => tx.
|
|
1637
|
+
start: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1638
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1639
1639
|
direction: -1,
|
|
1640
1640
|
earlyTerminate: true
|
|
1641
1641
|
}
|
|
@@ -1656,42 +1656,42 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1656
1656
|
},
|
|
1657
1657
|
or: {
|
|
1658
1658
|
asc: {
|
|
1659
|
-
start: (tx, v) => tx.
|
|
1660
|
-
end: (tx, v) => tx.
|
|
1659
|
+
start: (tx, v) => tx.findLowerBoundLeaf(tx.lowestValue(v)),
|
|
1660
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(tx.highestValue(v), 1),
|
|
1661
1661
|
direction: 1,
|
|
1662
1662
|
earlyTerminate: false
|
|
1663
1663
|
},
|
|
1664
1664
|
desc: {
|
|
1665
|
-
start: (tx, v) => tx.
|
|
1666
|
-
end: (tx, v) => tx.
|
|
1665
|
+
start: (tx, v) => tx.findOuterBoundaryLeaf(tx.highestValue(v), 1),
|
|
1666
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(tx.lowestValue(v), -1),
|
|
1667
1667
|
direction: -1,
|
|
1668
1668
|
earlyTerminate: false
|
|
1669
1669
|
}
|
|
1670
1670
|
},
|
|
1671
1671
|
primaryGt: {
|
|
1672
1672
|
asc: {
|
|
1673
|
-
start: (tx, v) => tx.
|
|
1673
|
+
start: (tx, v) => tx.findUpperBoundLeaf(v[0]),
|
|
1674
1674
|
end: () => null,
|
|
1675
1675
|
direction: 1,
|
|
1676
1676
|
earlyTerminate: false
|
|
1677
1677
|
},
|
|
1678
1678
|
desc: {
|
|
1679
1679
|
start: (tx) => tx.rightestNode(),
|
|
1680
|
-
end: (tx, v) => tx.
|
|
1680
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1681
1681
|
direction: -1,
|
|
1682
1682
|
earlyTerminate: true
|
|
1683
1683
|
}
|
|
1684
1684
|
},
|
|
1685
1685
|
primaryGte: {
|
|
1686
1686
|
asc: {
|
|
1687
|
-
start: (tx, v) => tx.
|
|
1687
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1688
1688
|
end: () => null,
|
|
1689
1689
|
direction: 1,
|
|
1690
1690
|
earlyTerminate: false
|
|
1691
1691
|
},
|
|
1692
1692
|
desc: {
|
|
1693
1693
|
start: (tx) => tx.rightestNode(),
|
|
1694
|
-
end: (tx, v) => tx.
|
|
1694
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1695
1695
|
direction: -1,
|
|
1696
1696
|
earlyTerminate: true
|
|
1697
1697
|
}
|
|
@@ -1699,12 +1699,12 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1699
1699
|
primaryLt: {
|
|
1700
1700
|
asc: {
|
|
1701
1701
|
start: (tx) => tx.leftestNode(),
|
|
1702
|
-
end: (tx, v) => tx.
|
|
1702
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1703
1703
|
direction: 1,
|
|
1704
1704
|
earlyTerminate: true
|
|
1705
1705
|
},
|
|
1706
1706
|
desc: {
|
|
1707
|
-
start: (tx, v) => tx.
|
|
1707
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1708
1708
|
end: () => null,
|
|
1709
1709
|
direction: -1,
|
|
1710
1710
|
earlyTerminate: false
|
|
@@ -1713,12 +1713,12 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1713
1713
|
primaryLte: {
|
|
1714
1714
|
asc: {
|
|
1715
1715
|
start: (tx) => tx.leftestNode(),
|
|
1716
|
-
end: (tx, v) => tx.
|
|
1716
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1717
1717
|
direction: 1,
|
|
1718
1718
|
earlyTerminate: true
|
|
1719
1719
|
},
|
|
1720
1720
|
desc: {
|
|
1721
|
-
start: (tx, v) => tx.
|
|
1721
|
+
start: (tx, v) => tx.findUpperBoundLeaf(v[0]),
|
|
1722
1722
|
end: () => null,
|
|
1723
1723
|
direction: -1,
|
|
1724
1724
|
earlyTerminate: false
|
|
@@ -1726,14 +1726,14 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1726
1726
|
},
|
|
1727
1727
|
primaryEqual: {
|
|
1728
1728
|
asc: {
|
|
1729
|
-
start: (tx, v) => tx.
|
|
1730
|
-
end: (tx, v) => tx.
|
|
1729
|
+
start: (tx, v) => tx.findLowerBoundLeaf(v[0]),
|
|
1730
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], 1),
|
|
1731
1731
|
direction: 1,
|
|
1732
1732
|
earlyTerminate: true
|
|
1733
1733
|
},
|
|
1734
1734
|
desc: {
|
|
1735
|
-
start: (tx, v) => tx.
|
|
1736
|
-
end: (tx, v) => tx.
|
|
1735
|
+
start: (tx, v) => tx.findUpperBoundLeaf(v[0]),
|
|
1736
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(v[0], -1),
|
|
1737
1737
|
direction: -1,
|
|
1738
1738
|
earlyTerminate: true
|
|
1739
1739
|
}
|
|
@@ -1754,14 +1754,14 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1754
1754
|
},
|
|
1755
1755
|
primaryOr: {
|
|
1756
1756
|
asc: {
|
|
1757
|
-
start: (tx, v) => tx.
|
|
1758
|
-
end: (tx, v) => tx.
|
|
1757
|
+
start: (tx, v) => tx.findLowerBoundLeaf(tx.lowestPrimaryValue(v)),
|
|
1758
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(tx.highestPrimaryValue(v), 1),
|
|
1759
1759
|
direction: 1,
|
|
1760
1760
|
earlyTerminate: false
|
|
1761
1761
|
},
|
|
1762
1762
|
desc: {
|
|
1763
|
-
start: (tx, v) => tx.
|
|
1764
|
-
end: (tx, v) => tx.
|
|
1763
|
+
start: (tx, v) => tx.findUpperBoundLeaf(tx.highestPrimaryValue(v)),
|
|
1764
|
+
end: (tx, v) => tx.findOuterBoundaryLeaf(tx.lowestPrimaryValue(v), -1),
|
|
1765
1765
|
direction: -1,
|
|
1766
1766
|
earlyTerminate: false
|
|
1767
1767
|
}
|
|
@@ -1933,17 +1933,19 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1933
1933
|
let endKey = null;
|
|
1934
1934
|
let startValues = [];
|
|
1935
1935
|
let endValues = [];
|
|
1936
|
-
for (
|
|
1936
|
+
for (let i = 0, len = startCandidates.length; i < len; i++) {
|
|
1937
|
+
const key = startCandidates[i];
|
|
1937
1938
|
if (key in condition) {
|
|
1938
1939
|
startKey = key;
|
|
1939
|
-
startValues = this.ensureValues(condition[key]);
|
|
1940
|
+
startValues = _BPTreeTransaction._multiValueKeys.includes(key) ? this.ensureValues(condition[key]) : [condition[key]];
|
|
1940
1941
|
break;
|
|
1941
1942
|
}
|
|
1942
1943
|
}
|
|
1943
|
-
for (
|
|
1944
|
+
for (let i = 0, len = endCandidates.length; i < len; i++) {
|
|
1945
|
+
const key = endCandidates[i];
|
|
1944
1946
|
if (key in condition) {
|
|
1945
1947
|
endKey = key;
|
|
1946
|
-
endValues = this.ensureValues(condition[key]);
|
|
1948
|
+
endValues = _BPTreeTransaction._multiValueKeys.includes(key) ? this.ensureValues(condition[key]) : [condition[key]];
|
|
1947
1949
|
break;
|
|
1948
1950
|
}
|
|
1949
1951
|
}
|
|
@@ -1973,6 +1975,11 @@ var BPTreeTransaction = class _BPTreeTransaction {
|
|
|
1973
1975
|
"primaryOr",
|
|
1974
1976
|
"or"
|
|
1975
1977
|
];
|
|
1978
|
+
// Condition keys that accept multiple values (V[]) rather than a single value (V)
|
|
1979
|
+
static _multiValueKeys = [
|
|
1980
|
+
"or",
|
|
1981
|
+
"primaryOr"
|
|
1982
|
+
];
|
|
1976
1983
|
constructor(rootTx, mvccRoot, mvcc, strategy, comparator, option) {
|
|
1977
1984
|
this.rootTx = rootTx === null ? this : rootTx;
|
|
1978
1985
|
this.mvccRoot = mvccRoot;
|
|
@@ -2211,7 +2218,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2211
2218
|
this._insertInParent(parentNode, midValue, newSiblingNodeRecursive);
|
|
2212
2219
|
}
|
|
2213
2220
|
}
|
|
2214
|
-
|
|
2221
|
+
locateLeaf(value) {
|
|
2215
2222
|
let node = this.getNode(this.rootId);
|
|
2216
2223
|
while (!node.leaf) {
|
|
2217
2224
|
const { index } = this._binarySearchValues(node.values, value, false, true);
|
|
@@ -2219,7 +2226,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2219
2226
|
}
|
|
2220
2227
|
return node;
|
|
2221
2228
|
}
|
|
2222
|
-
|
|
2229
|
+
findLowerBoundLeaf(value) {
|
|
2223
2230
|
let node = this.getNode(this.rootId);
|
|
2224
2231
|
while (!node.leaf) {
|
|
2225
2232
|
const { index } = this._binarySearchValues(node.values, value, true, false);
|
|
@@ -2227,7 +2234,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2227
2234
|
}
|
|
2228
2235
|
return node;
|
|
2229
2236
|
}
|
|
2230
|
-
|
|
2237
|
+
findUpperBoundLeaf(value) {
|
|
2231
2238
|
let node = this.getNode(this.rootId);
|
|
2232
2239
|
while (!node.leaf) {
|
|
2233
2240
|
const { index } = this._binarySearchValues(node.values, value, true, true);
|
|
@@ -2235,15 +2242,8 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2235
2242
|
}
|
|
2236
2243
|
return node;
|
|
2237
2244
|
}
|
|
2238
|
-
|
|
2239
|
-
const
|
|
2240
|
-
if (!node.next) {
|
|
2241
|
-
return null;
|
|
2242
|
-
}
|
|
2243
|
-
return this.getNode(node.next);
|
|
2244
|
-
}
|
|
2245
|
-
insertableEndNode(value, direction) {
|
|
2246
|
-
const insertableNode = direction === -1 ? this.insertableNodeByPrimary(value) : this.insertableRightestNodeByPrimary(value);
|
|
2245
|
+
findOuterBoundaryLeaf(value, direction) {
|
|
2246
|
+
const insertableNode = direction === -1 ? this.findLowerBoundLeaf(value) : this.findUpperBoundLeaf(value);
|
|
2247
2247
|
let key;
|
|
2248
2248
|
switch (direction) {
|
|
2249
2249
|
case -1:
|
|
@@ -2355,7 +2355,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2355
2355
|
}
|
|
2356
2356
|
}
|
|
2357
2357
|
exists(key, value) {
|
|
2358
|
-
const node = this.
|
|
2358
|
+
const node = this.locateLeaf(value);
|
|
2359
2359
|
const { index, found } = this._binarySearchValues(node.values, value);
|
|
2360
2360
|
if (found) {
|
|
2361
2361
|
const keys = node.keys[index];
|
|
@@ -2452,7 +2452,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2452
2452
|
return map;
|
|
2453
2453
|
}
|
|
2454
2454
|
insert(key, value) {
|
|
2455
|
-
let before = this.
|
|
2455
|
+
let before = this.locateLeaf(value);
|
|
2456
2456
|
before = this._insertAtLeaf(before, key, value);
|
|
2457
2457
|
if (before.values.length === this.order) {
|
|
2458
2458
|
let after = this._createNode(
|
|
@@ -2480,7 +2480,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2480
2480
|
let currentLeaf = null;
|
|
2481
2481
|
let modified = false;
|
|
2482
2482
|
for (const [key, value] of sorted) {
|
|
2483
|
-
const targetLeaf = this.
|
|
2483
|
+
const targetLeaf = this.locateLeaf(value);
|
|
2484
2484
|
if (currentLeaf !== null && currentLeaf.id === targetLeaf.id) {
|
|
2485
2485
|
} else {
|
|
2486
2486
|
if (currentLeaf !== null && modified) {
|
|
@@ -2722,7 +2722,7 @@ var BPTreeSyncTransaction = class extends BPTreeTransaction {
|
|
|
2722
2722
|
if (value === void 0) {
|
|
2723
2723
|
return;
|
|
2724
2724
|
}
|
|
2725
|
-
let node = this.
|
|
2725
|
+
let node = this.findLowerBoundLeaf(value);
|
|
2726
2726
|
let found = false;
|
|
2727
2727
|
while (true) {
|
|
2728
2728
|
let i = node.values.length;
|
|
@@ -3312,7 +3312,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3312
3312
|
await this._insertInParent(parentNode, midValue, newSiblingNodeRecursive);
|
|
3313
3313
|
}
|
|
3314
3314
|
}
|
|
3315
|
-
async
|
|
3315
|
+
async locateLeaf(value) {
|
|
3316
3316
|
let node = await this.getNode(this.rootId);
|
|
3317
3317
|
while (!node.leaf) {
|
|
3318
3318
|
const { index } = this._binarySearchValues(node.values, value, false, true);
|
|
@@ -3320,7 +3320,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3320
3320
|
}
|
|
3321
3321
|
return node;
|
|
3322
3322
|
}
|
|
3323
|
-
async
|
|
3323
|
+
async findLowerBoundLeaf(value) {
|
|
3324
3324
|
let node = await this.getNode(this.rootId);
|
|
3325
3325
|
while (!node.leaf) {
|
|
3326
3326
|
const { index } = this._binarySearchValues(node.values, value, true, false);
|
|
@@ -3328,7 +3328,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3328
3328
|
}
|
|
3329
3329
|
return node;
|
|
3330
3330
|
}
|
|
3331
|
-
async
|
|
3331
|
+
async findUpperBoundLeaf(value) {
|
|
3332
3332
|
let node = await this.getNode(this.rootId);
|
|
3333
3333
|
while (!node.leaf) {
|
|
3334
3334
|
const { index } = this._binarySearchValues(node.values, value, true, true);
|
|
@@ -3336,15 +3336,8 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3336
3336
|
}
|
|
3337
3337
|
return node;
|
|
3338
3338
|
}
|
|
3339
|
-
async
|
|
3340
|
-
const
|
|
3341
|
-
if (!node.next) {
|
|
3342
|
-
return null;
|
|
3343
|
-
}
|
|
3344
|
-
return await this.getNode(node.next);
|
|
3345
|
-
}
|
|
3346
|
-
async insertableEndNode(value, direction) {
|
|
3347
|
-
const insertableNode = direction === -1 ? await this.insertableNodeByPrimary(value) : await this.insertableRightestNodeByPrimary(value);
|
|
3339
|
+
async findOuterBoundaryLeaf(value, direction) {
|
|
3340
|
+
const insertableNode = direction === -1 ? await this.findLowerBoundLeaf(value) : await this.findUpperBoundLeaf(value);
|
|
3348
3341
|
let key;
|
|
3349
3342
|
switch (direction) {
|
|
3350
3343
|
case -1:
|
|
@@ -3465,7 +3458,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3465
3458
|
}
|
|
3466
3459
|
}
|
|
3467
3460
|
async exists(key, value) {
|
|
3468
|
-
const node = await this.
|
|
3461
|
+
const node = await this.locateLeaf(value);
|
|
3469
3462
|
const { index, found } = this._binarySearchValues(node.values, value);
|
|
3470
3463
|
if (found) {
|
|
3471
3464
|
const keys = node.keys[index];
|
|
@@ -3563,7 +3556,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3563
3556
|
}
|
|
3564
3557
|
async insert(key, value) {
|
|
3565
3558
|
return this.writeLock(0, async () => {
|
|
3566
|
-
let before = await this.
|
|
3559
|
+
let before = await this.locateLeaf(value);
|
|
3567
3560
|
before = await this._insertAtLeaf(before, key, value);
|
|
3568
3561
|
if (before.values.length === this.order) {
|
|
3569
3562
|
let after = await this._createNode(
|
|
@@ -3593,7 +3586,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3593
3586
|
let currentLeaf = null;
|
|
3594
3587
|
let modified = false;
|
|
3595
3588
|
for (const [key, value] of sorted) {
|
|
3596
|
-
const targetLeaf = await this.
|
|
3589
|
+
const targetLeaf = await this.locateLeaf(value);
|
|
3597
3590
|
if (currentLeaf !== null && currentLeaf.id === targetLeaf.id) {
|
|
3598
3591
|
} else {
|
|
3599
3592
|
if (currentLeaf !== null && modified) {
|
|
@@ -3837,7 +3830,7 @@ var BPTreeAsyncTransaction = class extends BPTreeTransaction {
|
|
|
3837
3830
|
if (value === void 0) {
|
|
3838
3831
|
return;
|
|
3839
3832
|
}
|
|
3840
|
-
let node = await this.
|
|
3833
|
+
let node = await this.findLowerBoundLeaf(value);
|
|
3841
3834
|
let found = false;
|
|
3842
3835
|
while (true) {
|
|
3843
3836
|
let i = node.values.length;
|
|
@@ -103,17 +103,17 @@ export declare abstract class BPTreeTransaction<K, V> {
|
|
|
103
103
|
};
|
|
104
104
|
private static readonly _lowerBoundKeys;
|
|
105
105
|
private static readonly _upperBoundKeys;
|
|
106
|
+
private static readonly _multiValueKeys;
|
|
106
107
|
protected constructor(rootTx: BPTreeTransaction<K, V> | null, mvccRoot: BPTreeMVCC<K, V>, mvcc: BPTreeMVCC<K, V>, strategy: SerializeStrategy<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
|
|
107
108
|
protected abstract _createNode(leaf: boolean, keys: string[] | K[][], values: V[], parent?: string | null, next?: string | null, prev?: string | null): Deferred<BPTreeUnknownNode<K, V>>;
|
|
108
109
|
protected abstract _deleteEntry(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>): Deferred<BPTreeUnknownNode<K, V>>;
|
|
109
110
|
protected abstract _insertInParent(node: BPTreeUnknownNode<K, V>, value: V, pointer: BPTreeUnknownNode<K, V>): Deferred<void>;
|
|
110
111
|
protected abstract _insertAtLeaf(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V): Deferred<BPTreeUnknownNode<K, V>>;
|
|
111
112
|
protected abstract getNode(id: string): Deferred<BPTreeUnknownNode<K, V>>;
|
|
112
|
-
protected abstract
|
|
113
|
-
protected abstract
|
|
114
|
-
protected abstract
|
|
115
|
-
protected abstract
|
|
116
|
-
protected abstract insertableEndNode(value: V, direction: 1 | -1): Deferred<BPTreeLeafNode<K, V> | null>;
|
|
113
|
+
protected abstract locateLeaf(value: V): Deferred<BPTreeLeafNode<K, V>>;
|
|
114
|
+
protected abstract findLowerBoundLeaf(value: V): Deferred<BPTreeLeafNode<K, V>>;
|
|
115
|
+
protected abstract findUpperBoundLeaf(value: V): Deferred<BPTreeLeafNode<K, V>>;
|
|
116
|
+
protected abstract findOuterBoundaryLeaf(value: V, direction: 1 | -1): Deferred<BPTreeLeafNode<K, V> | null>;
|
|
117
117
|
protected abstract leftestNode(): Deferred<BPTreeLeafNode<K, V>>;
|
|
118
118
|
protected abstract rightestNode(): Deferred<BPTreeLeafNode<K, V>>;
|
|
119
119
|
/**
|
|
@@ -25,11 +25,10 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeTransaction<K, V
|
|
|
25
25
|
protected _writeHead(head: SerializeStrategyHead): Promise<void>;
|
|
26
26
|
protected _insertAtLeaf(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V): Promise<BPTreeUnknownNode<K, V>>;
|
|
27
27
|
protected _insertInParent(node: BPTreeUnknownNode<K, V>, value: V, newSiblingNode: BPTreeUnknownNode<K, V>): Promise<void>;
|
|
28
|
-
protected
|
|
29
|
-
protected
|
|
30
|
-
protected
|
|
31
|
-
protected
|
|
32
|
-
protected insertableEndNode(value: V, direction: 1 | -1): Promise<BPTreeLeafNode<K, V> | null>;
|
|
28
|
+
protected locateLeaf(value: V): Promise<BPTreeLeafNode<K, V>>;
|
|
29
|
+
protected findLowerBoundLeaf(value: V): Promise<BPTreeLeafNode<K, V>>;
|
|
30
|
+
protected findUpperBoundLeaf(value: V): Promise<BPTreeLeafNode<K, V>>;
|
|
31
|
+
protected findOuterBoundaryLeaf(value: V, direction: 1 | -1): Promise<BPTreeLeafNode<K, V> | null>;
|
|
33
32
|
protected leftestNode(): Promise<BPTreeLeafNode<K, V>>;
|
|
34
33
|
protected rightestNode(): Promise<BPTreeLeafNode<K, V>>;
|
|
35
34
|
protected getPairsGenerator(startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, direction: 1 | -1): AsyncGenerator<[K, V]>;
|
|
@@ -22,11 +22,10 @@ export declare class BPTreeSyncTransaction<K, V> extends BPTreeTransaction<K, V>
|
|
|
22
22
|
protected _writeHead(head: SerializeStrategyHead): void;
|
|
23
23
|
protected _insertAtLeaf(node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V): BPTreeUnknownNode<K, V>;
|
|
24
24
|
protected _insertInParent(node: BPTreeUnknownNode<K, V>, value: V, newSiblingNode: BPTreeUnknownNode<K, V>): void;
|
|
25
|
-
protected
|
|
26
|
-
protected
|
|
27
|
-
protected
|
|
28
|
-
protected
|
|
29
|
-
protected insertableEndNode(value: V, direction: 1 | -1): BPTreeLeafNode<K, V> | null;
|
|
25
|
+
protected locateLeaf(value: V): BPTreeLeafNode<K, V>;
|
|
26
|
+
protected findLowerBoundLeaf(value: V): BPTreeLeafNode<K, V>;
|
|
27
|
+
protected findUpperBoundLeaf(value: V): BPTreeLeafNode<K, V>;
|
|
28
|
+
protected findOuterBoundaryLeaf(value: V, direction: 1 | -1): BPTreeLeafNode<K, V> | null;
|
|
30
29
|
protected leftestNode(): BPTreeLeafNode<K, V>;
|
|
31
30
|
protected rightestNode(): BPTreeLeafNode<K, V>;
|
|
32
31
|
protected getPairsGenerator(startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, direction: 1 | -1): Generator<[K, V]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serializable-bptree",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.5",
|
|
4
4
|
"description": "Store the B+tree flexibly, not only in-memory.",
|
|
5
5
|
"types": "./dist/types/index.d.ts",
|
|
6
6
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -47,4 +47,4 @@
|
|
|
47
47
|
"mvcc-api": "^1.3.5",
|
|
48
48
|
"ryoiki": "^1.2.0"
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|