@bjornpagen/bumbledb 0.10.0 → 0.12.0
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/COOKBOOK.md +155 -136
- package/README.md +5 -9
- package/dist/db.d.ts +77 -109
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +121 -339
- package/dist/db.js.map +1 -1
- package/dist/index.d.ts +12 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -11
- package/dist/index.js.map +1 -1
- package/dist/lower.d.ts.map +1 -1
- package/dist/lower.js +8 -1
- package/dist/lower.js.map +1 -1
- package/dist/native.d.ts +77 -51
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/query/atom.d.ts +94 -112
- package/dist/query/atom.d.ts.map +1 -1
- package/dist/query/atom.js +8 -17
- package/dist/query/atom.js.map +1 -1
- package/dist/query/find.d.ts +18 -35
- package/dist/query/find.d.ts.map +1 -1
- package/dist/query/find.js +13 -32
- package/dist/query/find.js.map +1 -1
- package/dist/query/lower.d.ts +128 -124
- package/dist/query/lower.d.ts.map +1 -1
- package/dist/query/lower.js +366 -258
- package/dist/query/lower.js.map +1 -1
- package/dist/query/parse-ir.d.ts +12 -0
- package/dist/query/parse-ir.d.ts.map +1 -0
- package/dist/query/parse-ir.js +71 -0
- package/dist/query/parse-ir.js.map +1 -0
- package/dist/query/run.d.ts +2 -2
- package/dist/query/run.d.ts.map +1 -1
- package/dist/query/run.js +2 -13
- package/dist/query/run.js.map +1 -1
- package/dist/query/scope.d.ts +4 -16
- package/dist/query/scope.d.ts.map +1 -1
- package/dist/query/scope.js +1 -6
- package/dist/query/scope.js.map +1 -1
- package/dist/schema.js +2 -2
- package/dist/schema.js.map +1 -1
- package/dist/statements.d.ts +8 -4
- package/dist/statements.d.ts.map +1 -1
- package/dist/statements.js +7 -9
- package/dist/statements.js.map +1 -1
- package/package.json +2 -2
- package/src/db.ts +182 -443
- package/src/index.ts +11 -24
- package/src/lower.ts +8 -1
- package/src/native.ts +79 -43
- package/src/query/atom.ts +105 -138
- package/src/query/find.ts +39 -80
- package/src/query/lower.ts +626 -434
- package/src/query/parse-ir.ts +82 -0
- package/src/query/run.ts +2 -14
- package/src/query/scope.ts +3 -21
- package/src/schema.ts +2 -2
- package/src/statements.ts +17 -13
- package/dist/order.d.ts +0 -87
- package/dist/order.d.ts.map +0 -1
- package/dist/order.js +0 -153
- package/dist/order.js.map +0 -1
- package/dist/query/predicate.d.ts +0 -91
- package/dist/query/predicate.d.ts.map +0 -1
- package/dist/query/predicate.js +0 -156
- package/dist/query/predicate.js.map +0 -1
- package/src/order.ts +0 -234
- package/src/query/predicate.ts +0 -269
package/dist/query/find.d.ts
CHANGED
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* vocabulary, mirroring the IR's aggregate roster exactly
|
|
4
4
|
* (`bumbledb/crates/bumbledb/src/ir.rs` `AggOp`/`FindTerm`;
|
|
5
5
|
* `docs/architecture/20-query-ir.md` § aggregation): `count` (nullary),
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `r.sum(w)` — and are typed by the variable's own descriptor.
|
|
6
|
+
* `sum`/`min`/`max` (over an orderable variable or the measure), and
|
|
7
|
+
* `pack` (the coalescing fold — RELATION-SHAPED, the result position
|
|
8
|
+
* interval-typed). Aggregates fold VARIABLES by reference — `r.sum(w)` —
|
|
9
|
+
* and are typed by the variable's own descriptor.
|
|
11
10
|
*
|
|
12
11
|
* `select(strings)` is DEAD: the head is a `find` RECORD, whose KEYS name
|
|
13
12
|
* the answer columns (`find({ total: r.count(), owner: h })`). The keys are
|
|
@@ -23,27 +22,23 @@ import type { SchemaClasses } from "#law.ts";
|
|
|
23
22
|
import type { IntervalVarOk, NumericVarOk, OrderVarOk } from "#query/atom.ts";
|
|
24
23
|
import type { AnyVar, Duration, MintSlotOf } from "#query/scope.ts";
|
|
25
24
|
/** One aggregate operator name of the find vocabulary. */
|
|
26
|
-
type AggOpName = "count" | "
|
|
25
|
+
type AggOpName = "count" | "sum" | "min" | "max" | "pack";
|
|
27
26
|
/**
|
|
28
|
-
* One aggregate find VALUE: the op
|
|
29
|
-
* REFERENCE
|
|
30
|
-
* variable's own descriptor types the result.
|
|
27
|
+
* One aggregate find VALUE: the op and the variable (or measure) it folds
|
|
28
|
+
* BY REFERENCE. The variable's own descriptor types the result.
|
|
31
29
|
*/
|
|
32
|
-
interface Agg<Op extends AggOpName, Over extends AnyVar | Duration | undefined
|
|
30
|
+
interface Agg<Op extends AggOpName, Over extends AnyVar | Duration | undefined> {
|
|
33
31
|
readonly agg: Op;
|
|
34
32
|
readonly over: Over;
|
|
35
|
-
readonly key: Key;
|
|
36
33
|
}
|
|
37
34
|
/** Any aggregate find value. */
|
|
38
|
-
type AnyAgg = Agg<AggOpName, AnyVar | Duration | undefined
|
|
35
|
+
type AnyAgg = Agg<AggOpName, AnyVar | Duration | undefined>;
|
|
39
36
|
/** One find entry: a projected variable, the measure, or an aggregate. */
|
|
40
37
|
type FindEntry = AnyVar | Duration | AnyAgg;
|
|
41
38
|
/** The `find` record: column name → find entry. Keys ARE the answer columns. */
|
|
42
39
|
type FindShape = Readonly<Record<string, FindEntry>>;
|
|
43
40
|
/** Nullary count: |the group's set of distinct full bindings|, `bigint`. */
|
|
44
41
|
declare function count(): Agg<"count", undefined>;
|
|
45
|
-
/** |the distinct values of the variable across the group|, `bigint`; legal over every type. */
|
|
46
|
-
declare function countDistinct<const V extends AnyVar>(over: V): Agg<"countDistinct", V>;
|
|
47
42
|
/**
|
|
48
43
|
* Exact checked sum over a NUMERIC (u64/i64) variable — wide accumulator,
|
|
49
44
|
* one finalize range check; overflow is the engine's typed runtime error —
|
|
@@ -55,22 +50,12 @@ declare function sum<const O extends AnyVar | Duration>(over: O): Agg<"sum", O>;
|
|
|
55
50
|
declare function min<const O extends AnyVar | Duration>(over: O): Agg<"min", O>;
|
|
56
51
|
/** Maximum over an orderable variable (u64/i64/bool — over bool, `Max` is the ANY quantifier; R3) or the measure. */
|
|
57
52
|
declare function max<const O extends AnyVar | Duration>(over: O): Agg<"max", O>;
|
|
58
|
-
/**
|
|
59
|
-
* Arg-restriction toward the maximum of `key` (`ir::AggOp::ArgMax`): the
|
|
60
|
-
* group's binding set is restricted to the bindings attaining the extreme
|
|
61
|
-
* of the orderable key, and `value` is the carried payload — a tie yields
|
|
62
|
-
* every attaining row. All Arg entries of one query share one key and one
|
|
63
|
-
* direction; Arg and fold aggregates never mix (both the engine's rules).
|
|
64
|
-
*/
|
|
65
|
-
declare function argMax<const V extends AnyVar, const K extends AnyVar>(value: V, key: K): Agg<"argMax", V, K>;
|
|
66
|
-
/** Arg-restriction toward the minimum of `key`; rules as {@link argMax}. */
|
|
67
|
-
declare function argMin<const V extends AnyVar, const K extends AnyVar>(value: V, key: K): Agg<"argMin", V, K>;
|
|
68
53
|
/**
|
|
69
54
|
* The coalescing fold (Snodgrass coalesce, `ir::AggOp::Pack`): per group,
|
|
70
55
|
* the maximal disjoint half-open segments of the union of the group's
|
|
71
56
|
* interval point sets — RELATION-SHAPED, one answer row per (group, maximal
|
|
72
57
|
* segment), the result position carrying one interval of the input's element
|
|
73
|
-
* type. At most one `pack` per find, never beside a fold
|
|
58
|
+
* type. At most one `pack` per find, never beside a fold entry.
|
|
74
59
|
*/
|
|
75
60
|
declare function pack<const V extends AnyVar>(over: V): Agg<"pack", V>;
|
|
76
61
|
/**
|
|
@@ -88,28 +73,26 @@ type FoldOverOk<O> = O extends AnyVar ? OrderVarOk<O> : O extends Duration<infer
|
|
|
88
73
|
/**
|
|
89
74
|
* One find entry's judgment (off the entry's own descriptor — no env, no
|
|
90
75
|
* class map needed): a projected variable is ok, the measure and `pack`
|
|
91
|
-
* demand interval-typed variables, folds
|
|
76
|
+
* demand interval-typed variables, folds demand orderable ones.
|
|
92
77
|
*/
|
|
93
|
-
type FindEntryOk<E> = E extends AnyVar ? true : E extends Duration<infer V extends AnyVar> ? IntervalVarOk<V> : E extends Agg<"count", undefined> ? true : E extends Agg<"
|
|
78
|
+
type FindEntryOk<E> = E extends AnyVar ? true : E extends Duration<infer V extends AnyVar> ? IntervalVarOk<V> : E extends Agg<"count", undefined> ? true : E extends Agg<"sum", infer O> ? SumOverOk<O> : E extends Agg<"min" | "max", infer O> ? FoldOverOk<O> : E extends Agg<"pack", infer V extends AnyVar> ? IntervalVarOk<V> : false;
|
|
94
79
|
/** The validated find record (intersect with the inferred entries — errors land on the offending key). */
|
|
95
80
|
type CheckFind<F extends FindShape> = {
|
|
96
81
|
readonly [K in keyof F]: FindEntryOk<F[K]> extends true ? F[K] : never;
|
|
97
82
|
};
|
|
98
83
|
/**
|
|
99
84
|
* The validated find record of a RECURSIVE rule: every entry must be a plain
|
|
100
|
-
* variable (aggregates and the measure are unwritable in a
|
|
101
|
-
* the strata quarantine).
|
|
85
|
+
* variable (aggregates and the measure are unwritable in a rec head).
|
|
102
86
|
*/
|
|
103
87
|
type CheckRecFind<F extends FindShape> = {
|
|
104
88
|
readonly [K in keyof F]: F[K] extends AnyVar ? F[K] : never;
|
|
105
89
|
};
|
|
106
90
|
/**
|
|
107
91
|
* One find entry's answer-column value type: a variable carries its field's
|
|
108
|
-
* type, the measure/count
|
|
109
|
-
*
|
|
110
|
-
* payload's type, `pack` its interval type.
|
|
92
|
+
* type, the measure/count are `bigint`, folds carry their input's type
|
|
93
|
+
* (a measure fold is `bigint`), `pack` its interval type.
|
|
111
94
|
*/
|
|
112
|
-
type FindValue<E> = E extends AnyVar ? Infer<E["field"]> : E extends Duration<AnyVar> ? bigint : E extends Agg<"count", undefined> ? bigint : E extends Agg<"
|
|
95
|
+
type FindValue<E> = E extends AnyVar ? Infer<E["field"]> : E extends Duration<AnyVar> ? bigint : E extends Agg<"count", undefined> ? bigint : E extends Agg<"sum" | "min" | "max", infer O> ? O extends AnyVar ? Infer<O["field"]> : bigint : E extends Agg<"pack", infer V extends AnyVar> ? Infer<V["field"]> : never;
|
|
113
96
|
/** The inferred answer-row object type of a find record — the keys ARE the columns. */
|
|
114
97
|
type RowOfFind<F extends FindShape> = {
|
|
115
98
|
readonly [K in keyof F]: FindValue<F[K]>;
|
|
@@ -117,11 +100,11 @@ type RowOfFind<F extends FindShape> = {
|
|
|
117
100
|
/**
|
|
118
101
|
* The head signature of a recursive rule's find record as classed mint
|
|
119
102
|
* slots (descriptor + law-computed class), keyed by column name — the
|
|
120
|
-
* signature an
|
|
103
|
+
* signature an interior join pairs against (`F` is variable-only there).
|
|
121
104
|
*/
|
|
122
105
|
type HeadRecordOf<Classes extends SchemaClasses, F extends FindShape> = {
|
|
123
106
|
readonly [K in keyof F]: F[K] extends AnyVar ? MintSlotOf<Classes, F[K]> : never;
|
|
124
107
|
};
|
|
125
108
|
export type { Agg, AggOpName, AnyAgg, CheckFind, CheckRecFind, FindEntry, FindEntryOk, FindShape, FindValue, HeadRecordOf, RowOfFind };
|
|
126
|
-
export {
|
|
109
|
+
export { count, max, min, pack, sum };
|
|
127
110
|
//# sourceMappingURL=find.d.ts.map
|
package/dist/query/find.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../src/query/find.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../src/query/find.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEnE,0DAA0D;AAC1D,KAAK,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,G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AAA;AACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA"}
|
package/dist/query/find.js
CHANGED
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* vocabulary, mirroring the IR's aggregate roster exactly
|
|
4
4
|
* (`bumbledb/crates/bumbledb/src/ir.rs` `AggOp`/`FindTerm`;
|
|
5
5
|
* `docs/architecture/20-query-ir.md` § aggregation): `count` (nullary),
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `r.sum(w)` — and are typed by the variable's own descriptor.
|
|
6
|
+
* `sum`/`min`/`max` (over an orderable variable or the measure), and
|
|
7
|
+
* `pack` (the coalescing fold — RELATION-SHAPED, the result position
|
|
8
|
+
* interval-typed). Aggregates fold VARIABLES by reference — `r.sum(w)` —
|
|
9
|
+
* and are typed by the variable's own descriptor.
|
|
11
10
|
*
|
|
12
11
|
* `select(strings)` is DEAD: the head is a `find` RECORD, whose KEYS name
|
|
13
12
|
* the answer columns (`find({ total: r.count(), owner: h })`). The keys are
|
|
@@ -19,16 +18,12 @@
|
|
|
19
18
|
* aggregate — no minting or arithmetic term exists to spell (permanent law).
|
|
20
19
|
*/
|
|
21
20
|
/** Builds one aggregate value. */
|
|
22
|
-
function aggregate(op, over
|
|
23
|
-
return Object.freeze({ agg: op, over
|
|
21
|
+
function aggregate(op, over) {
|
|
22
|
+
return Object.freeze({ agg: op, over });
|
|
24
23
|
}
|
|
25
24
|
/** Nullary count: |the group's set of distinct full bindings|, `bigint`. */
|
|
26
25
|
function count() {
|
|
27
|
-
return aggregate("count", undefined
|
|
28
|
-
}
|
|
29
|
-
/** |the distinct values of the variable across the group|, `bigint`; legal over every type. */
|
|
30
|
-
function countDistinct(over) {
|
|
31
|
-
return aggregate("countDistinct", over, undefined);
|
|
26
|
+
return aggregate("count", undefined);
|
|
32
27
|
}
|
|
33
28
|
/**
|
|
34
29
|
* Exact checked sum over a NUMERIC (u64/i64) variable — wide accumulator,
|
|
@@ -37,39 +32,25 @@ function countDistinct(over) {
|
|
|
37
32
|
* quantifier is not an addition (R3).
|
|
38
33
|
*/
|
|
39
34
|
function sum(over) {
|
|
40
|
-
return aggregate("sum", over
|
|
35
|
+
return aggregate("sum", over);
|
|
41
36
|
}
|
|
42
37
|
/** Minimum over an orderable variable (u64/i64/bool — over bool, `Min` is the ALL quantifier; R3) or the measure. */
|
|
43
38
|
function min(over) {
|
|
44
|
-
return aggregate("min", over
|
|
39
|
+
return aggregate("min", over);
|
|
45
40
|
}
|
|
46
41
|
/** Maximum over an orderable variable (u64/i64/bool — over bool, `Max` is the ANY quantifier; R3) or the measure. */
|
|
47
42
|
function max(over) {
|
|
48
|
-
return aggregate("max", over
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Arg-restriction toward the maximum of `key` (`ir::AggOp::ArgMax`): the
|
|
52
|
-
* group's binding set is restricted to the bindings attaining the extreme
|
|
53
|
-
* of the orderable key, and `value` is the carried payload — a tie yields
|
|
54
|
-
* every attaining row. All Arg entries of one query share one key and one
|
|
55
|
-
* direction; Arg and fold aggregates never mix (both the engine's rules).
|
|
56
|
-
*/
|
|
57
|
-
function argMax(value, key) {
|
|
58
|
-
return aggregate("argMax", value, key);
|
|
59
|
-
}
|
|
60
|
-
/** Arg-restriction toward the minimum of `key`; rules as {@link argMax}. */
|
|
61
|
-
function argMin(value, key) {
|
|
62
|
-
return aggregate("argMin", value, key);
|
|
43
|
+
return aggregate("max", over);
|
|
63
44
|
}
|
|
64
45
|
/**
|
|
65
46
|
* The coalescing fold (Snodgrass coalesce, `ir::AggOp::Pack`): per group,
|
|
66
47
|
* the maximal disjoint half-open segments of the union of the group's
|
|
67
48
|
* interval point sets — RELATION-SHAPED, one answer row per (group, maximal
|
|
68
49
|
* segment), the result position carrying one interval of the input's element
|
|
69
|
-
* type. At most one `pack` per find, never beside a fold
|
|
50
|
+
* type. At most one `pack` per find, never beside a fold entry.
|
|
70
51
|
*/
|
|
71
52
|
function pack(over) {
|
|
72
|
-
return aggregate("pack", over
|
|
53
|
+
return aggregate("pack", over);
|
|
73
54
|
}
|
|
74
|
-
export {
|
|
55
|
+
export { count, max, min, pack, sum };
|
|
75
56
|
//# sourceMappingURL=find.js.map
|
package/dist/query/find.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/query/find.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/query/find.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA4BH,kCAAkC;AAClC,SAAS,SAAS,CACjB,EAAM,EACN,IAAU;IAEV,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AACxC,CAAC;AAED,4EAA4E;AAC5E,SAAS,KAAK;IACb,OAAO,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAS,GAAG,CAAoC,IAAO;IACtD,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AAC9B,CAAC;AAED,qHAAqH;AACrH,SAAS,GAAG,CAAoC,IAAO;IACtD,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AAC9B,CAAC;AAED,qHAAqH;AACrH,SAAS,GAAG,CAAoC,IAAO;IACtD,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,SAAS,IAAI,CAAyB,IAAO;IAC5C,OAAO,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAC/B,CAAC;AAoGD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA"}
|