deno.land / x / pg_mem@2.8.1 / schema / table-index.ts

table-index.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { _IIndex, IValue, _ITable, _IDb, _Transaction, _Explainer, _IndexExplanation, IndexOp, IndexKey, Stats } from '../interfaces-private.ts';import { PermissionDeniedError, NotSupported } from '../interfaces.ts';
export class TableIndex implements _IIndex { readonly expressions: IValue<any>[];
get hash(): string { throw new Error('not implemented'); } explain(e: _Explainer): _IndexExplanation { throw new Error('not implemented'); }
stats(t: _Transaction, key?: IndexKey): Stats | null { return null; }
iterateKeys() { return null; }
constructor(readonly onTable: _ITable & { itemsByTable(table: string, t: _Transaction): Iterable<any>; ownSymbol: any }, private col: IValue) { this.expressions = [col]; }
get indexName(): string { return 'index_table_name_name'; }
entropy(op: IndexOp): number { return this.onTable.db.listSchemas() .reduce((tot, s) => tot + s.tablesCount(op.t) * 10 * 3, 0); }

add(raw: any): void { throw new PermissionDeniedError('tables'); }
eqFirst([key]: any, t: _Transaction) { for (const its of this.onTable.itemsByTable(key, t)) { return its; } } *eq([rawKey]: any, t: _Transaction): Iterable<any> { for (const its of this.onTable.itemsByTable(rawKey, t)) { yield its; } }
*nin(keys: any[][], t: _Transaction) { const raws = keys.map(x => x[0]) as any[]; for (const i of this.onTable.selection.enumerate(t)) { if (raws.includes(i.table_name)) { continue; } yield i; } }
*neq([rawKey]: any, t: _Transaction) { for (const i of this.onTable.selection.enumerate(t)) { if (i.table_name !== rawKey) { yield i; } } } *gt(rawKey: any, t: _Transaction): Iterable<any> { for (const i of this.onTable.selection.enumerate(t)) { if (i.table_name > rawKey) { yield i; } } } *lt(rawKey: any, t: _Transaction): Iterable<any> { for (const i of this.onTable.selection.enumerate(t)) { if (i.table_name < rawKey) { yield i; } } } *ge(rawKey: any, t: _Transaction): Iterable<any> { for (const i of this.onTable.selection.enumerate(t)) { if (i.table_name >= rawKey) { yield i; } } } *le(rawKey: any, t: _Transaction): Iterable<any> { for (const i of this.onTable.selection.enumerate(t)) { if (i.table_name <= rawKey) { yield i; } } }

enumerate(op: IndexOp): Iterable<any> { switch (op.type) { case 'eq': return this.eq(op.key, op.t); case 'neq': return this.neq(op.key, op.t); case 'ge': return this.ge(op.key, op.t); case 'le': return this.le(op.key, op.t); case 'gt': return this.gt(op.key, op.t); case 'lt': return this.lt(op.key, op.t); case 'outside': return this.outside(op.lo, op.hi, op.t); case 'inside': return this.inside(op.lo, op.hi, op.t); case 'nin': return this.nin(op.keys, op.t); default: throw NotSupported.never(op['type']); } }
*outside(lo: IndexKey, hi: IndexKey, t: _Transaction): Iterable<any> { yield* this.lt(lo, t); yield* this.gt(hi, t); }
*inside(lo: IndexKey, hi: IndexKey, t: _Transaction): Iterable<any> { throw new Error('Not implemented'); }}
pg_mem

Version Info

Tagged at
4 months ago