@uwdata/mosaic-core 0.17.0 → 0.19.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.
Files changed (178) hide show
  1. package/LICENSE +47 -0
  2. package/README.md +0 -1
  3. package/dist/src/Coordinator.d.ts +159 -0
  4. package/dist/src/Coordinator.d.ts.map +1 -0
  5. package/dist/src/Coordinator.js +250 -0
  6. package/dist/src/Coordinator.js.map +1 -0
  7. package/dist/src/MosaicClient.d.ts +138 -0
  8. package/dist/src/MosaicClient.d.ts.map +1 -0
  9. package/dist/src/MosaicClient.js +214 -0
  10. package/dist/src/MosaicClient.js.map +1 -0
  11. package/dist/src/Param.d.ts +56 -0
  12. package/dist/src/Param.d.ts.map +1 -0
  13. package/dist/src/Param.js +89 -0
  14. package/dist/src/Param.js.map +1 -0
  15. package/dist/src/QueryConsolidator.d.ts +11 -0
  16. package/dist/src/QueryConsolidator.d.ts.map +1 -0
  17. package/dist/src/QueryConsolidator.js +249 -0
  18. package/dist/src/QueryConsolidator.js.map +1 -0
  19. package/dist/src/QueryManager.d.ts +77 -0
  20. package/dist/src/QueryManager.d.ts.map +1 -0
  21. package/dist/src/QueryManager.js +174 -0
  22. package/dist/src/QueryManager.js.map +1 -0
  23. package/dist/src/Selection.d.ts +222 -0
  24. package/dist/src/Selection.d.ts.map +1 -0
  25. package/dist/src/Selection.js +322 -0
  26. package/dist/src/Selection.js.map +1 -0
  27. package/dist/src/SelectionClause.d.ts +222 -0
  28. package/dist/src/SelectionClause.d.ts.map +1 -0
  29. package/dist/src/SelectionClause.js +168 -0
  30. package/dist/src/SelectionClause.js.map +1 -0
  31. package/dist/src/connectors/Connector.d.ts +26 -0
  32. package/dist/src/connectors/Connector.d.ts.map +1 -0
  33. package/dist/src/connectors/Connector.js +2 -0
  34. package/dist/src/connectors/Connector.js.map +1 -0
  35. package/dist/src/connectors/rest.d.ts +24 -0
  36. package/dist/src/connectors/rest.d.ts.map +1 -0
  37. package/dist/src/connectors/rest.js +37 -0
  38. package/dist/src/connectors/rest.js.map +1 -0
  39. package/dist/src/connectors/socket.d.ts +40 -0
  40. package/dist/src/connectors/socket.d.ts.map +1 -0
  41. package/dist/src/connectors/socket.js +115 -0
  42. package/dist/src/connectors/socket.js.map +1 -0
  43. package/dist/src/connectors/wasm.d.ts +56 -0
  44. package/dist/src/connectors/wasm.d.ts.map +1 -0
  45. package/dist/src/connectors/wasm.js +116 -0
  46. package/dist/src/connectors/wasm.js.map +1 -0
  47. package/dist/src/index.d.ts +28 -0
  48. package/dist/src/index.d.ts.map +1 -0
  49. package/{src → dist/src}/index.js +8 -11
  50. package/dist/src/index.js.map +1 -0
  51. package/dist/src/make-client.d.ts +33 -0
  52. package/dist/src/make-client.d.ts.map +1 -0
  53. package/dist/src/make-client.js +52 -0
  54. package/dist/src/make-client.js.map +1 -0
  55. package/dist/src/preagg/PreAggregator.d.ts +150 -0
  56. package/dist/src/preagg/PreAggregator.d.ts.map +1 -0
  57. package/dist/src/preagg/PreAggregator.js +382 -0
  58. package/dist/src/preagg/PreAggregator.js.map +1 -0
  59. package/dist/src/preagg/preagg-columns.d.ts +16 -0
  60. package/dist/src/preagg/preagg-columns.d.ts.map +1 -0
  61. package/dist/src/preagg/preagg-columns.js +95 -0
  62. package/dist/src/preagg/preagg-columns.js.map +1 -0
  63. package/dist/src/preagg/sufficient-statistics.d.ts +14 -0
  64. package/dist/src/preagg/sufficient-statistics.d.ts.map +1 -0
  65. package/dist/src/preagg/sufficient-statistics.js +446 -0
  66. package/dist/src/preagg/sufficient-statistics.js.map +1 -0
  67. package/dist/src/types.d.ts +77 -0
  68. package/dist/src/types.d.ts.map +1 -0
  69. package/dist/src/types.js +2 -0
  70. package/dist/src/types.js.map +1 -0
  71. package/dist/src/util/AsyncDispatch.d.ts +121 -0
  72. package/dist/src/util/AsyncDispatch.d.ts.map +1 -0
  73. package/dist/src/util/AsyncDispatch.js +188 -0
  74. package/dist/src/util/AsyncDispatch.js.map +1 -0
  75. package/dist/src/util/cache.d.ts +19 -0
  76. package/dist/src/util/cache.d.ts.map +1 -0
  77. package/dist/src/util/cache.js +66 -0
  78. package/dist/src/util/cache.js.map +1 -0
  79. package/dist/src/util/decode-ipc.d.ts +12 -0
  80. package/dist/src/util/decode-ipc.d.ts.map +1 -0
  81. package/{src → dist/src}/util/decode-ipc.js +5 -6
  82. package/dist/src/util/decode-ipc.js.map +1 -0
  83. package/dist/src/util/distinct.d.ts +3 -0
  84. package/dist/src/util/distinct.d.ts.map +1 -0
  85. package/dist/src/util/distinct.js +16 -0
  86. package/dist/src/util/distinct.js.map +1 -0
  87. package/dist/src/util/field-info.d.ts +26 -0
  88. package/dist/src/util/field-info.d.ts.map +1 -0
  89. package/dist/src/util/field-info.js +91 -0
  90. package/dist/src/util/field-info.js.map +1 -0
  91. package/dist/src/util/hash.d.ts +2 -0
  92. package/dist/src/util/hash.d.ts.map +1 -0
  93. package/dist/src/util/hash.js +26 -0
  94. package/dist/src/util/hash.js.map +1 -0
  95. package/dist/src/util/is-activatable.d.ts +8 -0
  96. package/dist/src/util/is-activatable.d.ts.map +1 -0
  97. package/dist/src/util/is-activatable.js +10 -0
  98. package/dist/src/util/is-activatable.js.map +1 -0
  99. package/dist/src/util/is-arrow-table.d.ts +9 -0
  100. package/dist/src/util/is-arrow-table.d.ts.map +1 -0
  101. package/dist/src/util/is-arrow-table.js +11 -0
  102. package/dist/src/util/is-arrow-table.js.map +1 -0
  103. package/dist/src/util/js-type.d.ts +9 -0
  104. package/dist/src/util/js-type.d.ts.map +1 -0
  105. package/dist/src/util/js-type.js +59 -0
  106. package/dist/src/util/js-type.js.map +1 -0
  107. package/dist/src/util/priority-queue.d.ts +35 -0
  108. package/dist/src/util/priority-queue.d.ts.map +1 -0
  109. package/dist/src/util/priority-queue.js +81 -0
  110. package/dist/src/util/priority-queue.js.map +1 -0
  111. package/dist/src/util/query-result.d.ts +47 -0
  112. package/dist/src/util/query-result.d.ts.map +1 -0
  113. package/dist/src/util/query-result.js +83 -0
  114. package/dist/src/util/query-result.js.map +1 -0
  115. package/dist/src/util/synchronizer.d.ts +36 -0
  116. package/dist/src/util/synchronizer.d.ts.map +1 -0
  117. package/dist/src/util/synchronizer.js +52 -0
  118. package/dist/src/util/synchronizer.js.map +1 -0
  119. package/dist/src/util/throttle.d.ts +12 -0
  120. package/dist/src/util/throttle.d.ts.map +1 -0
  121. package/dist/src/util/throttle.js +51 -0
  122. package/dist/src/util/throttle.js.map +1 -0
  123. package/dist/src/util/to-data-columns.d.ts +22 -0
  124. package/dist/src/util/to-data-columns.d.ts.map +1 -0
  125. package/dist/src/util/to-data-columns.js +51 -0
  126. package/dist/src/util/to-data-columns.js.map +1 -0
  127. package/dist/src/util/void-logger.d.ts +13 -0
  128. package/dist/src/util/void-logger.d.ts.map +1 -0
  129. package/dist/src/util/void-logger.js +13 -0
  130. package/dist/src/util/void-logger.js.map +1 -0
  131. package/package.json +17 -11
  132. package/src/Coordinator.ts +396 -0
  133. package/src/{MosaicClient.js → MosaicClient.ts} +50 -43
  134. package/src/{Param.js → Param.ts} +29 -28
  135. package/src/{QueryConsolidator.js → QueryConsolidator.ts} +85 -62
  136. package/src/{QueryManager.js → QueryManager.ts} +61 -54
  137. package/src/Selection.ts +391 -0
  138. package/src/SelectionClause.ts +357 -0
  139. package/src/connectors/Connector.ts +6 -6
  140. package/src/connectors/rest.ts +56 -0
  141. package/src/connectors/{socket.js → socket.ts} +53 -42
  142. package/src/connectors/{wasm.js → wasm.ts} +52 -63
  143. package/src/index.ts +42 -0
  144. package/src/make-client.ts +93 -0
  145. package/src/preagg/{PreAggregator.js → PreAggregator.ts} +164 -145
  146. package/src/preagg/{preagg-columns.js → preagg-columns.ts} +27 -24
  147. package/src/preagg/{sufficient-statistics.js → sufficient-statistics.ts} +160 -110
  148. package/src/types.ts +24 -9
  149. package/src/util/{AsyncDispatch.js → AsyncDispatch.ts} +62 -43
  150. package/src/util/{cache.js → cache.ts} +25 -15
  151. package/src/util/decode-ipc.ts +15 -0
  152. package/src/util/{distinct.js → distinct.ts} +3 -3
  153. package/src/util/{field-info.js → field-info.ts} +30 -31
  154. package/src/util/{hash.js → hash.ts} +4 -4
  155. package/src/util/is-activatable.ts +11 -0
  156. package/src/util/is-arrow-table.ts +12 -0
  157. package/src/util/{js-type.js → js-type.ts} +7 -5
  158. package/src/util/{priority-queue.js → priority-queue.ts} +32 -20
  159. package/src/util/{query-result.js → query-result.ts} +24 -17
  160. package/src/util/synchronizer.ts +56 -0
  161. package/src/util/throttle.ts +59 -0
  162. package/src/util/to-data-columns.ts +65 -0
  163. package/src/util/void-logger.ts +23 -0
  164. package/src/Coordinator.js +0 -313
  165. package/src/Selection.js +0 -380
  166. package/src/SelectionClause.js +0 -159
  167. package/src/connectors/rest.js +0 -38
  168. package/src/index-types.ts +0 -5
  169. package/src/make-client.js +0 -101
  170. package/src/util/is-activatable.js +0 -8
  171. package/src/util/is-arrow-table.js +0 -10
  172. package/src/util/selection-types.ts +0 -137
  173. package/src/util/synchronizer.js +0 -47
  174. package/src/util/throttle.js +0 -54
  175. package/src/util/to-data-columns.js +0 -60
  176. package/src/util/void-logger.js +0 -13
  177. package/tsconfig.json +0 -9
  178. package/vitest.config.ts +0 -3
@@ -1,10 +0,0 @@
1
- /**
2
- * Test if a value is a Flechette Arrow table.
3
- * We use a "duck typing" approach and check for a getChild function.
4
- * @param {*} values The value to test
5
- * @returns {values is import('@uwdata/flechette').Table}
6
- * true if the value duck types as Arrow data
7
- */
8
- export function isArrowTable(values) {
9
- return typeof values?.getChild === 'function';
10
- }
@@ -1,137 +0,0 @@
1
- import { ExprNode } from '@uwdata/mosaic-sql';
2
- import { MosaicClient } from '../MosaicClient.js';
3
-
4
- /**
5
- * Selection clause metadata to guide possible query optimizations.
6
- * Sub-interfaces provide more information about the specifics of a
7
- * given selection based on the selection type.
8
- */
9
- export interface ClauseMetadata {
10
- /**
11
- * The selection type, such as `'point'`, `'interval'`, or `'match'`.
12
- */
13
- type: string;
14
- }
15
-
16
- /**
17
- * Selection clause metadata indicating selection of one or more discrete
18
- * point values, typically based on equality or is distinctiveness checks.
19
- */
20
- export interface PointMetadata extends ClauseMetadata {
21
- type: 'point';
22
- }
23
-
24
- /** Text search matching methods. */
25
- export type MatchMethod =
26
- | 'contains'
27
- | 'prefix'
28
- | 'suffix'
29
- | 'regexp'
30
- | (string & {});
31
-
32
- /**
33
- * Selection clause metadata indicating text search matching.
34
- */
35
- export interface MatchMetadata extends ClauseMetadata {
36
- type: MatchMethod;
37
- /** The text search matching method used. */
38
- method?: 'contains' | 'prefix' | 'suffix' | 'regexp' | (string & {});
39
- }
40
-
41
- /** Quantitative scale types. */
42
- export type ScaleType =
43
- | 'identity'
44
- | 'linear'
45
- | 'log'
46
- | 'sqrt'
47
- | 'pow'
48
- | 'symlog'
49
- | 'time'
50
- | 'utc';
51
-
52
- /** A data value interval extent. */
53
- export type Extent = [number, number] | [Date, Date];
54
-
55
- /**
56
- * Descriptor for a scale that maps a data domain to screen pixels.
57
- */
58
- export interface Scale {
59
- /** The scale type, such as `'linear'`, `'log'`, etc. */
60
- type: ScaleType;
61
- /** The scale domain, as an array of start and end data values. */
62
- domain: Extent;
63
- /**
64
- * The scale range, as an array of start and end screen pixels.
65
- * The range may be omitted for *identity* scales.
66
- */
67
- range?: [number, number];
68
- /** The base of the logarithm. For `'log'` scales only. */
69
- base?: number;
70
- /** The constant parameter. For `'symlog'` scales only. */
71
- constant?: number;
72
- /** The exponent parameter. For `'pow'` scales only. */
73
- exponent?: number;
74
- }
75
-
76
- /** A binning method name. */
77
- export type BinMethod = 'floor' | 'ceil' | 'round';
78
-
79
- /**
80
- * Selection clause metadata for one or more selected intervals. This
81
- * metadata can be used to determine appropriate data-space binning
82
- * schemes that correspond to pixel-level bins in screen space.
83
- */
84
- export interface IntervalMetadata extends ClauseMetadata {
85
- type: 'interval';
86
- /**
87
- * The interactive pixel size used by the generating component.
88
- * Values larger than one indicate intervals that "snap-to" values
89
- * greater than a single pixel. If unspecified, assumed to be `1`.
90
- */
91
- pixelSize?: number;
92
- /**
93
- * An array of one or more scale descriptors that describe the
94
- * mapping from data values to screen pixels.
95
- */
96
- scales?: Scale[];
97
- /**
98
- * A hint for the binning method to use when discretizing the
99
- * interval domain. If unspecified, the default is `'floor'`.
100
- */
101
- bin?: BinMethod
102
- }
103
-
104
- /**
105
- * A selection clause representing filtering criteria
106
- * to apply within a Mosiac Selection.
107
- */
108
- export interface SelectionClause {
109
- /**
110
- * A unique identifier (according to object equality) for the source
111
- * component that generated this clause. In many cases, this is a
112
- * reference to the originating component itself.
113
- */
114
- source: any;
115
- /**
116
- * A set of Mosaic clients associated with this clause that should not
117
- * be updated when this clause is applied in a cross-filtering context.
118
- */
119
- clients?: Set<MosaicClient>;
120
- /**
121
- * A selected value associated with this clause. For example, for a 1D
122
- * interval selection clause the value may be a [lo, hi] array.
123
- */
124
- value: any;
125
- /**
126
- * A predicate SQL expression suitable for use in a query WHERE clause.
127
- * The predicate should apply filtering criteria consistent with this
128
- * clause's *value* property.
129
- */
130
- predicate: ExprNode | null;
131
- /**
132
- * Optional clause metadata that varies based on the selection type.
133
- * The metadata can be used to optimize selection queries, for example
134
- * by creating materialized views of pre-aggregated data when applicable.
135
- */
136
- meta?: ClauseMetadata;
137
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * Create a new synchronizer instance to aid synchronization
3
- * of updates on multiple pending operations.
4
- */
5
- export function synchronizer() {
6
- const set = new Set;
7
- let done;
8
- let promise = new Promise(resolve => done = resolve);
9
-
10
- return {
11
- /**
12
- * Mark an item as pending.
13
- * @param {*} item An item to synchronize on.
14
- */
15
- pending(item) {
16
- set.add(item);
17
- },
18
- /**
19
- * Mark a pending item as ready, indicating it is
20
- * ready for a synchronized update.
21
- * @param {*} item An item to synchronize on.
22
- * @returns {boolean} True if the synchronizer is ready to
23
- * resolve, false otherwise.
24
- */
25
- ready(item) {
26
- set.delete(item);
27
- return set.size === 0;
28
- },
29
- /**
30
- * Resolve the current synchronization cycle, causing the synchronize
31
- * promise to resolve and thereby trigger downstream updates.
32
- */
33
- resolve() {
34
- promise = new Promise(resolve => {
35
- done();
36
- done = resolve;
37
- });
38
- },
39
- /**
40
- * The promise for the current synchronization cycle.
41
- * @return {Promise} The synchronization promise.
42
- */
43
- get promise() {
44
- return promise;
45
- }
46
- }
47
- }
@@ -1,54 +0,0 @@
1
- const NIL = {};
2
-
3
- /**
4
- * Throttle invocations of a callback function. The callback must return
5
- * a Promise. Upon repeated invocation, the callback will not be invoked
6
- * until a prior Promise resolves. If multiple invocations occurs while
7
- * waiting, only the most recent invocation will be pending.
8
- * @template E, T
9
- * @param {(event: E) => Promise<T>} callback The callback function.
10
- * @param {boolean} [debounce=true] Flag indicating if invocations
11
- * should also be debounced within the current animation frame.
12
- * @returns {(event: E) => void} A new function that throttles
13
- * access to the callback.
14
- */
15
- export function throttle(callback, debounce = false) {
16
- let curr;
17
- let next;
18
- let pending = NIL;
19
-
20
- function invoke(event) {
21
- curr = callback(event)
22
- .catch(() => {})
23
- .finally(() => {
24
- if (next) {
25
- const { value } = next;
26
- next = null;
27
- invoke(value);
28
- } else {
29
- curr = null;
30
- }
31
- });
32
- }
33
-
34
- function enqueue(event) {
35
- next = { event };
36
- }
37
-
38
- function process(event) {
39
- curr ? enqueue(event) : invoke(event);
40
- }
41
-
42
- function delay(event) {
43
- if (pending !== event) {
44
- requestAnimationFrame(() => {
45
- const e = pending;
46
- pending = NIL;
47
- process(e);
48
- });
49
- }
50
- pending = event;
51
- }
52
-
53
- return debounce ? delay : process;
54
- }
@@ -1,60 +0,0 @@
1
- import { isArrowTable } from './is-arrow-table.js';
2
-
3
- /**
4
- * @typedef {Array | Int8Array | Uint8Array | Uint8ClampedArray
5
- * | Int16Array | Uint16Array | Int32Array | Uint32Array
6
- * | Float32Array | Float64Array
7
- * } Arrayish - an Array or TypedArray
8
- */
9
-
10
- /**
11
- * @typedef {
12
- * | { numRows: number, columns: Record<string,Arrayish> }
13
- * | { numRows: number, values: Arrayish; }
14
- * } DataColumns
15
- */
16
-
17
- /**
18
- * Convert input data to a set of column arrays.
19
- * @param {any} data The input data.
20
- * @returns {DataColumns} An object with named column arrays.
21
- */
22
- export function toDataColumns(data) {
23
- return isArrowTable(data)
24
- ? arrowToColumns(data)
25
- : arrayToColumns(data);
26
- }
27
-
28
- /**
29
- * Convert an Arrow table to a set of column arrays.
30
- * @param {import('@uwdata/flechette').Table} data An Arrow Table.
31
- * @returns {DataColumns} An object with named column arrays.
32
- */
33
- function arrowToColumns(data) {
34
- const { numRows } = data;
35
- return { numRows, columns: data.toColumns() };
36
- }
37
-
38
- /**
39
- * Convert an array of values to a set of column arrays.
40
- * If the array values are objects, build out named columns.
41
- * We use the keys of the first object as the column names.
42
- * Otherwise, use a special "values" array.
43
- * @param {object[]} data An array of data objects.
44
- * @returns {DataColumns} An object with named column arrays.
45
- */
46
- function arrayToColumns(data) {
47
- const numRows = data.length;
48
- if (typeof data[0] === 'object') {
49
- const names = numRows ? Object.keys(data[0]) : [];
50
- const columns = {};
51
- if (names.length > 0) {
52
- names.forEach(name => {
53
- columns[name] = data.map(d => d[name]);
54
- });
55
- }
56
- return { numRows, columns };
57
- } else {
58
- return { numRows, values: data };
59
- }
60
- }
@@ -1,13 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- export function voidLogger() {
3
- return {
4
- debug(..._) {},
5
- info(..._) {},
6
- log(..._) {},
7
- warn(..._) {},
8
- error(..._) {},
9
- group(label) {},
10
- groupCollapsed(label) {},
11
- groupEnd() {}
12
- };
13
- }
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "include": ["src/**/*"],
4
- "compilerOptions": {
5
- "emitDeclarationOnly": true,
6
- "outDir": "dist"
7
- },
8
- "references": [{ "path": "../sql" }]
9
- }
package/vitest.config.ts DELETED
@@ -1,3 +0,0 @@
1
- import { defineConfig } from 'vite';
2
-
3
- export default defineConfig({});