@tanstack/db-ivm 0.0.0 → 0.1.1
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/LICENSE +21 -0
- package/dist/cjs/d2.cjs +111 -0
- package/dist/cjs/d2.cjs.map +1 -0
- package/dist/cjs/d2.d.cts +45 -0
- package/dist/cjs/graph.cjs +90 -0
- package/dist/cjs/graph.cjs.map +1 -0
- package/dist/cjs/graph.d.cts +57 -0
- package/dist/cjs/index.cjs +72 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +4 -0
- package/dist/cjs/indexes.cjs +104 -0
- package/dist/cjs/indexes.cjs.map +1 -0
- package/dist/cjs/indexes.d.cts +20 -0
- package/dist/cjs/multiset.cjs +173 -0
- package/dist/cjs/multiset.cjs.map +1 -0
- package/dist/cjs/multiset.d.cts +36 -0
- package/dist/cjs/operators/concat.cjs +37 -0
- package/dist/cjs/operators/concat.cjs.map +1 -0
- package/dist/cjs/operators/concat.d.cts +13 -0
- package/dist/cjs/operators/consolidate.cjs +40 -0
- package/dist/cjs/operators/consolidate.cjs.map +1 -0
- package/dist/cjs/operators/consolidate.d.cts +12 -0
- package/dist/cjs/operators/count.cjs +36 -0
- package/dist/cjs/operators/count.cjs.map +1 -0
- package/dist/cjs/operators/count.d.cts +13 -0
- package/dist/cjs/operators/debug.cjs +50 -0
- package/dist/cjs/operators/debug.cjs.map +1 -0
- package/dist/cjs/operators/debug.d.cts +16 -0
- package/dist/cjs/operators/distinct.cjs +78 -0
- package/dist/cjs/operators/distinct.cjs.map +1 -0
- package/dist/cjs/operators/distinct.d.cts +14 -0
- package/dist/cjs/operators/filter.cjs +43 -0
- package/dist/cjs/operators/filter.cjs.map +1 -0
- package/dist/cjs/operators/filter.d.cts +16 -0
- package/dist/cjs/operators/filterBy.cjs +19 -0
- package/dist/cjs/operators/filterBy.cjs.map +1 -0
- package/dist/cjs/operators/filterBy.d.cts +10 -0
- package/dist/cjs/operators/groupBy.cjs +225 -0
- package/dist/cjs/operators/groupBy.cjs.map +1 -0
- package/dist/cjs/operators/groupBy.d.cts +68 -0
- package/dist/cjs/operators/index.d.cts +18 -0
- package/dist/cjs/operators/join.cjs +145 -0
- package/dist/cjs/operators/join.cjs.map +1 -0
- package/dist/cjs/operators/join.d.cts +48 -0
- package/dist/cjs/operators/keying.cjs +16 -0
- package/dist/cjs/operators/keying.cjs.map +1 -0
- package/dist/cjs/operators/keying.d.cts +19 -0
- package/dist/cjs/operators/map.cjs +43 -0
- package/dist/cjs/operators/map.cjs.map +1 -0
- package/dist/cjs/operators/map.d.cts +16 -0
- package/dist/cjs/operators/negate.cjs +28 -0
- package/dist/cjs/operators/negate.cjs.map +1 -0
- package/dist/cjs/operators/negate.d.cts +13 -0
- package/dist/cjs/operators/orderBy.cjs +102 -0
- package/dist/cjs/operators/orderBy.cjs.map +1 -0
- package/dist/cjs/operators/orderBy.d.cts +38 -0
- package/dist/cjs/operators/orderByBTree.d.cts +3 -0
- package/dist/cjs/operators/output.cjs +46 -0
- package/dist/cjs/operators/output.cjs.map +1 -0
- package/dist/cjs/operators/output.d.cts +16 -0
- package/dist/cjs/operators/pipe.cjs +9 -0
- package/dist/cjs/operators/pipe.cjs.map +1 -0
- package/dist/cjs/operators/pipe.d.cts +21 -0
- package/dist/cjs/operators/reduce.cjs +99 -0
- package/dist/cjs/operators/reduce.cjs.map +1 -0
- package/dist/cjs/operators/reduce.d.cts +14 -0
- package/dist/cjs/operators/topK.cjs +39 -0
- package/dist/cjs/operators/topK.cjs.map +1 -0
- package/dist/cjs/operators/topK.d.cts +32 -0
- package/dist/cjs/operators/topKWithFractionalIndex.cjs +218 -0
- package/dist/cjs/operators/topKWithFractionalIndex.cjs.map +1 -0
- package/dist/cjs/operators/topKWithFractionalIndex.d.cts +58 -0
- package/dist/cjs/operators/topKWithFractionalIndexBTree.d.cts +27 -0
- package/dist/cjs/types.d.cts +30 -0
- package/dist/cjs/utils.cjs +125 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +40 -0
- package/dist/esm/d2.d.ts +45 -0
- package/dist/esm/d2.js +111 -0
- package/dist/esm/d2.js.map +1 -0
- package/dist/esm/graph.d.ts +57 -0
- package/dist/esm/graph.js +90 -0
- package/dist/esm/graph.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +72 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/indexes.d.ts +20 -0
- package/dist/esm/indexes.js +104 -0
- package/dist/esm/indexes.js.map +1 -0
- package/dist/esm/multiset.d.ts +36 -0
- package/dist/esm/multiset.js +173 -0
- package/dist/esm/multiset.js.map +1 -0
- package/dist/esm/operators/concat.d.ts +13 -0
- package/dist/esm/operators/concat.js +37 -0
- package/dist/esm/operators/concat.js.map +1 -0
- package/dist/esm/operators/consolidate.d.ts +12 -0
- package/dist/esm/operators/consolidate.js +40 -0
- package/dist/esm/operators/consolidate.js.map +1 -0
- package/dist/esm/operators/count.d.ts +13 -0
- package/dist/esm/operators/count.js +36 -0
- package/dist/esm/operators/count.js.map +1 -0
- package/dist/esm/operators/debug.d.ts +16 -0
- package/dist/esm/operators/debug.js +50 -0
- package/dist/esm/operators/debug.js.map +1 -0
- package/dist/esm/operators/distinct.d.ts +14 -0
- package/dist/esm/operators/distinct.js +78 -0
- package/dist/esm/operators/distinct.js.map +1 -0
- package/dist/esm/operators/filter.d.ts +16 -0
- package/dist/esm/operators/filter.js +43 -0
- package/dist/esm/operators/filter.js.map +1 -0
- package/dist/esm/operators/filterBy.d.ts +10 -0
- package/dist/esm/operators/filterBy.js +19 -0
- package/dist/esm/operators/filterBy.js.map +1 -0
- package/dist/esm/operators/groupBy.d.ts +68 -0
- package/dist/esm/operators/groupBy.js +225 -0
- package/dist/esm/operators/groupBy.js.map +1 -0
- package/dist/esm/operators/index.d.ts +18 -0
- package/dist/esm/operators/join.d.ts +48 -0
- package/dist/esm/operators/join.js +145 -0
- package/dist/esm/operators/join.js.map +1 -0
- package/dist/esm/operators/keying.d.ts +19 -0
- package/dist/esm/operators/keying.js +16 -0
- package/dist/esm/operators/keying.js.map +1 -0
- package/dist/esm/operators/map.d.ts +16 -0
- package/dist/esm/operators/map.js +43 -0
- package/dist/esm/operators/map.js.map +1 -0
- package/dist/esm/operators/negate.d.ts +13 -0
- package/dist/esm/operators/negate.js +28 -0
- package/dist/esm/operators/negate.js.map +1 -0
- package/dist/esm/operators/orderBy.d.ts +38 -0
- package/dist/esm/operators/orderBy.js +102 -0
- package/dist/esm/operators/orderBy.js.map +1 -0
- package/dist/esm/operators/orderByBTree.d.ts +3 -0
- package/dist/esm/operators/output.d.ts +16 -0
- package/dist/esm/operators/output.js +46 -0
- package/dist/esm/operators/output.js.map +1 -0
- package/dist/esm/operators/pipe.d.ts +21 -0
- package/dist/esm/operators/pipe.js +9 -0
- package/dist/esm/operators/pipe.js.map +1 -0
- package/dist/esm/operators/reduce.d.ts +14 -0
- package/dist/esm/operators/reduce.js +99 -0
- package/dist/esm/operators/reduce.js.map +1 -0
- package/dist/esm/operators/topK.d.ts +32 -0
- package/dist/esm/operators/topK.js +39 -0
- package/dist/esm/operators/topK.js.map +1 -0
- package/dist/esm/operators/topKWithFractionalIndex.d.ts +58 -0
- package/dist/esm/operators/topKWithFractionalIndex.js +218 -0
- package/dist/esm/operators/topKWithFractionalIndex.js.map +1 -0
- package/dist/esm/operators/topKWithFractionalIndexBTree.d.ts +27 -0
- package/dist/esm/types.d.ts +30 -0
- package/dist/esm/utils.d.ts +40 -0
- package/dist/esm/utils.js +125 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +6 -7
- package/src/operators/orderBy.ts +11 -29
- package/src/operators/topKWithFractionalIndex.ts +69 -57
- package/src/operators/topKWithFractionalIndexBTree.ts +14 -19
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kyle Mathews
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cjs/d2.cjs
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
6
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
7
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
8
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
9
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
10
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
11
|
+
set _(value) {
|
|
12
|
+
__privateSet(obj, member, value, setter);
|
|
13
|
+
},
|
|
14
|
+
get _() {
|
|
15
|
+
return __privateGet(obj, member, getter);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _streams, _operators, _nextOperatorId, _finalized, _D2_instances, checkNotFinalized_fn, _graph, _writer;
|
|
19
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
20
|
+
const graph = require("./graph.cjs");
|
|
21
|
+
class D2 {
|
|
22
|
+
constructor() {
|
|
23
|
+
__privateAdd(this, _D2_instances);
|
|
24
|
+
__privateAdd(this, _streams, []);
|
|
25
|
+
__privateAdd(this, _operators, []);
|
|
26
|
+
__privateAdd(this, _nextOperatorId, 0);
|
|
27
|
+
__privateAdd(this, _finalized, false);
|
|
28
|
+
}
|
|
29
|
+
getNextOperatorId() {
|
|
30
|
+
__privateMethod(this, _D2_instances, checkNotFinalized_fn).call(this);
|
|
31
|
+
return __privateWrapper(this, _nextOperatorId)._++;
|
|
32
|
+
}
|
|
33
|
+
newInput() {
|
|
34
|
+
__privateMethod(this, _D2_instances, checkNotFinalized_fn).call(this);
|
|
35
|
+
const writer = new graph.DifferenceStreamWriter();
|
|
36
|
+
const streamBuilder = new RootStreamBuilder(this, writer);
|
|
37
|
+
__privateGet(this, _streams).push(streamBuilder.connectReader());
|
|
38
|
+
return streamBuilder;
|
|
39
|
+
}
|
|
40
|
+
addOperator(operator) {
|
|
41
|
+
__privateMethod(this, _D2_instances, checkNotFinalized_fn).call(this);
|
|
42
|
+
__privateGet(this, _operators).push(operator);
|
|
43
|
+
}
|
|
44
|
+
addStream(stream) {
|
|
45
|
+
__privateMethod(this, _D2_instances, checkNotFinalized_fn).call(this);
|
|
46
|
+
__privateGet(this, _streams).push(stream);
|
|
47
|
+
}
|
|
48
|
+
finalize() {
|
|
49
|
+
__privateMethod(this, _D2_instances, checkNotFinalized_fn).call(this);
|
|
50
|
+
__privateSet(this, _finalized, true);
|
|
51
|
+
}
|
|
52
|
+
step() {
|
|
53
|
+
if (!__privateGet(this, _finalized)) {
|
|
54
|
+
throw new Error(`Graph not finalized`);
|
|
55
|
+
}
|
|
56
|
+
for (const op of __privateGet(this, _operators)) {
|
|
57
|
+
op.run();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
pendingWork() {
|
|
61
|
+
return __privateGet(this, _operators).some((op) => op.hasPendingWork());
|
|
62
|
+
}
|
|
63
|
+
run() {
|
|
64
|
+
while (this.pendingWork()) {
|
|
65
|
+
this.step();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
_streams = new WeakMap();
|
|
70
|
+
_operators = new WeakMap();
|
|
71
|
+
_nextOperatorId = new WeakMap();
|
|
72
|
+
_finalized = new WeakMap();
|
|
73
|
+
_D2_instances = new WeakSet();
|
|
74
|
+
checkNotFinalized_fn = function() {
|
|
75
|
+
if (__privateGet(this, _finalized)) {
|
|
76
|
+
throw new Error(`Graph already finalized`);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
class StreamBuilder {
|
|
80
|
+
constructor(graph2, writer) {
|
|
81
|
+
__privateAdd(this, _graph);
|
|
82
|
+
__privateAdd(this, _writer);
|
|
83
|
+
__privateSet(this, _graph, graph2);
|
|
84
|
+
__privateSet(this, _writer, writer);
|
|
85
|
+
}
|
|
86
|
+
connectReader() {
|
|
87
|
+
return __privateGet(this, _writer).newReader();
|
|
88
|
+
}
|
|
89
|
+
get writer() {
|
|
90
|
+
return __privateGet(this, _writer);
|
|
91
|
+
}
|
|
92
|
+
get graph() {
|
|
93
|
+
return __privateGet(this, _graph);
|
|
94
|
+
}
|
|
95
|
+
pipe(...operators) {
|
|
96
|
+
return operators.reduce((stream, operator) => {
|
|
97
|
+
return operator(stream);
|
|
98
|
+
}, this);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
_graph = new WeakMap();
|
|
102
|
+
_writer = new WeakMap();
|
|
103
|
+
class RootStreamBuilder extends StreamBuilder {
|
|
104
|
+
sendData(collection) {
|
|
105
|
+
this.writer.sendData(collection);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.D2 = D2;
|
|
109
|
+
exports.RootStreamBuilder = RootStreamBuilder;
|
|
110
|
+
exports.StreamBuilder = StreamBuilder;
|
|
111
|
+
//# sourceMappingURL=d2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"d2.cjs","sources":["../../src/d2.ts"],"sourcesContent":["import { DifferenceStreamWriter } from \"./graph.js\"\nimport type {\n BinaryOperator,\n DifferenceStreamReader,\n UnaryOperator,\n} from \"./graph.js\"\nimport type { MultiSet, MultiSetArray } from \"./multiset.js\"\nimport type { ID2, IStreamBuilder, PipedOperator } from \"./types.js\"\n\nexport class D2 implements ID2 {\n #streams: Array<DifferenceStreamReader<any>> = []\n #operators: Array<UnaryOperator<any> | BinaryOperator<any>> = []\n #nextOperatorId = 0\n #finalized = false\n\n constructor() {}\n\n #checkNotFinalized(): void {\n if (this.#finalized) {\n throw new Error(`Graph already finalized`)\n }\n }\n\n getNextOperatorId(): number {\n this.#checkNotFinalized()\n return this.#nextOperatorId++\n }\n\n newInput<T>(): RootStreamBuilder<T> {\n this.#checkNotFinalized()\n const writer = new DifferenceStreamWriter<T>()\n // Use the root stream builder that exposes the sendData and sendFrontier methods\n const streamBuilder = new RootStreamBuilder<T>(this, writer)\n this.#streams.push(streamBuilder.connectReader())\n return streamBuilder\n }\n\n addOperator(operator: UnaryOperator<any> | BinaryOperator<any>): void {\n this.#checkNotFinalized()\n this.#operators.push(operator)\n }\n\n addStream(stream: DifferenceStreamReader<any>): void {\n this.#checkNotFinalized()\n this.#streams.push(stream)\n }\n\n finalize() {\n this.#checkNotFinalized()\n this.#finalized = true\n }\n\n step(): void {\n if (!this.#finalized) {\n throw new Error(`Graph not finalized`)\n }\n for (const op of this.#operators) {\n op.run()\n }\n }\n\n pendingWork(): boolean {\n return this.#operators.some((op) => op.hasPendingWork())\n }\n\n run(): void {\n while (this.pendingWork()) {\n this.step()\n }\n }\n}\n\nexport class StreamBuilder<T> implements IStreamBuilder<T> {\n #graph: ID2\n #writer: DifferenceStreamWriter<T>\n\n constructor(graph: ID2, writer: DifferenceStreamWriter<T>) {\n this.#graph = graph\n this.#writer = writer\n }\n\n connectReader(): DifferenceStreamReader<T> {\n return this.#writer.newReader()\n }\n\n get writer(): DifferenceStreamWriter<T> {\n return this.#writer\n }\n\n get graph(): ID2 {\n return this.#graph\n }\n\n // Don't judge, this is the only way to type this function.\n // rxjs has very similar code to type its pipe function\n // https://github.com/ReactiveX/rxjs/blob/master/packages/rxjs/src/internal/util/pipe.ts\n // We go to 20 operators deep, because surly that's enough for anyone...\n // A user can always split the pipe into multiple pipes to get around this.\n pipe<O>(o1: PipedOperator<T, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, T16>, o16: PipedOperator<T16, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, T16>, o16: PipedOperator<T16, T17>, o17: PipedOperator<T17, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, T16>, o16: PipedOperator<T16, T17>, o17: PipedOperator<T17, T18>, o18: PipedOperator<T18, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, T16>, o16: PipedOperator<T16, T17>, o17: PipedOperator<T17, T18>, o18: PipedOperator<T18, T19>, o19: PipedOperator<T19, O>): IStreamBuilder<O>\n // prettier-ignore\n pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, T16>, o16: PipedOperator<T16, T17>, o17: PipedOperator<T17, T18>, o18: PipedOperator<T18, T19>, o19: PipedOperator<T19, T20>, o20: PipedOperator<T20, O>): IStreamBuilder<O>\n\n pipe(...operators: Array<PipedOperator<any, any>>): IStreamBuilder<any> {\n return operators.reduce((stream, operator) => {\n return operator(stream)\n }, this as IStreamBuilder<any>)\n }\n}\n\nexport class RootStreamBuilder<T> extends StreamBuilder<T> {\n sendData(collection: MultiSet<T> | MultiSetArray<T>): void {\n this.writer.sendData(collection)\n }\n}\n"],"names":["DifferenceStreamWriter","graph"],"mappings":";;;;;;;;;;;;;;;;;;;;AASO,MAAM,GAAkB;AAAA,EAM7B,cAAc;AANT;AACL,iCAA+C,CAAA;AAC/C,mCAA8D,CAAA;AAC9D,wCAAkB;AAClB,mCAAa;AAAA,EAEE;AAAA,EAQf,oBAA4B;AAC1B,0BAAK,qCAAL;AACA,WAAO,uBAAK,iBAAL;AAAA,EACT;AAAA,EAEA,WAAoC;AAClC,0BAAK,qCAAL;AACA,UAAM,SAAS,IAAIA,6BAAA;AAEnB,UAAM,gBAAgB,IAAI,kBAAqB,MAAM,MAAM;AAC3D,uBAAK,UAAS,KAAK,cAAc,cAAA,CAAe;AAChD,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,UAA0D;AACpE,0BAAK,qCAAL;AACA,uBAAK,YAAW,KAAK,QAAQ;AAAA,EAC/B;AAAA,EAEA,UAAU,QAA2C;AACnD,0BAAK,qCAAL;AACA,uBAAK,UAAS,KAAK,MAAM;AAAA,EAC3B;AAAA,EAEA,WAAW;AACT,0BAAK,qCAAL;AACA,uBAAK,YAAa;AAAA,EACpB;AAAA,EAEA,OAAa;AACX,QAAI,CAAC,mBAAK,aAAY;AACpB,YAAM,IAAI,MAAM,qBAAqB;AAAA,IACvC;AACA,eAAW,MAAM,mBAAK,aAAY;AAChC,SAAG,IAAA;AAAA,IACL;AAAA,EACF;AAAA,EAEA,cAAuB;AACrB,WAAO,mBAAK,YAAW,KAAK,CAAC,OAAO,GAAG,gBAAgB;AAAA,EACzD;AAAA,EAEA,MAAY;AACV,WAAO,KAAK,eAAe;AACzB,WAAK,KAAA;AAAA,IACP;AAAA,EACF;AACF;AA5DE;AACA;AACA;AACA;AAJK;AAQL,uBAAA,WAA2B;AACzB,MAAI,mBAAK,aAAY;AACnB,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AACF;AAmDK,MAAM,cAA8C;AAAA,EAIzD,YAAYC,QAAY,QAAmC;AAH3D;AACA;AAGE,uBAAK,QAASA;AACd,uBAAK,SAAU;AAAA,EACjB;AAAA,EAEA,gBAA2C;AACzC,WAAO,mBAAK,SAAQ,UAAA;AAAA,EACtB;AAAA,EAEA,IAAI,SAAoC;AACtC,WAAO,mBAAK;AAAA,EACd;AAAA,EAEA,IAAI,QAAa;AACf,WAAO,mBAAK;AAAA,EACd;AAAA,EA+CA,QAAQ,WAAgE;AACtE,WAAO,UAAU,OAAO,CAAC,QAAQ,aAAa;AAC5C,aAAO,SAAS,MAAM;AAAA,IACxB,GAAG,IAA2B;AAAA,EAChC;AACF;AAtEE;AACA;AAuEK,MAAM,0BAA6B,cAAiB;AAAA,EACzD,SAAS,YAAkD;AACzD,SAAK,OAAO,SAAS,UAAU;AAAA,EACjC;AACF;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DifferenceStreamWriter, BinaryOperator, DifferenceStreamReader, UnaryOperator } from './graph.js';
|
|
2
|
+
import { MultiSet, MultiSetArray } from './multiset.js';
|
|
3
|
+
import { ID2, IStreamBuilder, PipedOperator } from './types.js';
|
|
4
|
+
export declare class D2 implements ID2 {
|
|
5
|
+
#private;
|
|
6
|
+
constructor();
|
|
7
|
+
getNextOperatorId(): number;
|
|
8
|
+
newInput<T>(): RootStreamBuilder<T>;
|
|
9
|
+
addOperator(operator: UnaryOperator<any> | BinaryOperator<any>): void;
|
|
10
|
+
addStream(stream: DifferenceStreamReader<any>): void;
|
|
11
|
+
finalize(): void;
|
|
12
|
+
step(): void;
|
|
13
|
+
pendingWork(): boolean;
|
|
14
|
+
run(): void;
|
|
15
|
+
}
|
|
16
|
+
export declare class StreamBuilder<T> implements IStreamBuilder<T> {
|
|
17
|
+
#private;
|
|
18
|
+
constructor(graph: ID2, writer: DifferenceStreamWriter<T>);
|
|
19
|
+
connectReader(): DifferenceStreamReader<T>;
|
|
20
|
+
get writer(): DifferenceStreamWriter<T>;
|
|
21
|
+
get graph(): ID2;
|
|
22
|
+
pipe<O>(o1: PipedOperator<T, O>): IStreamBuilder<O>;
|
|
23
|
+
pipe<T2, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, O>): IStreamBuilder<O>;
|
|
24
|
+
pipe<T2, T3, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, O>): IStreamBuilder<O>;
|
|
25
|
+
pipe<T2, T3, T4, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, O>): IStreamBuilder<O>;
|
|
26
|
+
pipe<T2, T3, T4, T5, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, O>): IStreamBuilder<O>;
|
|
27
|
+
pipe<T2, T3, T4, T5, T6, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, O>): IStreamBuilder<O>;
|
|
28
|
+
pipe<T2, T3, T4, T5, T6, T7, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, O>): IStreamBuilder<O>;
|
|
29
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, O>): IStreamBuilder<O>;
|
|
30
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, O>): IStreamBuilder<O>;
|
|
31
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, O>): IStreamBuilder<O>;
|
|
32
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, O>): IStreamBuilder<O>;
|
|
33
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, O>): IStreamBuilder<O>;
|
|
34
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, O>): IStreamBuilder<O>;
|
|
35
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, O>): IStreamBuilder<O>;
|
|
36
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, O>): IStreamBuilder<O>;
|
|
37
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, T16>, o16: PipedOperator<T16, O>): IStreamBuilder<O>;
|
|
38
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, T16>, o16: PipedOperator<T16, T17>, o17: PipedOperator<T17, O>): IStreamBuilder<O>;
|
|
39
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, T16>, o16: PipedOperator<T16, T17>, o17: PipedOperator<T17, T18>, o18: PipedOperator<T18, O>): IStreamBuilder<O>;
|
|
40
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, T16>, o16: PipedOperator<T16, T17>, o17: PipedOperator<T17, T18>, o18: PipedOperator<T18, T19>, o19: PipedOperator<T19, O>): IStreamBuilder<O>;
|
|
41
|
+
pipe<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, O>(o1: PipedOperator<T, T2>, o2: PipedOperator<T2, T3>, o3: PipedOperator<T3, T4>, o4: PipedOperator<T4, T5>, o5: PipedOperator<T5, T6>, o6: PipedOperator<T6, T7>, o7: PipedOperator<T7, T8>, o8: PipedOperator<T8, T9>, o9: PipedOperator<T9, T10>, o10: PipedOperator<T10, T11>, o11: PipedOperator<T11, T12>, o12: PipedOperator<T12, T13>, o13: PipedOperator<T13, T14>, o14: PipedOperator<T14, T15>, o15: PipedOperator<T15, T16>, o16: PipedOperator<T16, T17>, o17: PipedOperator<T17, T18>, o18: PipedOperator<T18, T19>, o19: PipedOperator<T19, T20>, o20: PipedOperator<T20, O>): IStreamBuilder<O>;
|
|
42
|
+
}
|
|
43
|
+
export declare class RootStreamBuilder<T> extends StreamBuilder<T> {
|
|
44
|
+
sendData(collection: MultiSet<T> | MultiSetArray<T>): void;
|
|
45
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
6
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
7
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
8
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
9
|
+
var _queue, _queues;
|
|
10
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
const multiset = require("./multiset.cjs");
|
|
12
|
+
class DifferenceStreamReader {
|
|
13
|
+
constructor(queue) {
|
|
14
|
+
__privateAdd(this, _queue);
|
|
15
|
+
__privateSet(this, _queue, queue);
|
|
16
|
+
}
|
|
17
|
+
drain() {
|
|
18
|
+
const out = [...__privateGet(this, _queue)].reverse();
|
|
19
|
+
__privateGet(this, _queue).length = 0;
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
isEmpty() {
|
|
23
|
+
return __privateGet(this, _queue).length === 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
_queue = new WeakMap();
|
|
27
|
+
class DifferenceStreamWriter {
|
|
28
|
+
constructor() {
|
|
29
|
+
__privateAdd(this, _queues, []);
|
|
30
|
+
}
|
|
31
|
+
sendData(collection) {
|
|
32
|
+
if (!(collection instanceof multiset.MultiSet)) {
|
|
33
|
+
collection = new multiset.MultiSet(collection);
|
|
34
|
+
}
|
|
35
|
+
for (const q of __privateGet(this, _queues)) {
|
|
36
|
+
q.unshift(collection);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
newReader() {
|
|
40
|
+
const q = [];
|
|
41
|
+
__privateGet(this, _queues).push(q);
|
|
42
|
+
return new DifferenceStreamReader(q);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
_queues = new WeakMap();
|
|
46
|
+
class Operator {
|
|
47
|
+
constructor(id, inputs, output) {
|
|
48
|
+
this.id = id;
|
|
49
|
+
this.inputs = inputs;
|
|
50
|
+
this.output = output;
|
|
51
|
+
}
|
|
52
|
+
hasPendingWork() {
|
|
53
|
+
return this.inputs.some((input) => !input.isEmpty());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class UnaryOperator extends Operator {
|
|
57
|
+
constructor(id, inputA, output) {
|
|
58
|
+
super(id, [inputA], output);
|
|
59
|
+
this.id = id;
|
|
60
|
+
}
|
|
61
|
+
inputMessages() {
|
|
62
|
+
return this.inputs[0].drain();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
class BinaryOperator extends Operator {
|
|
66
|
+
constructor(id, inputA, inputB, output) {
|
|
67
|
+
super(id, [inputA, inputB], output);
|
|
68
|
+
this.id = id;
|
|
69
|
+
}
|
|
70
|
+
inputAMessages() {
|
|
71
|
+
return this.inputs[0].drain();
|
|
72
|
+
}
|
|
73
|
+
inputBMessages() {
|
|
74
|
+
return this.inputs[1].drain();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
class LinearUnaryOperator extends UnaryOperator {
|
|
78
|
+
run() {
|
|
79
|
+
for (const message of this.inputMessages()) {
|
|
80
|
+
this.output.sendData(this.inner(message));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.BinaryOperator = BinaryOperator;
|
|
85
|
+
exports.DifferenceStreamReader = DifferenceStreamReader;
|
|
86
|
+
exports.DifferenceStreamWriter = DifferenceStreamWriter;
|
|
87
|
+
exports.LinearUnaryOperator = LinearUnaryOperator;
|
|
88
|
+
exports.Operator = Operator;
|
|
89
|
+
exports.UnaryOperator = UnaryOperator;
|
|
90
|
+
//# sourceMappingURL=graph.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.cjs","sources":["../../src/graph.ts"],"sourcesContent":["import { MultiSet } from \"./multiset.js\"\nimport type { MultiSetArray } from \"./multiset.js\"\nimport type {\n IDifferenceStreamReader,\n IDifferenceStreamWriter,\n IOperator,\n} from \"./types.js\"\n\n/**\n * A read handle to a dataflow edge that receives data from a writer.\n */\nexport class DifferenceStreamReader<T> implements IDifferenceStreamReader<T> {\n #queue: Array<MultiSet<T>>\n\n constructor(queue: Array<MultiSet<T>>) {\n this.#queue = queue\n }\n\n drain(): Array<MultiSet<T>> {\n const out = [...this.#queue].reverse()\n this.#queue.length = 0\n return out\n }\n\n isEmpty(): boolean {\n return this.#queue.length === 0\n }\n}\n\n/**\n * A write handle to a dataflow edge that is allowed to publish data.\n */\nexport class DifferenceStreamWriter<T> implements IDifferenceStreamWriter<T> {\n #queues: Array<Array<MultiSet<T>>> = []\n\n sendData(collection: MultiSet<T> | MultiSetArray<T>): void {\n if (!(collection instanceof MultiSet)) {\n collection = new MultiSet(collection)\n }\n\n for (const q of this.#queues) {\n q.unshift(collection)\n }\n }\n\n newReader(): DifferenceStreamReader<T> {\n const q: Array<MultiSet<T>> = []\n this.#queues.push(q)\n return new DifferenceStreamReader(q)\n }\n}\n\n/**\n * A generic implementation of a dataflow operator (node) that has multiple incoming edges (read handles) and\n * one outgoing edge (write handle).\n */\nexport abstract class Operator<T> implements IOperator<T> {\n protected inputs: Array<DifferenceStreamReader<T>>\n protected output: DifferenceStreamWriter<T>\n\n constructor(\n public id: number,\n inputs: Array<DifferenceStreamReader<T>>,\n output: DifferenceStreamWriter<T>\n ) {\n this.inputs = inputs\n this.output = output\n }\n\n abstract run(): void\n\n hasPendingWork(): boolean {\n return this.inputs.some((input) => !input.isEmpty())\n }\n}\n\n/**\n * A convenience implementation of a dataflow operator that has a handle to one\n * incoming stream of data, and one handle to an outgoing stream of data.\n */\nexport abstract class UnaryOperator<Tin, Tout = Tin> extends Operator<\n Tin | Tout\n> {\n constructor(\n public id: number,\n inputA: DifferenceStreamReader<Tin>,\n output: DifferenceStreamWriter<Tout>\n ) {\n super(id, [inputA], output)\n }\n\n inputMessages(): Array<MultiSet<Tin>> {\n return this.inputs[0]!.drain() as Array<MultiSet<Tin>>\n }\n}\n\n/**\n * A convenience implementation of a dataflow operator that has a handle to two\n * incoming streams of data, and one handle to an outgoing stream of data.\n */\nexport abstract class BinaryOperator<T> extends Operator<T> {\n constructor(\n public id: number,\n inputA: DifferenceStreamReader<T>,\n inputB: DifferenceStreamReader<T>,\n output: DifferenceStreamWriter<T>\n ) {\n super(id, [inputA, inputB], output)\n }\n\n inputAMessages(): Array<MultiSet<T>> {\n return this.inputs[0]!.drain()\n }\n\n inputBMessages(): Array<MultiSet<T>> {\n return this.inputs[1]!.drain()\n }\n}\n\n/**\n * Base class for operators that process a single input stream\n */\nexport abstract class LinearUnaryOperator<T, U> extends UnaryOperator<T | U> {\n abstract inner(collection: MultiSet<T | U>): MultiSet<U>\n\n run(): void {\n for (const message of this.inputMessages()) {\n this.output.sendData(this.inner(message))\n }\n }\n}\n"],"names":["MultiSet"],"mappings":";;;;;;;;;;;AAWO,MAAM,uBAAgE;AAAA,EAG3E,YAAY,OAA2B;AAFvC;AAGE,uBAAK,QAAS;AAAA,EAChB;AAAA,EAEA,QAA4B;AAC1B,UAAM,MAAM,CAAC,GAAG,mBAAK,OAAM,EAAE,QAAA;AAC7B,uBAAK,QAAO,SAAS;AACrB,WAAO;AAAA,EACT;AAAA,EAEA,UAAmB;AACjB,WAAO,mBAAK,QAAO,WAAW;AAAA,EAChC;AACF;AAfE;AAoBK,MAAM,uBAAgE;AAAA,EAAtE;AACL,gCAAqC,CAAA;AAAA;AAAA,EAErC,SAAS,YAAkD;AACzD,QAAI,EAAE,sBAAsBA,SAAAA,WAAW;AACrC,mBAAa,IAAIA,SAAAA,SAAS,UAAU;AAAA,IACtC;AAEA,eAAW,KAAK,mBAAK,UAAS;AAC5B,QAAE,QAAQ,UAAU;AAAA,IACtB;AAAA,EACF;AAAA,EAEA,YAAuC;AACrC,UAAM,IAAwB,CAAA;AAC9B,uBAAK,SAAQ,KAAK,CAAC;AACnB,WAAO,IAAI,uBAAuB,CAAC;AAAA,EACrC;AACF;AAjBE;AAuBK,MAAe,SAAoC;AAAA,EAIxD,YACS,IACP,QACA,QACA;AAHO,SAAA,KAAA;AAIP,SAAK,SAAS;AACd,SAAK,SAAS;AAAA,EAChB;AAAA,EAIA,iBAA0B;AACxB,WAAO,KAAK,OAAO,KAAK,CAAC,UAAU,CAAC,MAAM,SAAS;AAAA,EACrD;AACF;AAMO,MAAe,sBAAuC,SAE3D;AAAA,EACA,YACS,IACP,QACA,QACA;AACA,UAAM,IAAI,CAAC,MAAM,GAAG,MAAM;AAJnB,SAAA,KAAA;AAAA,EAKT;AAAA,EAEA,gBAAsC;AACpC,WAAO,KAAK,OAAO,CAAC,EAAG,MAAA;AAAA,EACzB;AACF;AAMO,MAAe,uBAA0B,SAAY;AAAA,EAC1D,YACS,IACP,QACA,QACA,QACA;AACA,UAAM,IAAI,CAAC,QAAQ,MAAM,GAAG,MAAM;AAL3B,SAAA,KAAA;AAAA,EAMT;AAAA,EAEA,iBAAqC;AACnC,WAAO,KAAK,OAAO,CAAC,EAAG,MAAA;AAAA,EACzB;AAAA,EAEA,iBAAqC;AACnC,WAAO,KAAK,OAAO,CAAC,EAAG,MAAA;AAAA,EACzB;AACF;AAKO,MAAe,4BAAkC,cAAqB;AAAA,EAG3E,MAAY;AACV,eAAW,WAAW,KAAK,iBAAiB;AAC1C,WAAK,OAAO,SAAS,KAAK,MAAM,OAAO,CAAC;AAAA,IAC1C;AAAA,EACF;AACF;;;;;;;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { MultiSet, MultiSetArray } from './multiset.js';
|
|
2
|
+
import { IDifferenceStreamReader, IDifferenceStreamWriter, IOperator } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* A read handle to a dataflow edge that receives data from a writer.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DifferenceStreamReader<T> implements IDifferenceStreamReader<T> {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(queue: Array<MultiSet<T>>);
|
|
9
|
+
drain(): Array<MultiSet<T>>;
|
|
10
|
+
isEmpty(): boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A write handle to a dataflow edge that is allowed to publish data.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DifferenceStreamWriter<T> implements IDifferenceStreamWriter<T> {
|
|
16
|
+
#private;
|
|
17
|
+
sendData(collection: MultiSet<T> | MultiSetArray<T>): void;
|
|
18
|
+
newReader(): DifferenceStreamReader<T>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A generic implementation of a dataflow operator (node) that has multiple incoming edges (read handles) and
|
|
22
|
+
* one outgoing edge (write handle).
|
|
23
|
+
*/
|
|
24
|
+
export declare abstract class Operator<T> implements IOperator<T> {
|
|
25
|
+
id: number;
|
|
26
|
+
protected inputs: Array<DifferenceStreamReader<T>>;
|
|
27
|
+
protected output: DifferenceStreamWriter<T>;
|
|
28
|
+
constructor(id: number, inputs: Array<DifferenceStreamReader<T>>, output: DifferenceStreamWriter<T>);
|
|
29
|
+
abstract run(): void;
|
|
30
|
+
hasPendingWork(): boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A convenience implementation of a dataflow operator that has a handle to one
|
|
34
|
+
* incoming stream of data, and one handle to an outgoing stream of data.
|
|
35
|
+
*/
|
|
36
|
+
export declare abstract class UnaryOperator<Tin, Tout = Tin> extends Operator<Tin | Tout> {
|
|
37
|
+
id: number;
|
|
38
|
+
constructor(id: number, inputA: DifferenceStreamReader<Tin>, output: DifferenceStreamWriter<Tout>);
|
|
39
|
+
inputMessages(): Array<MultiSet<Tin>>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A convenience implementation of a dataflow operator that has a handle to two
|
|
43
|
+
* incoming streams of data, and one handle to an outgoing stream of data.
|
|
44
|
+
*/
|
|
45
|
+
export declare abstract class BinaryOperator<T> extends Operator<T> {
|
|
46
|
+
id: number;
|
|
47
|
+
constructor(id: number, inputA: DifferenceStreamReader<T>, inputB: DifferenceStreamReader<T>, output: DifferenceStreamWriter<T>);
|
|
48
|
+
inputAMessages(): Array<MultiSet<T>>;
|
|
49
|
+
inputBMessages(): Array<MultiSet<T>>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Base class for operators that process a single input stream
|
|
53
|
+
*/
|
|
54
|
+
export declare abstract class LinearUnaryOperator<T, U> extends UnaryOperator<T | U> {
|
|
55
|
+
abstract inner(collection: MultiSet<T | U>): MultiSet<U>;
|
|
56
|
+
run(): void;
|
|
57
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const d2 = require("./d2.cjs");
|
|
4
|
+
const multiset = require("./multiset.cjs");
|
|
5
|
+
const groupBy = require("./operators/groupBy.cjs");
|
|
6
|
+
const pipe = require("./operators/pipe.cjs");
|
|
7
|
+
const map = require("./operators/map.cjs");
|
|
8
|
+
const filter = require("./operators/filter.cjs");
|
|
9
|
+
const negate = require("./operators/negate.cjs");
|
|
10
|
+
const concat = require("./operators/concat.cjs");
|
|
11
|
+
const debug = require("./operators/debug.cjs");
|
|
12
|
+
const output = require("./operators/output.cjs");
|
|
13
|
+
const consolidate = require("./operators/consolidate.cjs");
|
|
14
|
+
const join = require("./operators/join.cjs");
|
|
15
|
+
const reduce = require("./operators/reduce.cjs");
|
|
16
|
+
const count = require("./operators/count.cjs");
|
|
17
|
+
const distinct = require("./operators/distinct.cjs");
|
|
18
|
+
const keying = require("./operators/keying.cjs");
|
|
19
|
+
const topK = require("./operators/topK.cjs");
|
|
20
|
+
const topKWithFractionalIndex = require("./operators/topKWithFractionalIndex.cjs");
|
|
21
|
+
const orderBy = require("./operators/orderBy.cjs");
|
|
22
|
+
const filterBy = require("./operators/filterBy.cjs");
|
|
23
|
+
exports.D2 = d2.D2;
|
|
24
|
+
exports.RootStreamBuilder = d2.RootStreamBuilder;
|
|
25
|
+
exports.StreamBuilder = d2.StreamBuilder;
|
|
26
|
+
exports.MultiSet = multiset.MultiSet;
|
|
27
|
+
exports.groupBy = groupBy.groupBy;
|
|
28
|
+
exports.groupByOperators = groupBy.groupByOperators;
|
|
29
|
+
exports.pipe = pipe.pipe;
|
|
30
|
+
exports.MapOperator = map.MapOperator;
|
|
31
|
+
exports.map = map.map;
|
|
32
|
+
exports.FilterOperator = filter.FilterOperator;
|
|
33
|
+
exports.filter = filter.filter;
|
|
34
|
+
exports.NegateOperator = negate.NegateOperator;
|
|
35
|
+
exports.negate = negate.negate;
|
|
36
|
+
exports.ConcatOperator = concat.ConcatOperator;
|
|
37
|
+
exports.concat = concat.concat;
|
|
38
|
+
exports.DebugOperator = debug.DebugOperator;
|
|
39
|
+
exports.debug = debug.debug;
|
|
40
|
+
exports.OutputOperator = output.OutputOperator;
|
|
41
|
+
exports.output = output.output;
|
|
42
|
+
exports.ConsolidateOperator = consolidate.ConsolidateOperator;
|
|
43
|
+
exports.consolidate = consolidate.consolidate;
|
|
44
|
+
exports.JoinOperator = join.JoinOperator;
|
|
45
|
+
exports.antiJoin = join.antiJoin;
|
|
46
|
+
exports.fullJoin = join.fullJoin;
|
|
47
|
+
exports.innerJoin = join.innerJoin;
|
|
48
|
+
exports.join = join.join;
|
|
49
|
+
exports.leftJoin = join.leftJoin;
|
|
50
|
+
exports.rightJoin = join.rightJoin;
|
|
51
|
+
exports.ReduceOperator = reduce.ReduceOperator;
|
|
52
|
+
exports.reduce = reduce.reduce;
|
|
53
|
+
exports.CountOperator = count.CountOperator;
|
|
54
|
+
exports.count = count.count;
|
|
55
|
+
exports.DistinctOperator = distinct.DistinctOperator;
|
|
56
|
+
exports.distinct = distinct.distinct;
|
|
57
|
+
exports.keyBy = keying.keyBy;
|
|
58
|
+
exports.rekey = keying.rekey;
|
|
59
|
+
exports.unkey = keying.unkey;
|
|
60
|
+
exports.topK = topK.topK;
|
|
61
|
+
exports.topKWithIndex = topK.topKWithIndex;
|
|
62
|
+
exports.TopKWithFractionalIndexOperator = topKWithFractionalIndex.TopKWithFractionalIndexOperator;
|
|
63
|
+
exports.getIndex = topKWithFractionalIndex.getIndex;
|
|
64
|
+
exports.getValue = topKWithFractionalIndex.getValue;
|
|
65
|
+
exports.indexedValue = topKWithFractionalIndex.indexedValue;
|
|
66
|
+
exports.topKWithFractionalIndex = topKWithFractionalIndex.topKWithFractionalIndex;
|
|
67
|
+
exports.orderBy = orderBy.orderBy;
|
|
68
|
+
exports.orderByWithFractionalIndex = orderBy.orderByWithFractionalIndex;
|
|
69
|
+
exports.orderByWithFractionalIndexBase = orderBy.orderByWithFractionalIndexBase;
|
|
70
|
+
exports.orderByWithIndex = orderBy.orderByWithIndex;
|
|
71
|
+
exports.filterBy = filterBy.filterBy;
|
|
72
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
6
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
7
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
8
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
9
|
+
var _inner;
|
|
10
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
const multiset = require("./multiset.cjs");
|
|
12
|
+
const utils = require("./utils.cjs");
|
|
13
|
+
class Index {
|
|
14
|
+
constructor() {
|
|
15
|
+
__privateAdd(this, _inner);
|
|
16
|
+
__privateSet(this, _inner, new utils.DefaultMap(() => /* @__PURE__ */ new Map()));
|
|
17
|
+
}
|
|
18
|
+
toString(indent = false) {
|
|
19
|
+
return `Index(${JSON.stringify(
|
|
20
|
+
[...__privateGet(this, _inner)].map(([k, valueMap]) => [k, [...valueMap]]),
|
|
21
|
+
void 0,
|
|
22
|
+
indent ? ` ` : void 0
|
|
23
|
+
)})`;
|
|
24
|
+
}
|
|
25
|
+
get(key) {
|
|
26
|
+
const valueMap = __privateGet(this, _inner).get(key);
|
|
27
|
+
return [...valueMap.entries()];
|
|
28
|
+
}
|
|
29
|
+
getMultiplicity(key, value) {
|
|
30
|
+
const valueMap = __privateGet(this, _inner).get(key);
|
|
31
|
+
return valueMap.get(value) ?? 0;
|
|
32
|
+
}
|
|
33
|
+
entries() {
|
|
34
|
+
return __privateGet(this, _inner).entries();
|
|
35
|
+
}
|
|
36
|
+
keys() {
|
|
37
|
+
return __privateGet(this, _inner).keys();
|
|
38
|
+
}
|
|
39
|
+
has(key) {
|
|
40
|
+
return __privateGet(this, _inner).has(key);
|
|
41
|
+
}
|
|
42
|
+
get size() {
|
|
43
|
+
return __privateGet(this, _inner).size;
|
|
44
|
+
}
|
|
45
|
+
addValue(key, value) {
|
|
46
|
+
const [val, multiplicity] = value;
|
|
47
|
+
const valueMap = __privateGet(this, _inner).get(key);
|
|
48
|
+
const existingMultiplicity = valueMap.get(val) ?? 0;
|
|
49
|
+
const newMultiplicity = existingMultiplicity + multiplicity;
|
|
50
|
+
if (multiplicity !== 0) {
|
|
51
|
+
if (newMultiplicity === 0) {
|
|
52
|
+
valueMap.delete(val);
|
|
53
|
+
} else {
|
|
54
|
+
valueMap.set(val, newMultiplicity);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
append(other) {
|
|
59
|
+
for (const [key, otherValueMap] of other.entries()) {
|
|
60
|
+
const thisValueMap = __privateGet(this, _inner).get(key);
|
|
61
|
+
for (const [value, multiplicity] of otherValueMap.entries()) {
|
|
62
|
+
const existingMultiplicity = thisValueMap.get(value) ?? 0;
|
|
63
|
+
const newMultiplicity = existingMultiplicity + multiplicity;
|
|
64
|
+
if (newMultiplicity === 0) {
|
|
65
|
+
thisValueMap.delete(value);
|
|
66
|
+
} else {
|
|
67
|
+
thisValueMap.set(value, newMultiplicity);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
join(other) {
|
|
73
|
+
const result = [];
|
|
74
|
+
if (this.size <= other.size) {
|
|
75
|
+
for (const [key, valueMap] of this.entries()) {
|
|
76
|
+
if (!other.has(key)) continue;
|
|
77
|
+
const otherValues = other.get(key);
|
|
78
|
+
for (const [val1, mul1] of valueMap.entries()) {
|
|
79
|
+
for (const [val2, mul2] of otherValues) {
|
|
80
|
+
if (mul1 !== 0 && mul2 !== 0) {
|
|
81
|
+
result.push([[key, [val1, val2]], mul1 * mul2]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
for (const [key, otherValueMap] of other.entries()) {
|
|
88
|
+
if (!this.has(key)) continue;
|
|
89
|
+
const values = this.get(key);
|
|
90
|
+
for (const [val2, mul2] of otherValueMap.entries()) {
|
|
91
|
+
for (const [val1, mul1] of values) {
|
|
92
|
+
if (mul1 !== 0 && mul2 !== 0) {
|
|
93
|
+
result.push([[key, [val1, val2]], mul1 * mul2]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return new multiset.MultiSet(result);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
_inner = new WeakMap();
|
|
103
|
+
exports.Index = Index;
|
|
104
|
+
//# sourceMappingURL=indexes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexes.cjs","sources":["../../src/indexes.ts"],"sourcesContent":["import { MultiSet } from \"./multiset.js\"\nimport { DefaultMap } from \"./utils.js\"\n\n/**\n * A map from a difference collection trace's keys -> (value, multiplicities) that changed.\n * Used in operations like join and reduce where the operation needs to\n * exploit the key-value structure of the data to run efficiently.\n */\nexport class Index<K, V> {\n #inner: DefaultMap<K, Map<V, number>>\n\n constructor() {\n this.#inner = new DefaultMap<K, Map<V, number>>(() => new Map<V, number>())\n // #inner is a map of:\n // {\n // [key]: Map<V, number> // Direct value-to-multiplicity mapping\n // }\n }\n\n toString(indent = false): string {\n return `Index(${JSON.stringify(\n [...this.#inner].map(([k, valueMap]) => [k, [...valueMap]]),\n undefined,\n indent ? ` ` : undefined\n )})`\n }\n\n get(key: K): Array<[V, number]> {\n const valueMap = this.#inner.get(key)\n return [...valueMap.entries()]\n }\n\n getMultiplicity(key: K, value: V): number {\n const valueMap = this.#inner.get(key)\n return valueMap.get(value) ?? 0\n }\n\n entries() {\n return this.#inner.entries()\n }\n\n keys() {\n return this.#inner.keys()\n }\n\n has(key: K): boolean {\n return this.#inner.has(key)\n }\n\n get size(): number {\n return this.#inner.size\n }\n\n addValue(key: K, value: [V, number]): void {\n const [val, multiplicity] = value\n const valueMap = this.#inner.get(key)\n const existingMultiplicity = valueMap.get(val) ?? 0\n const newMultiplicity = existingMultiplicity + multiplicity\n\n if (multiplicity !== 0) {\n if (newMultiplicity === 0) {\n valueMap.delete(val)\n } else {\n valueMap.set(val, newMultiplicity)\n }\n }\n }\n\n append(other: Index<K, V>): void {\n for (const [key, otherValueMap] of other.entries()) {\n const thisValueMap = this.#inner.get(key)\n for (const [value, multiplicity] of otherValueMap.entries()) {\n const existingMultiplicity = thisValueMap.get(value) ?? 0\n const newMultiplicity = existingMultiplicity + multiplicity\n if (newMultiplicity === 0) {\n thisValueMap.delete(value)\n } else {\n thisValueMap.set(value, newMultiplicity)\n }\n }\n }\n }\n\n join<V2>(other: Index<K, V2>): MultiSet<[K, [V, V2]]> {\n const result: Array<[[K, [V, V2]], number]> = []\n\n // We want to iterate over the smaller of the two indexes to reduce the\n // number of operations we need to do.\n if (this.size <= other.size) {\n for (const [key, valueMap] of this.entries()) {\n if (!other.has(key)) continue\n const otherValues = other.get(key)\n for (const [val1, mul1] of valueMap.entries()) {\n for (const [val2, mul2] of otherValues) {\n if (mul1 !== 0 && mul2 !== 0) {\n result.push([[key, [val1, val2]], mul1 * mul2])\n }\n }\n }\n }\n } else {\n for (const [key, otherValueMap] of other.entries()) {\n if (!this.has(key)) continue\n const values = this.get(key)\n for (const [val2, mul2] of otherValueMap.entries()) {\n for (const [val1, mul1] of values) {\n if (mul1 !== 0 && mul2 !== 0) {\n result.push([[key, [val1, val2]], mul1 * mul2])\n }\n }\n }\n }\n }\n\n return new MultiSet(result)\n }\n}\n"],"names":["DefaultMap","MultiSet"],"mappings":";;;;;;;;;;;;AAQO,MAAM,MAAY;AAAA,EAGvB,cAAc;AAFd;AAGE,uBAAK,QAAS,IAAIA,MAAAA,WAA8B,MAAM,oBAAI,KAAgB;AAAA,EAK5E;AAAA,EAEA,SAAS,SAAS,OAAe;AAC/B,WAAO,SAAS,KAAK;AAAA,MACnB,CAAC,GAAG,mBAAK,OAAM,EAAE,IAAI,CAAC,CAAC,GAAG,QAAQ,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;AAAA,MAC1D;AAAA,MACA,SAAS,OAAO;AAAA,IAAA,CACjB;AAAA,EACH;AAAA,EAEA,IAAI,KAA4B;AAC9B,UAAM,WAAW,mBAAK,QAAO,IAAI,GAAG;AACpC,WAAO,CAAC,GAAG,SAAS,SAAS;AAAA,EAC/B;AAAA,EAEA,gBAAgB,KAAQ,OAAkB;AACxC,UAAM,WAAW,mBAAK,QAAO,IAAI,GAAG;AACpC,WAAO,SAAS,IAAI,KAAK,KAAK;AAAA,EAChC;AAAA,EAEA,UAAU;AACR,WAAO,mBAAK,QAAO,QAAA;AAAA,EACrB;AAAA,EAEA,OAAO;AACL,WAAO,mBAAK,QAAO,KAAA;AAAA,EACrB;AAAA,EAEA,IAAI,KAAiB;AACnB,WAAO,mBAAK,QAAO,IAAI,GAAG;AAAA,EAC5B;AAAA,EAEA,IAAI,OAAe;AACjB,WAAO,mBAAK,QAAO;AAAA,EACrB;AAAA,EAEA,SAAS,KAAQ,OAA0B;AACzC,UAAM,CAAC,KAAK,YAAY,IAAI;AAC5B,UAAM,WAAW,mBAAK,QAAO,IAAI,GAAG;AACpC,UAAM,uBAAuB,SAAS,IAAI,GAAG,KAAK;AAClD,UAAM,kBAAkB,uBAAuB;AAE/C,QAAI,iBAAiB,GAAG;AACtB,UAAI,oBAAoB,GAAG;AACzB,iBAAS,OAAO,GAAG;AAAA,MACrB,OAAO;AACL,iBAAS,IAAI,KAAK,eAAe;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAO,OAA0B;AAC/B,eAAW,CAAC,KAAK,aAAa,KAAK,MAAM,WAAW;AAClD,YAAM,eAAe,mBAAK,QAAO,IAAI,GAAG;AACxC,iBAAW,CAAC,OAAO,YAAY,KAAK,cAAc,WAAW;AAC3D,cAAM,uBAAuB,aAAa,IAAI,KAAK,KAAK;AACxD,cAAM,kBAAkB,uBAAuB;AAC/C,YAAI,oBAAoB,GAAG;AACzB,uBAAa,OAAO,KAAK;AAAA,QAC3B,OAAO;AACL,uBAAa,IAAI,OAAO,eAAe;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,KAAS,OAA6C;AACpD,UAAM,SAAwC,CAAA;AAI9C,QAAI,KAAK,QAAQ,MAAM,MAAM;AAC3B,iBAAW,CAAC,KAAK,QAAQ,KAAK,KAAK,WAAW;AAC5C,YAAI,CAAC,MAAM,IAAI,GAAG,EAAG;AACrB,cAAM,cAAc,MAAM,IAAI,GAAG;AACjC,mBAAW,CAAC,MAAM,IAAI,KAAK,SAAS,WAAW;AAC7C,qBAAW,CAAC,MAAM,IAAI,KAAK,aAAa;AACtC,gBAAI,SAAS,KAAK,SAAS,GAAG;AAC5B,qBAAO,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,OAAO,IAAI,CAAC;AAAA,YAChD;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,OAAO;AACL,iBAAW,CAAC,KAAK,aAAa,KAAK,MAAM,WAAW;AAClD,YAAI,CAAC,KAAK,IAAI,GAAG,EAAG;AACpB,cAAM,SAAS,KAAK,IAAI,GAAG;AAC3B,mBAAW,CAAC,MAAM,IAAI,KAAK,cAAc,WAAW;AAClD,qBAAW,CAAC,MAAM,IAAI,KAAK,QAAQ;AACjC,gBAAI,SAAS,KAAK,SAAS,GAAG;AAC5B,qBAAO,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,OAAO,IAAI,CAAC;AAAA,YAChD;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,WAAO,IAAIC,SAAAA,SAAS,MAAM;AAAA,EAC5B;AACF;AA3GE;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MultiSet } from './multiset.js';
|
|
2
|
+
/**
|
|
3
|
+
* A map from a difference collection trace's keys -> (value, multiplicities) that changed.
|
|
4
|
+
* Used in operations like join and reduce where the operation needs to
|
|
5
|
+
* exploit the key-value structure of the data to run efficiently.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Index<K, V> {
|
|
8
|
+
#private;
|
|
9
|
+
constructor();
|
|
10
|
+
toString(indent?: boolean): string;
|
|
11
|
+
get(key: K): Array<[V, number]>;
|
|
12
|
+
getMultiplicity(key: K, value: V): number;
|
|
13
|
+
entries(): MapIterator<[K, Map<V, number>]>;
|
|
14
|
+
keys(): MapIterator<K>;
|
|
15
|
+
has(key: K): boolean;
|
|
16
|
+
get size(): number;
|
|
17
|
+
addValue(key: K, value: [V, number]): void;
|
|
18
|
+
append(other: Index<K, V>): void;
|
|
19
|
+
join<V2>(other: Index<K, V2>): MultiSet<[K, [V, V2]]>;
|
|
20
|
+
}
|