deno.land / x / pg_mem@2.8.1 / transforms / or-filter.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { _ISelection, _IIndex, _ITable, getId, _Transaction, _Explainer, _SelectExplanation, Stats } from '../interfaces-private.ts';import { FilterBase } from './transform-base.ts';

export class OrFilter<T = any> extends FilterBase<T> {
entropy(t: _Transaction) { return this.left.entropy(t) + this.right.entropy(t); }
hasItem(value: T, t: _Transaction): boolean { return this.left.hasItem(value, t) || this.right.hasItem(value, t); }
constructor(private left: _ISelection<T>, private right: _ISelection<T>) { super(left); if (left.columns !== right.columns) { // istanbul ignore next throw new Error('Column set mismatch'); } }
stats(t: _Transaction): Stats | null { return null; }
*enumerate(t: _Transaction): Iterable<T> { const yielded = new Set<string>(); for (const item of this.left.enumerate(t)) { yield item; yielded.add(getId(item)); } for (const item of this.right.enumerate(t)) { const id = getId(item); if (!yielded.has(id)) { yield item; } } }


explain(e: _Explainer): _SelectExplanation { return { id: e.idFor(this), _: 'union', union: [ this.left.explain(e), this.right.explain(e), ], }; }}
pg_mem

Version Info

Tagged at
4 months ago