dataply 0.0.11 → 0.0.12
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.js +95 -5
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -507,9 +507,15 @@ var BPTree = class {
|
|
|
507
507
|
lt: (nv, v) => this.comparator.isLower(nv, v),
|
|
508
508
|
lte: (nv, v) => this.comparator.isLower(nv, v) || this.comparator.isSame(nv, v),
|
|
509
509
|
equal: (nv, v) => this.comparator.isSame(nv, v),
|
|
510
|
-
primaryEqual: (nv, v) => this.comparator.isPrimarySame(nv, v),
|
|
511
510
|
notEqual: (nv, v) => this.comparator.isSame(nv, v) === false,
|
|
512
511
|
or: (nv, v) => this.ensureValues(v).some((v2) => this.comparator.isSame(nv, v2)),
|
|
512
|
+
primaryGt: (nv, v) => this.comparator.isPrimaryHigher(nv, v),
|
|
513
|
+
primaryGte: (nv, v) => this.comparator.isPrimaryHigher(nv, v) || this.comparator.isPrimarySame(nv, v),
|
|
514
|
+
primaryLt: (nv, v) => this.comparator.isPrimaryLower(nv, v),
|
|
515
|
+
primaryLte: (nv, v) => this.comparator.isPrimaryLower(nv, v) || this.comparator.isPrimarySame(nv, v),
|
|
516
|
+
primaryEqual: (nv, v) => this.comparator.isPrimarySame(nv, v),
|
|
517
|
+
primaryNotEqual: (nv, v) => this.comparator.isPrimarySame(nv, v) === false,
|
|
518
|
+
primaryOr: (nv, v) => this.ensureValues(v).some((v2) => this.comparator.isPrimarySame(nv, v2)),
|
|
513
519
|
like: (nv, v) => {
|
|
514
520
|
const nodeValue = this.comparator.match(nv);
|
|
515
521
|
const value = this.comparator.match(v);
|
|
@@ -524,9 +530,15 @@ var BPTree = class {
|
|
|
524
530
|
lt: (v) => this.insertableNode(v),
|
|
525
531
|
lte: (v) => this.insertableNode(v),
|
|
526
532
|
equal: (v) => this.insertableNode(v),
|
|
527
|
-
primaryEqual: (v) => this.insertableNodeByPrimary(v),
|
|
528
533
|
notEqual: (v) => this.leftestNode(),
|
|
529
534
|
or: (v) => this.insertableNode(this.lowestValue(this.ensureValues(v))),
|
|
535
|
+
primaryGt: (v) => this.insertableNodeByPrimary(v),
|
|
536
|
+
primaryGte: (v) => this.insertableNodeByPrimary(v),
|
|
537
|
+
primaryLt: (v) => this.insertableNodeByPrimary(v),
|
|
538
|
+
primaryLte: (v) => this.insertableRightestNodeByPrimary(v),
|
|
539
|
+
primaryEqual: (v) => this.insertableNodeByPrimary(v),
|
|
540
|
+
primaryNotEqual: (v) => this.leftestNode(),
|
|
541
|
+
primaryOr: (v) => this.insertableNodeByPrimary(this.lowestPrimaryValue(this.ensureValues(v))),
|
|
530
542
|
like: (v) => this.leftestNode()
|
|
531
543
|
};
|
|
532
544
|
verifierEndNode = {
|
|
@@ -535,12 +547,20 @@ var BPTree = class {
|
|
|
535
547
|
lt: (v) => null,
|
|
536
548
|
lte: (v) => null,
|
|
537
549
|
equal: (v) => this.insertableEndNode(v, this.verifierDirection.equal),
|
|
538
|
-
primaryEqual: (v) => null,
|
|
539
550
|
notEqual: (v) => null,
|
|
540
551
|
or: (v) => this.insertableEndNode(
|
|
541
552
|
this.highestValue(this.ensureValues(v)),
|
|
542
553
|
this.verifierDirection.or
|
|
543
554
|
),
|
|
555
|
+
primaryGt: (v) => null,
|
|
556
|
+
primaryGte: (v) => null,
|
|
557
|
+
primaryLt: (v) => null,
|
|
558
|
+
primaryLte: (v) => null,
|
|
559
|
+
primaryEqual: (v) => null,
|
|
560
|
+
primaryNotEqual: (v) => null,
|
|
561
|
+
primaryOr: (v) => this.insertableRightestEndNodeByPrimary(
|
|
562
|
+
this.highestPrimaryValue(this.ensureValues(v))
|
|
563
|
+
),
|
|
544
564
|
like: (v) => null
|
|
545
565
|
};
|
|
546
566
|
verifierDirection = {
|
|
@@ -549,9 +569,15 @@ var BPTree = class {
|
|
|
549
569
|
lt: -1,
|
|
550
570
|
lte: -1,
|
|
551
571
|
equal: 1,
|
|
552
|
-
primaryEqual: 1,
|
|
553
572
|
notEqual: 1,
|
|
554
573
|
or: 1,
|
|
574
|
+
primaryGt: 1,
|
|
575
|
+
primaryGte: 1,
|
|
576
|
+
primaryLt: -1,
|
|
577
|
+
primaryLte: -1,
|
|
578
|
+
primaryEqual: 1,
|
|
579
|
+
primaryNotEqual: 1,
|
|
580
|
+
primaryOr: 1,
|
|
555
581
|
like: 1
|
|
556
582
|
};
|
|
557
583
|
/**
|
|
@@ -565,9 +591,15 @@ var BPTree = class {
|
|
|
565
591
|
lt: false,
|
|
566
592
|
lte: false,
|
|
567
593
|
equal: true,
|
|
568
|
-
primaryEqual: true,
|
|
569
594
|
notEqual: false,
|
|
570
595
|
or: false,
|
|
596
|
+
primaryGt: false,
|
|
597
|
+
primaryGte: false,
|
|
598
|
+
primaryLt: false,
|
|
599
|
+
primaryLte: false,
|
|
600
|
+
primaryEqual: true,
|
|
601
|
+
primaryNotEqual: false,
|
|
602
|
+
primaryOr: false,
|
|
571
603
|
like: false
|
|
572
604
|
};
|
|
573
605
|
constructor(strategy, comparator, option) {
|
|
@@ -603,6 +635,14 @@ var BPTree = class {
|
|
|
603
635
|
const i = v.length - 1;
|
|
604
636
|
return [...v].sort((a, b) => this.comparator.asc(a, b))[i];
|
|
605
637
|
}
|
|
638
|
+
lowestPrimaryValue(v) {
|
|
639
|
+
const i = 0;
|
|
640
|
+
return [...v].sort((a, b) => this.comparator.primaryAsc(a, b))[i];
|
|
641
|
+
}
|
|
642
|
+
highestPrimaryValue(v) {
|
|
643
|
+
const i = v.length - 1;
|
|
644
|
+
return [...v].sort((a, b) => this.comparator.primaryAsc(a, b))[i];
|
|
645
|
+
}
|
|
606
646
|
_insertAtLeaf(node, key, value) {
|
|
607
647
|
if (node.values.length) {
|
|
608
648
|
for (let i = 0, len = node.values.length; i < len; i++) {
|
|
@@ -1125,6 +1165,31 @@ var BPTreeSync = class extends BPTree {
|
|
|
1125
1165
|
}
|
|
1126
1166
|
return node;
|
|
1127
1167
|
}
|
|
1168
|
+
insertableRightestNodeByPrimary(value) {
|
|
1169
|
+
let node = this.getNode(this.root.id);
|
|
1170
|
+
while (!node.leaf) {
|
|
1171
|
+
for (let i = 0, len = node.values.length; i < len; i++) {
|
|
1172
|
+
const nValue = node.values[i];
|
|
1173
|
+
const k = node.keys;
|
|
1174
|
+
if (this.comparator.isPrimaryLower(value, nValue)) {
|
|
1175
|
+
node = this.getNode(k[i]);
|
|
1176
|
+
break;
|
|
1177
|
+
}
|
|
1178
|
+
if (i + 1 === node.values.length) {
|
|
1179
|
+
node = this.getNode(k[i + 1]);
|
|
1180
|
+
break;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
return node;
|
|
1185
|
+
}
|
|
1186
|
+
insertableRightestEndNodeByPrimary(value) {
|
|
1187
|
+
const node = this.insertableRightestNodeByPrimary(value);
|
|
1188
|
+
if (!node.next) {
|
|
1189
|
+
return null;
|
|
1190
|
+
}
|
|
1191
|
+
return this.getNode(node.next);
|
|
1192
|
+
}
|
|
1128
1193
|
insertableEndNode(value, direction) {
|
|
1129
1194
|
const insertableNode = this.insertableNode(value);
|
|
1130
1195
|
let key;
|
|
@@ -2049,6 +2114,31 @@ var BPTreeAsync = class extends BPTree {
|
|
|
2049
2114
|
}
|
|
2050
2115
|
return node;
|
|
2051
2116
|
}
|
|
2117
|
+
async insertableRightestNodeByPrimary(value) {
|
|
2118
|
+
let node = await this.getNode(this.root.id);
|
|
2119
|
+
while (!node.leaf) {
|
|
2120
|
+
for (let i = 0, len = node.values.length; i < len; i++) {
|
|
2121
|
+
const nValue = node.values[i];
|
|
2122
|
+
const k = node.keys;
|
|
2123
|
+
if (this.comparator.isPrimaryLower(value, nValue)) {
|
|
2124
|
+
node = await this.getNode(k[i]);
|
|
2125
|
+
break;
|
|
2126
|
+
}
|
|
2127
|
+
if (i + 1 === node.values.length) {
|
|
2128
|
+
node = await this.getNode(k[i + 1]);
|
|
2129
|
+
break;
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
return node;
|
|
2134
|
+
}
|
|
2135
|
+
async insertableRightestEndNodeByPrimary(value) {
|
|
2136
|
+
const node = await this.insertableRightestNodeByPrimary(value);
|
|
2137
|
+
if (!node.next) {
|
|
2138
|
+
return null;
|
|
2139
|
+
}
|
|
2140
|
+
return await this.getNode(node.next);
|
|
2141
|
+
}
|
|
2052
2142
|
async insertableEndNode(value, direction) {
|
|
2053
2143
|
const insertableNode = await this.insertableNode(value);
|
|
2054
2144
|
let key;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dataply",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "A lightweight storage engine for Node.js with support for MVCC, WAL.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "izure <admin@izure.org>",
|
|
@@ -47,6 +47,6 @@
|
|
|
47
47
|
"cache-entanglement": "^1.7.1",
|
|
48
48
|
"hookall": "^2.2.0",
|
|
49
49
|
"ryoiki": "^1.2.0",
|
|
50
|
-
"serializable-bptree": "^6.1.
|
|
50
|
+
"serializable-bptree": "^6.1.1"
|
|
51
51
|
}
|
|
52
52
|
}
|