-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add an inner join operator * flatten results of previous joins * named arguments for `JoinOperator` * remove goofy string 'undefined' * fix type errors * fixup binary operator to account for new interface without reader and writers * add `join` to `DifferenceStream` * only compact keys seen in the difference * remove `pending` from `join` * fix tests to correctly reset expected items * difference index tests * remove unused test case * fix type errors from incorrect git merge * address review comments * send many rows at the same version * stable ids, do smallest collection in the outer loop
- Loading branch information
Showing
21 changed files
with
1,310 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import {Multiset} from '../../multiset.js'; | ||
import {Version} from '../../types.js'; | ||
import {DifferenceStream, Listener} from '../difference-stream.js'; | ||
import {Request} from '../message.js'; | ||
import {OperatorBase} from './operator.js'; | ||
|
||
export class BinaryOperator< | ||
I1 extends object, | ||
I2 extends object, | ||
O extends object, | ||
> extends OperatorBase<O> { | ||
readonly #listener1: Listener<I1>; | ||
readonly #input1: DifferenceStream<I1>; | ||
readonly #listener2: Listener<I2>; | ||
readonly #input2: DifferenceStream<I2>; | ||
|
||
constructor( | ||
input1: DifferenceStream<I1>, | ||
input2: DifferenceStream<I2>, | ||
output: DifferenceStream<O>, | ||
fn: ( | ||
v: Version, | ||
inputA: Multiset<I1> | undefined, | ||
inputB: Multiset<I2> | undefined, | ||
) => Multiset<O>, | ||
) { | ||
super(output); | ||
this.#listener1 = { | ||
newDifference: (version, data) => { | ||
output.newDifference(version, fn(version, data, undefined)); | ||
}, | ||
commit: version => { | ||
this.commit(version); | ||
}, | ||
}; | ||
this.#listener2 = { | ||
newDifference: (version, data) => { | ||
output.newDifference(version, fn(version, undefined, data)); | ||
}, | ||
commit: version => { | ||
this.commit(version); | ||
}, | ||
}; | ||
input1.addDownstream(this.#listener1); | ||
input2.addDownstream(this.#listener2); | ||
this.#input1 = input1; | ||
this.#input2 = input2; | ||
} | ||
|
||
messageUpstream(message: Request): void { | ||
this.#input1.messageUpstream(message, this.#listener1); | ||
this.#input2.messageUpstream(message, this.#listener2); | ||
} | ||
|
||
destroy() { | ||
this.#input1.removeDownstream(this.#listener1); | ||
this.#input2.removeDownstream(this.#listener2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.