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

ineq-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
53
54
55
56
57
58
import { _ISelection, IValue, _IIndex, _ITable, _Transaction, _Explainer, _SelectExplanation, IndexOp, Stats } from '../interfaces-private.ts';import { FilterBase } from './transform-base.ts';import { nullIsh } from '../utils.ts';
export class IneqFilter<T = any> extends FilterBase<T> {
private index: _IIndex; private opDef: IndexOp;
entropy(t: _Transaction) { return this.onValue.index!.entropy({ ...this.opDef, t }); }
hasItem(item: T, t: _Transaction) { const val = this.onValue.get(item, t); if (nullIsh(val)) { return false; } return !!this.onValue.type[this.op](val, this.than); }
constructor(private onValue: IValue<T> , private op: 'gt' | 'ge' | 'lt' | 'le' , private than: any) { super(onValue.origin!);
this.index = this.onValue.index!; this.opDef = { type: op, key: [than], t: null as any, } }

stats(t: _Transaction): Stats | null { return null; }
*enumerate(t: _Transaction): Iterable<T> { for (const item of this.index.enumerate({ ...this.opDef, t })) { if (!this.hasItem(item, t)) { break; } yield item; } }

explain(e: _Explainer): _SelectExplanation { return { id: e.idFor(this), _: 'ineq', entropy: this.entropy(e.transaction), on: this.onValue.index!.explain(e), }; }}
pg_mem

Version Info

Tagged at
4 months ago