@uwdata/mosaic-core 0.17.0 → 0.18.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/LICENSE +47 -0
- package/README.md +0 -1
- package/dist/src/Coordinator.d.ts +147 -0
- package/dist/src/Coordinator.d.ts.map +1 -0
- package/dist/src/Coordinator.js +269 -0
- package/dist/src/Coordinator.js.map +1 -0
- package/dist/src/MosaicClient.d.ts +138 -0
- package/dist/src/MosaicClient.d.ts.map +1 -0
- package/dist/src/MosaicClient.js +213 -0
- package/dist/src/MosaicClient.js.map +1 -0
- package/dist/src/Param.d.ts +56 -0
- package/dist/src/Param.d.ts.map +1 -0
- package/dist/src/Param.js +89 -0
- package/dist/src/Param.js.map +1 -0
- package/dist/src/QueryConsolidator.d.ts +11 -0
- package/dist/src/QueryConsolidator.d.ts.map +1 -0
- package/dist/src/QueryConsolidator.js +249 -0
- package/dist/src/QueryConsolidator.js.map +1 -0
- package/dist/src/QueryManager.d.ts +77 -0
- package/dist/src/QueryManager.d.ts.map +1 -0
- package/dist/src/QueryManager.js +174 -0
- package/dist/src/QueryManager.js.map +1 -0
- package/dist/src/Selection.d.ts +222 -0
- package/dist/src/Selection.d.ts.map +1 -0
- package/dist/src/Selection.js +319 -0
- package/dist/src/Selection.js.map +1 -0
- package/dist/src/SelectionClause.d.ts +192 -0
- package/dist/src/SelectionClause.d.ts.map +1 -0
- package/dist/src/SelectionClause.js +126 -0
- package/dist/src/SelectionClause.js.map +1 -0
- package/dist/src/connectors/Connector.d.ts +26 -0
- package/dist/src/connectors/Connector.d.ts.map +1 -0
- package/dist/src/connectors/Connector.js +2 -0
- package/dist/src/connectors/Connector.js.map +1 -0
- package/dist/src/connectors/rest.d.ts +24 -0
- package/dist/src/connectors/rest.d.ts.map +1 -0
- package/dist/src/connectors/rest.js +37 -0
- package/dist/src/connectors/rest.js.map +1 -0
- package/dist/src/connectors/socket.d.ts +40 -0
- package/dist/src/connectors/socket.d.ts.map +1 -0
- package/dist/src/connectors/socket.js +115 -0
- package/dist/src/connectors/socket.js.map +1 -0
- package/dist/src/connectors/wasm.d.ts +53 -0
- package/dist/src/connectors/wasm.d.ts.map +1 -0
- package/dist/src/connectors/wasm.js +113 -0
- package/dist/src/connectors/wasm.js.map +1 -0
- package/dist/src/index.d.ts +28 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/make-client.d.ts +35 -0
- package/dist/src/make-client.d.ts.map +1 -0
- package/dist/src/make-client.js +52 -0
- package/dist/src/make-client.js.map +1 -0
- package/dist/src/preagg/PreAggregator.d.ts +150 -0
- package/dist/src/preagg/PreAggregator.d.ts.map +1 -0
- package/dist/src/preagg/PreAggregator.js +382 -0
- package/dist/src/preagg/PreAggregator.js.map +1 -0
- package/dist/src/preagg/preagg-columns.d.ts +16 -0
- package/dist/src/preagg/preagg-columns.d.ts.map +1 -0
- package/dist/src/preagg/preagg-columns.js +95 -0
- package/dist/src/preagg/preagg-columns.js.map +1 -0
- package/dist/src/preagg/sufficient-statistics.d.ts +14 -0
- package/dist/src/preagg/sufficient-statistics.d.ts.map +1 -0
- package/dist/src/preagg/sufficient-statistics.js +446 -0
- package/dist/src/preagg/sufficient-statistics.js.map +1 -0
- package/dist/src/types.d.ts +77 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/util/AsyncDispatch.d.ts +121 -0
- package/dist/src/util/AsyncDispatch.d.ts.map +1 -0
- package/dist/src/util/AsyncDispatch.js +188 -0
- package/dist/src/util/AsyncDispatch.js.map +1 -0
- package/dist/src/util/cache.d.ts +19 -0
- package/dist/src/util/cache.d.ts.map +1 -0
- package/dist/src/util/cache.js +66 -0
- package/dist/src/util/cache.js.map +1 -0
- package/dist/src/util/decode-ipc.d.ts +12 -0
- package/dist/src/util/decode-ipc.d.ts.map +1 -0
- package/{src → dist/src}/util/decode-ipc.js +5 -6
- package/dist/src/util/decode-ipc.js.map +1 -0
- package/dist/src/util/distinct.d.ts +3 -0
- package/dist/src/util/distinct.d.ts.map +1 -0
- package/dist/src/util/distinct.js +16 -0
- package/dist/src/util/distinct.js.map +1 -0
- package/dist/src/util/field-info.d.ts +26 -0
- package/dist/src/util/field-info.d.ts.map +1 -0
- package/dist/src/util/field-info.js +91 -0
- package/dist/src/util/field-info.js.map +1 -0
- package/dist/src/util/hash.d.ts +2 -0
- package/dist/src/util/hash.d.ts.map +1 -0
- package/dist/src/util/hash.js +26 -0
- package/dist/src/util/hash.js.map +1 -0
- package/dist/src/util/is-activatable.d.ts +8 -0
- package/dist/src/util/is-activatable.d.ts.map +1 -0
- package/dist/src/util/is-activatable.js +10 -0
- package/dist/src/util/is-activatable.js.map +1 -0
- package/dist/src/util/is-arrow-table.d.ts +9 -0
- package/dist/src/util/is-arrow-table.d.ts.map +1 -0
- package/dist/src/util/is-arrow-table.js +11 -0
- package/dist/src/util/is-arrow-table.js.map +1 -0
- package/dist/src/util/js-type.d.ts +9 -0
- package/dist/src/util/js-type.d.ts.map +1 -0
- package/dist/src/util/js-type.js +59 -0
- package/dist/src/util/js-type.js.map +1 -0
- package/dist/src/util/priority-queue.d.ts +35 -0
- package/dist/src/util/priority-queue.d.ts.map +1 -0
- package/dist/src/util/priority-queue.js +81 -0
- package/dist/src/util/priority-queue.js.map +1 -0
- package/dist/src/util/query-result.d.ts +47 -0
- package/dist/src/util/query-result.d.ts.map +1 -0
- package/dist/src/util/query-result.js +83 -0
- package/dist/src/util/query-result.js.map +1 -0
- package/dist/src/util/synchronizer.d.ts +36 -0
- package/dist/src/util/synchronizer.d.ts.map +1 -0
- package/dist/src/util/synchronizer.js +52 -0
- package/dist/src/util/synchronizer.js.map +1 -0
- package/dist/src/util/throttle.d.ts +12 -0
- package/dist/src/util/throttle.d.ts.map +1 -0
- package/dist/src/util/throttle.js +51 -0
- package/dist/src/util/throttle.js.map +1 -0
- package/dist/src/util/to-data-columns.d.ts +22 -0
- package/dist/src/util/to-data-columns.d.ts.map +1 -0
- package/dist/src/util/to-data-columns.js +51 -0
- package/dist/src/util/to-data-columns.js.map +1 -0
- package/dist/src/util/void-logger.d.ts +13 -0
- package/dist/src/util/void-logger.d.ts.map +1 -0
- package/dist/src/util/void-logger.js +13 -0
- package/dist/src/util/void-logger.js.map +1 -0
- package/package.json +16 -10
- package/src/Coordinator.ts +367 -0
- package/src/{MosaicClient.js → MosaicClient.ts} +49 -43
- package/src/{Param.js → Param.ts} +29 -28
- package/src/{QueryConsolidator.js → QueryConsolidator.ts} +81 -58
- package/src/{QueryManager.js → QueryManager.ts} +61 -54
- package/src/Selection.ts +388 -0
- package/src/SelectionClause.ts +275 -0
- package/src/connectors/Connector.ts +6 -6
- package/src/connectors/rest.ts +56 -0
- package/src/connectors/{socket.js → socket.ts} +53 -42
- package/src/connectors/{wasm.js → wasm.ts} +46 -62
- package/src/{index.js → index.ts} +13 -1
- package/src/make-client.ts +93 -0
- package/src/preagg/{PreAggregator.js → PreAggregator.ts} +164 -145
- package/src/preagg/{preagg-columns.js → preagg-columns.ts} +27 -24
- package/src/preagg/{sufficient-statistics.js → sufficient-statistics.ts} +160 -110
- package/src/types.ts +24 -9
- package/src/util/{AsyncDispatch.js → AsyncDispatch.ts} +62 -43
- package/src/util/{cache.js → cache.ts} +25 -15
- package/src/util/decode-ipc.ts +15 -0
- package/src/util/{distinct.js → distinct.ts} +3 -3
- package/src/util/{field-info.js → field-info.ts} +31 -32
- package/src/util/{hash.js → hash.ts} +4 -4
- package/src/util/is-activatable.ts +11 -0
- package/src/util/is-arrow-table.ts +12 -0
- package/src/util/{js-type.js → js-type.ts} +7 -5
- package/src/util/{priority-queue.js → priority-queue.ts} +32 -20
- package/src/util/{query-result.js → query-result.ts} +24 -17
- package/src/util/synchronizer.ts +56 -0
- package/src/util/throttle.ts +59 -0
- package/src/util/to-data-columns.ts +65 -0
- package/src/util/void-logger.ts +23 -0
- package/src/Coordinator.js +0 -313
- package/src/Selection.js +0 -380
- package/src/SelectionClause.js +0 -159
- package/src/connectors/rest.js +0 -38
- package/src/index-types.ts +0 -5
- package/src/make-client.js +0 -101
- package/src/util/is-activatable.js +0 -8
- package/src/util/is-arrow-table.js +0 -10
- package/src/util/selection-types.ts +0 -137
- package/src/util/synchronizer.js +0 -47
- package/src/util/throttle.js +0 -54
- package/src/util/to-data-columns.js +0 -60
- package/src/util/void-logger.js +0 -13
- package/tsconfig.json +0 -9
- package/vitest.config.ts +0 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
type EventCallback<T = unknown> = (value: T) => void | Promise<unknown>;
|
|
2
|
+
interface DispatchEntry<T = unknown> {
|
|
3
|
+
callbacks: Set<EventCallback<T>>;
|
|
4
|
+
pending: Promise<unknown> | null;
|
|
5
|
+
queue: DispatchQueue<T>;
|
|
6
|
+
}
|
|
7
|
+
interface QueueNode<T = unknown> {
|
|
8
|
+
value: T;
|
|
9
|
+
next?: QueueNode<T> | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Event dispatcher supporting asynchronous updates. If an event handler
|
|
13
|
+
* callback returns a Promise, the dispatcher waits for all such Promises
|
|
14
|
+
* to settle before dispatching future events of the same type.
|
|
15
|
+
*/
|
|
16
|
+
export declare class AsyncDispatch<T> {
|
|
17
|
+
_callbacks: Map<string, DispatchEntry<T>>;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new asynchronous dispatcher instance.
|
|
20
|
+
*/
|
|
21
|
+
constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Add an event listener callback for the provided event type.
|
|
24
|
+
* @param type The event type.
|
|
25
|
+
* @param callback The event handler
|
|
26
|
+
* callback function to add. If the callback has already been
|
|
27
|
+
* added for the event type, this method has no effect.
|
|
28
|
+
*/
|
|
29
|
+
addEventListener(type: string, callback: EventCallback<T>): void;
|
|
30
|
+
/**
|
|
31
|
+
* Remove an event listener callback for the provided event type.
|
|
32
|
+
* @param type The event type.
|
|
33
|
+
* @param callback The event handler
|
|
34
|
+
* callback function to remove.
|
|
35
|
+
*/
|
|
36
|
+
removeEventListener(type: string, callback: EventCallback<T>): void;
|
|
37
|
+
/**
|
|
38
|
+
* Lifecycle method that returns the event value to emit.
|
|
39
|
+
* This default implementation simply returns the input value as-is.
|
|
40
|
+
* Subclasses may override this method to implement custom transformations
|
|
41
|
+
* prior to emitting an event value to all listeners.
|
|
42
|
+
* @param type The event type.
|
|
43
|
+
* @param value The event value.
|
|
44
|
+
* @returns The (possibly transformed) event value to emit.
|
|
45
|
+
*/
|
|
46
|
+
willEmit(type: string, value: T): T;
|
|
47
|
+
/**
|
|
48
|
+
* Lifecycle method that returns a filter function for updating the
|
|
49
|
+
* queue of unemitted event values prior to enqueueing a new value.
|
|
50
|
+
* This default implementation simply returns null, indicating that
|
|
51
|
+
* unknown other unemitted event values should be dropped (that is, all
|
|
52
|
+
* queued events are filtered).
|
|
53
|
+
* @param type The event type.
|
|
54
|
+
* @param value The new event value that will be enqueued.
|
|
55
|
+
* @returns A dispatch queue filter
|
|
56
|
+
* function, or null if all unemitted event values should be filtered.
|
|
57
|
+
*/
|
|
58
|
+
emitQueueFilter(_type: string, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
59
|
+
_value: unknown): ((value: unknown) => boolean | null) | null;
|
|
60
|
+
/**
|
|
61
|
+
* Cancel all unemitted event values for the given event type.
|
|
62
|
+
* @param type The event type.
|
|
63
|
+
*/
|
|
64
|
+
cancel(type: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Returns a promise that resolves when unknown pending updates complete for
|
|
67
|
+
* the event of the given type currently being processed. The Promise will
|
|
68
|
+
* resolve immediately if the queue for the given event type is empty.
|
|
69
|
+
* @param type The event type to wait for.
|
|
70
|
+
* @returns A pending event promise.
|
|
71
|
+
*/
|
|
72
|
+
pending(type: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Emit an event value to listeners for the given event type.
|
|
75
|
+
* If a previous emit has not yet resolved, the event value
|
|
76
|
+
* will be queued to be emitted later.
|
|
77
|
+
* The actual event value given to listeners will be the result
|
|
78
|
+
* of passing the input value through the emitValue() method.
|
|
79
|
+
* @param type The event type.
|
|
80
|
+
* @param value The event value.
|
|
81
|
+
*/
|
|
82
|
+
emit(type: string, value: T): void;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Queue for managing unemitted event values.
|
|
86
|
+
*/
|
|
87
|
+
export declare class DispatchQueue<T = unknown> {
|
|
88
|
+
next: QueueNode<T> | null;
|
|
89
|
+
/**
|
|
90
|
+
* Create a new dispatch queue instance.
|
|
91
|
+
*/
|
|
92
|
+
constructor();
|
|
93
|
+
/**
|
|
94
|
+
* Clear the queue state of all event values.
|
|
95
|
+
*/
|
|
96
|
+
clear(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Indicate if the queue is empty.
|
|
99
|
+
* @returns True if queue is empty, false otherwise.
|
|
100
|
+
*/
|
|
101
|
+
isEmpty(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Add a new value to the queue, and optionally filter the
|
|
104
|
+
* current queue content in response.
|
|
105
|
+
* @param value The value to add.
|
|
106
|
+
* @param filter An optional filter
|
|
107
|
+
* function to apply to existing queue content. If unspecified
|
|
108
|
+
* or falsy, all previously queued values are removed. Otherwise,
|
|
109
|
+
* the provided function is applied to all queue entries. The
|
|
110
|
+
* entry is retained if the filter function returns a truthy value,
|
|
111
|
+
* otherwise the entry is removed.
|
|
112
|
+
*/
|
|
113
|
+
enqueue(value: T, filter?: ((value: T) => boolean | null) | null): void;
|
|
114
|
+
/**
|
|
115
|
+
* Remove and return the next queued event value.
|
|
116
|
+
* @returns The next event value in the queue.
|
|
117
|
+
*/
|
|
118
|
+
dequeue(): T | undefined;
|
|
119
|
+
}
|
|
120
|
+
export {};
|
|
121
|
+
//# sourceMappingURL=AsyncDispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncDispatch.d.ts","sourceRoot":"","sources":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G;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C;;;;;;;;OAQG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;CAsBnC;AAED;;GAEG;AACH,qBAAa,aAAa,CAAC,CAAC,GAAG,OAAO;IACpC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAQ;IAEjC;;OAEG;;IAKH;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,OAAO,IAAI,OAAO;IAIlB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI;IAkBvE;;;OAGG;IACH,OAAO,IAAI,CAAC,GAAG,SAAS;CAKzB"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event dispatcher supporting asynchronous updates. If an event handler
|
|
3
|
+
* callback returns a Promise, the dispatcher waits for all such Promises
|
|
4
|
+
* to settle before dispatching future events of the same type.
|
|
5
|
+
*/
|
|
6
|
+
export class AsyncDispatch {
|
|
7
|
+
_callbacks;
|
|
8
|
+
/**
|
|
9
|
+
* Create a new asynchronous dispatcher instance.
|
|
10
|
+
*/
|
|
11
|
+
constructor() {
|
|
12
|
+
this._callbacks = new Map();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Add an event listener callback for the provided event type.
|
|
16
|
+
* @param type The event type.
|
|
17
|
+
* @param callback The event handler
|
|
18
|
+
* callback function to add. If the callback has already been
|
|
19
|
+
* added for the event type, this method has no effect.
|
|
20
|
+
*/
|
|
21
|
+
addEventListener(type, callback) {
|
|
22
|
+
if (!this._callbacks.has(type)) {
|
|
23
|
+
this._callbacks.set(type, {
|
|
24
|
+
callbacks: new Set(),
|
|
25
|
+
pending: null,
|
|
26
|
+
queue: new DispatchQueue()
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const entry = this._callbacks.get(type);
|
|
30
|
+
entry.callbacks.add(callback);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Remove an event listener callback for the provided event type.
|
|
34
|
+
* @param type The event type.
|
|
35
|
+
* @param callback The event handler
|
|
36
|
+
* callback function to remove.
|
|
37
|
+
*/
|
|
38
|
+
removeEventListener(type, callback) {
|
|
39
|
+
const entry = this._callbacks.get(type);
|
|
40
|
+
if (entry) {
|
|
41
|
+
entry.callbacks.delete(callback);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Lifecycle method that returns the event value to emit.
|
|
46
|
+
* This default implementation simply returns the input value as-is.
|
|
47
|
+
* Subclasses may override this method to implement custom transformations
|
|
48
|
+
* prior to emitting an event value to all listeners.
|
|
49
|
+
* @param type The event type.
|
|
50
|
+
* @param value The event value.
|
|
51
|
+
* @returns The (possibly transformed) event value to emit.
|
|
52
|
+
*/
|
|
53
|
+
willEmit(type, value) {
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Lifecycle method that returns a filter function for updating the
|
|
58
|
+
* queue of unemitted event values prior to enqueueing a new value.
|
|
59
|
+
* This default implementation simply returns null, indicating that
|
|
60
|
+
* unknown other unemitted event values should be dropped (that is, all
|
|
61
|
+
* queued events are filtered).
|
|
62
|
+
* @param type The event type.
|
|
63
|
+
* @param value The new event value that will be enqueued.
|
|
64
|
+
* @returns A dispatch queue filter
|
|
65
|
+
* function, or null if all unemitted event values should be filtered.
|
|
66
|
+
*/
|
|
67
|
+
emitQueueFilter(_type, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
68
|
+
_value // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
69
|
+
) {
|
|
70
|
+
// removes all pending items
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Cancel all unemitted event values for the given event type.
|
|
75
|
+
* @param type The event type.
|
|
76
|
+
*/
|
|
77
|
+
cancel(type) {
|
|
78
|
+
const entry = this._callbacks.get(type);
|
|
79
|
+
entry?.queue.clear();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Returns a promise that resolves when unknown pending updates complete for
|
|
83
|
+
* the event of the given type currently being processed. The Promise will
|
|
84
|
+
* resolve immediately if the queue for the given event type is empty.
|
|
85
|
+
* @param type The event type to wait for.
|
|
86
|
+
* @returns A pending event promise.
|
|
87
|
+
*/
|
|
88
|
+
async pending(type) {
|
|
89
|
+
await this._callbacks.get(type)?.pending;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Emit an event value to listeners for the given event type.
|
|
93
|
+
* If a previous emit has not yet resolved, the event value
|
|
94
|
+
* will be queued to be emitted later.
|
|
95
|
+
* The actual event value given to listeners will be the result
|
|
96
|
+
* of passing the input value through the emitValue() method.
|
|
97
|
+
* @param type The event type.
|
|
98
|
+
* @param value The event value.
|
|
99
|
+
*/
|
|
100
|
+
emit(type, value) {
|
|
101
|
+
const entry = this._callbacks.get(type) || {};
|
|
102
|
+
if (entry.pending) {
|
|
103
|
+
// an earlier emit is still processing
|
|
104
|
+
// enqueue the current update, possibly filtering other pending updates
|
|
105
|
+
entry.queue.enqueue(value, this.emitQueueFilter(type, value));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const event = this.willEmit(type, value);
|
|
109
|
+
const { callbacks, queue } = entry;
|
|
110
|
+
if (callbacks?.size) {
|
|
111
|
+
// broadcast update to callbacks, which may return promises
|
|
112
|
+
// wait until promises resolve, then process pending updates
|
|
113
|
+
const callbackValues = Array.from(callbacks, cb => cb(event));
|
|
114
|
+
entry.pending = Promise.allSettled(callbackValues).then(() => {
|
|
115
|
+
entry.pending = null;
|
|
116
|
+
if (!queue.isEmpty()) {
|
|
117
|
+
this.emit(type, queue.dequeue());
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Queue for managing unemitted event values.
|
|
126
|
+
*/
|
|
127
|
+
export class DispatchQueue {
|
|
128
|
+
next = null;
|
|
129
|
+
/**
|
|
130
|
+
* Create a new dispatch queue instance.
|
|
131
|
+
*/
|
|
132
|
+
constructor() {
|
|
133
|
+
this.clear();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Clear the queue state of all event values.
|
|
137
|
+
*/
|
|
138
|
+
clear() {
|
|
139
|
+
this.next = null;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Indicate if the queue is empty.
|
|
143
|
+
* @returns True if queue is empty, false otherwise.
|
|
144
|
+
*/
|
|
145
|
+
isEmpty() {
|
|
146
|
+
return !this.next;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Add a new value to the queue, and optionally filter the
|
|
150
|
+
* current queue content in response.
|
|
151
|
+
* @param value The value to add.
|
|
152
|
+
* @param filter An optional filter
|
|
153
|
+
* function to apply to existing queue content. If unspecified
|
|
154
|
+
* or falsy, all previously queued values are removed. Otherwise,
|
|
155
|
+
* the provided function is applied to all queue entries. The
|
|
156
|
+
* entry is retained if the filter function returns a truthy value,
|
|
157
|
+
* otherwise the entry is removed.
|
|
158
|
+
*/
|
|
159
|
+
enqueue(value, filter) {
|
|
160
|
+
const tail = { value };
|
|
161
|
+
if (filter && this.next) {
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
163
|
+
let curr = this;
|
|
164
|
+
while (curr.next) {
|
|
165
|
+
if (filter(curr.next.value)) {
|
|
166
|
+
curr = curr.next;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
curr.next = curr.next.next;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
curr.next = tail;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
this.next = tail;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Remove and return the next queued event value.
|
|
180
|
+
* @returns The next event value in the queue.
|
|
181
|
+
*/
|
|
182
|
+
dequeue() {
|
|
183
|
+
const { next } = this;
|
|
184
|
+
this.next = next?.next || null;
|
|
185
|
+
return next?.value;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=AsyncDispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncDispatch.js","sourceRoot":"","sources":["../../../src/util/AsyncDispatch.ts"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACxB,UAAU,CAAgC;IAE1C;;OAEG;IACH;QACE,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED;;;;;;OAMG;IACH,gBAAgB,CAAC,IAAY,EAAE,QAA0B;QACvD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE;gBACxB,SAAS,EAAE,IAAI,GAAG,EAAoB;gBACtC,OAAO,EAAE,IAAI;gBACb,KAAK,EAAE,IAAI,aAAa,EAAK;aAC9B,CAAC,CAAC;QACL,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;QACzC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,mBAAmB,CAAC,IAAY,EAAE,QAA0B;QAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,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AAC;YACN,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC;QAC/B,OAAO,IAAI,EAAE,KAAK,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Cache } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a new cache that ignores all values.
|
|
4
|
+
* @returns A void cache implementation.
|
|
5
|
+
*/
|
|
6
|
+
export declare function voidCache(): Cache;
|
|
7
|
+
/**
|
|
8
|
+
* Create a new cache that uses an LRU eviction policy.
|
|
9
|
+
* @param options Cache options.
|
|
10
|
+
* @param options.max Maximum number of cache entries.
|
|
11
|
+
* @param options.ttl Time-to-live for cache entries.
|
|
12
|
+
* @returns An LRU cache implementation.
|
|
13
|
+
*/
|
|
14
|
+
export declare function lruCache({ max, // max entries
|
|
15
|
+
ttl }?: {
|
|
16
|
+
max?: number;
|
|
17
|
+
ttl?: number;
|
|
18
|
+
}): Cache;
|
|
19
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/util/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAWzC;;;GAGG;AACH,wBAAgB,SAAS,IAAI,KAAK,CAMjC;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EACvB,GAAU,EAAE,cAAc;AAC1B,GAAwB,EACzB,GAAE;IACD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACT,GAAG,KAAK,CA8Cb"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const requestIdle = typeof requestIdleCallback !== 'undefined'
|
|
2
|
+
? requestIdleCallback
|
|
3
|
+
: setTimeout;
|
|
4
|
+
/**
|
|
5
|
+
* Create a new cache that ignores all values.
|
|
6
|
+
* @returns A void cache implementation.
|
|
7
|
+
*/
|
|
8
|
+
export function voidCache() {
|
|
9
|
+
return {
|
|
10
|
+
get: () => undefined,
|
|
11
|
+
set: (key, value) => value,
|
|
12
|
+
clear: () => { }
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a new cache that uses an LRU eviction policy.
|
|
17
|
+
* @param options Cache options.
|
|
18
|
+
* @param options.max Maximum number of cache entries.
|
|
19
|
+
* @param options.ttl Time-to-live for cache entries.
|
|
20
|
+
* @returns An LRU cache implementation.
|
|
21
|
+
*/
|
|
22
|
+
export function lruCache({ max = 1000, // max entries
|
|
23
|
+
ttl = 3 * 60 * 60 * 1000 // time-to-live, default 3 hours
|
|
24
|
+
} = {}) {
|
|
25
|
+
let cache = new Map();
|
|
26
|
+
function evict() {
|
|
27
|
+
const expire = performance.now() - ttl;
|
|
28
|
+
let lruKey = null;
|
|
29
|
+
let lruLast = Infinity;
|
|
30
|
+
for (const [key, value] of cache) {
|
|
31
|
+
const { last } = value;
|
|
32
|
+
// least recently used entry seen so far
|
|
33
|
+
if (last < lruLast) {
|
|
34
|
+
lruKey = key;
|
|
35
|
+
lruLast = last;
|
|
36
|
+
}
|
|
37
|
+
// remove if time since last access exceeds ttl
|
|
38
|
+
if (expire > last) {
|
|
39
|
+
cache.delete(key);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// remove lru entry
|
|
43
|
+
if (lruKey) {
|
|
44
|
+
cache.delete(lruKey);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
get(key) {
|
|
49
|
+
const entry = cache.get(key);
|
|
50
|
+
if (entry) {
|
|
51
|
+
entry.last = performance.now();
|
|
52
|
+
return entry.value;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
set(key, value) {
|
|
56
|
+
cache.set(key, { last: performance.now(), value });
|
|
57
|
+
if (cache.size > max)
|
|
58
|
+
requestIdle(evict);
|
|
59
|
+
return value;
|
|
60
|
+
},
|
|
61
|
+
clear() {
|
|
62
|
+
cache = new Map();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/util/cache.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAG,OAAO,mBAAmB,KAAK,WAAW;IAC5D,CAAC,CAAC,mBAAmB;IACrB,CAAC,CAAC,UAAU,CAAC;AAOf;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS;QACpB,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK;QAC1B,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;KAChB,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,EACvB,GAAG,GAAG,IAAI,EAAE,cAAc;AAC1B,GAAG,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,gCAAgC;KAIvD,EAAE;IACJ,IAAI,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;IAE1C,SAAS,KAAK;QACZ,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC;QACvC,IAAI,MAAM,GAAkB,IAAI,CAAC;QACjC,IAAI,OAAO,GAAG,QAAQ,CAAC;QAEvB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC;YACjC,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;YAEvB,wCAAwC;YACxC,IAAI,IAAI,GAAG,OAAO,EAAE,CAAC;gBACnB,MAAM,GAAG,GAAG,CAAC;gBACb,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;YAED,+CAA+C;YAC/C,IAAI,MAAM,GAAG,IAAI,EAAE,CAAC;gBAClB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QAED,mBAAmB;QACnB,IAAI,MAAM,EAAE,CAAC;YACX,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,CAAC,GAAW;YACb,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,KAAK,EAAE,CAAC;gBACV,KAAK,CAAC,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;gBAC/B,OAAO,KAAK,CAAC,KAAK,CAAC;YACrB,CAAC;QACH,CAAC;QACD,GAAG,CAAC,GAAW,EAAE,KAAc;YAC7B,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACnD,IAAI,KAAK,CAAC,IAAI,GAAG,GAAG;gBAAE,WAAW,CAAC,KAAK,CAAC,CAAC;YACzC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,KAAK;YACH,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExtractionOptions, Table } from '@uwdata/flechette';
|
|
2
|
+
/**
|
|
3
|
+
* Decode Arrow IPC bytes to a table instance.
|
|
4
|
+
* The default options map date and timestamp values to JS Date objects.
|
|
5
|
+
* @param data Arrow IPC bytes.
|
|
6
|
+
* @param options Arrow IPC extraction options.
|
|
7
|
+
* If unspecified, the default options will extract date and timestamp
|
|
8
|
+
* values to JS Date objects.
|
|
9
|
+
* @returns A table instance.
|
|
10
|
+
*/
|
|
11
|
+
export declare function decodeIPC(data: ArrayBuffer | Uint8Array, options?: ExtractionOptions): Table;
|
|
12
|
+
//# sourceMappingURL=decode-ipc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-ipc.d.ts","sourceRoot":"","sources":["../../../src/util/decode-ipc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAGlE;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,EAAE,OAAO,GAAE,iBAAqC,GAAG,KAAK,CAE/G"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
/** @import { ExtractionOptions, Table } from '@uwdata/flechette' */
|
|
2
1
|
import { tableFromIPC } from '@uwdata/flechette';
|
|
3
|
-
|
|
4
2
|
/**
|
|
5
3
|
* Decode Arrow IPC bytes to a table instance.
|
|
6
4
|
* The default options map date and timestamp values to JS Date objects.
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
5
|
+
* @param data Arrow IPC bytes.
|
|
6
|
+
* @param options Arrow IPC extraction options.
|
|
9
7
|
* If unspecified, the default options will extract date and timestamp
|
|
10
8
|
* values to JS Date objects.
|
|
11
|
-
* @returns
|
|
9
|
+
* @returns A table instance.
|
|
12
10
|
*/
|
|
13
11
|
export function decodeIPC(data, options = { useDate: true }) {
|
|
14
|
-
|
|
12
|
+
return tableFromIPC(data, options);
|
|
15
13
|
}
|
|
14
|
+
//# sourceMappingURL=decode-ipc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-ipc.js","sourceRoot":"","sources":["../../../src/util/decode-ipc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,IAA8B,EAAE,UAA6B,EAAE,OAAO,EAAE,IAAI,EAAE;IACtG,OAAO,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distinct.d.ts","sourceRoot":"","sources":["../../../src/util/distinct.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAKxD;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAMjE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function distinct(a, b) {
|
|
2
|
+
return a === b ? false
|
|
3
|
+
: a instanceof Date && b instanceof Date ? +a !== +b
|
|
4
|
+
: Array.isArray(a) && Array.isArray(b) ? distinctArray(a, b)
|
|
5
|
+
: true;
|
|
6
|
+
}
|
|
7
|
+
export function distinctArray(a, b) {
|
|
8
|
+
if (a.length !== b.length)
|
|
9
|
+
return true;
|
|
10
|
+
for (let i = 0; i < a.length; ++i) {
|
|
11
|
+
if (a[i] !== b[i])
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=distinct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distinct.js","sourceRoot":"","sources":["../../../src/util/distinct.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,CAAU,EAAE,CAAU;IAC7C,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;QACpB,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACpD,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC5D,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,CAAY,EAAE,CAAY;IACtD,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Coordinator } from '../Coordinator.js';
|
|
2
|
+
import type { FieldInfoRequest, FieldInfo } from '../types.js';
|
|
3
|
+
export declare const Count = "count";
|
|
4
|
+
export declare const Nulls = "nulls";
|
|
5
|
+
export declare const Max = "max";
|
|
6
|
+
export declare const Min = "min";
|
|
7
|
+
export declare const Distinct = "distinct";
|
|
8
|
+
export declare const Stats: {
|
|
9
|
+
Count: string;
|
|
10
|
+
Nulls: string;
|
|
11
|
+
Max: string;
|
|
12
|
+
Min: string;
|
|
13
|
+
Distinct: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Queries information about fields of a table.
|
|
17
|
+
* If the `fields` array contains a single field with the column set to '*',
|
|
18
|
+
* the function will retrieve and return the table information using `getTableInfo`.
|
|
19
|
+
* Otherwise, it will query individual field information using `getFieldInfo`
|
|
20
|
+
* for each field in the `fields` array.
|
|
21
|
+
* @param mc A Mosaic coordinator.
|
|
22
|
+
* @param fields Array of field information requests.
|
|
23
|
+
* @returns Promise resolving to array of field information.
|
|
24
|
+
*/
|
|
25
|
+
export declare function queryFieldInfo(mc: Coordinator, fields: FieldInfoRequest[]): Promise<FieldInfo[]>;
|
|
26
|
+
//# sourceMappingURL=field-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-info.d.ts","sourceRoot":"","sources":["../../../src/util/field-info.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAqC,MAAM,aAAa,CAAC;AAGlG,eAAO,MAAM,KAAK,UAAU,CAAC;AAC7B,eAAO,MAAM,KAAK,UAAU,CAAC;AAC7B,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB,eAAO,MAAM,QAAQ,aAAa,CAAC;AACnC,eAAO,MAAM,KAAK;;;;;;CAAuC,CAAC;AAqB1D;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAQtG"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Query, asTableRef, count, isAggregateExpression, isNode, isNull, max, min, sql } from '@uwdata/mosaic-sql';
|
|
2
|
+
import { jsType } from './js-type.js';
|
|
3
|
+
export const Count = 'count';
|
|
4
|
+
export const Nulls = 'nulls';
|
|
5
|
+
export const Max = 'max';
|
|
6
|
+
export const Min = 'min';
|
|
7
|
+
export const Distinct = 'distinct';
|
|
8
|
+
export const Stats = { Count, Nulls, Max, Min, Distinct };
|
|
9
|
+
const statMap = {
|
|
10
|
+
[Count]: count,
|
|
11
|
+
[Distinct]: column => count(column).distinct(),
|
|
12
|
+
[Max]: max,
|
|
13
|
+
[Min]: min,
|
|
14
|
+
[Nulls]: column => count().where(isNull(column))
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Get summary stats of the given column
|
|
18
|
+
* @param field Field information request
|
|
19
|
+
* @returns Query for field statistics
|
|
20
|
+
*/
|
|
21
|
+
function summarize({ table, column, stats }) {
|
|
22
|
+
return Query
|
|
23
|
+
.from(table)
|
|
24
|
+
.select(Array.from(stats, s => ({ [s]: statMap[s](column) })));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Queries information about fields of a table.
|
|
28
|
+
* If the `fields` array contains a single field with the column set to '*',
|
|
29
|
+
* the function will retrieve and return the table information using `getTableInfo`.
|
|
30
|
+
* Otherwise, it will query individual field information using `getFieldInfo`
|
|
31
|
+
* for each field in the `fields` array.
|
|
32
|
+
* @param mc A Mosaic coordinator.
|
|
33
|
+
* @param fields Array of field information requests.
|
|
34
|
+
* @returns Promise resolving to array of field information.
|
|
35
|
+
*/
|
|
36
|
+
export async function queryFieldInfo(mc, fields) {
|
|
37
|
+
if (fields.length === 1 && fields[0].column === '*') {
|
|
38
|
+
return getTableInfo(mc, fields[0].table);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return (await Promise
|
|
42
|
+
.all(fields.map(f => getFieldInfo(mc, f))))
|
|
43
|
+
.filter((x) => x !== undefined);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get information about a single field of a table.
|
|
48
|
+
* @param mc A Mosaic coordinator.
|
|
49
|
+
* @param field Field information request.
|
|
50
|
+
* @returns Promise resolving to field information.
|
|
51
|
+
*/
|
|
52
|
+
async function getFieldInfo(mc, { table, column, stats }) {
|
|
53
|
+
// generate and issue a query for field metadata info
|
|
54
|
+
// use GROUP BY ALL to differentiate & consolidate aggregates
|
|
55
|
+
const q = Query
|
|
56
|
+
.from({ source: table })
|
|
57
|
+
.select({ column })
|
|
58
|
+
.groupby(isNode(column) && isAggregateExpression(column) ? sql `ALL` : []);
|
|
59
|
+
const [desc] = Array.from(await mc.query(Query.describe(q)));
|
|
60
|
+
const info = {
|
|
61
|
+
table,
|
|
62
|
+
column: `${column}`,
|
|
63
|
+
sqlType: desc.column_type,
|
|
64
|
+
type: jsType(desc.column_type),
|
|
65
|
+
nullable: desc.null === 'YES'
|
|
66
|
+
};
|
|
67
|
+
// no need for summary statistics
|
|
68
|
+
if (!stats?.length)
|
|
69
|
+
return info;
|
|
70
|
+
// query for summary stats
|
|
71
|
+
const [result] = await mc.query(summarize({ table, column, stats }), { persist: true });
|
|
72
|
+
// extract summary stats, copy to field info, and return
|
|
73
|
+
return Object.assign(info, result);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get information about the fields of a table.
|
|
77
|
+
* @param mc A Mosaic coordinator.
|
|
78
|
+
* @param table The table name.
|
|
79
|
+
* @returns Promise resolving to array of field information.
|
|
80
|
+
*/
|
|
81
|
+
async function getTableInfo(mc, table) {
|
|
82
|
+
const result = Array.from(await mc.query(`DESCRIBE ${asTableRef(table)}`));
|
|
83
|
+
return result.map(desc => ({
|
|
84
|
+
table,
|
|
85
|
+
column: desc.column_name,
|
|
86
|
+
sqlType: desc.column_type,
|
|
87
|
+
type: jsType(desc.column_type),
|
|
88
|
+
nullable: desc.null === 'YES'
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=field-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-info.js","sourceRoot":"","sources":["../../../src/util/field-info.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACpH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC;AAC7B,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC;AAC7B,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;AACzB,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;AACzB,MAAM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AAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,YAAY,CAAC,EAAe,EAAE,KAAa;IACxD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CACvB,MAAM,EAAE,CAAC,KAAK,CAAC,YAAY,UAAU,CAAC,KAAK,CAAC,EAAE,CAAU,CAClC,CAAC;IACzB,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,KAAK;QACL,MAAM,EAAE,IAAI,CAAC,WAAW;QACxB,OAAO,EAAE,IAAI,CAAC,WAAW;QACzB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;QAC9B,QAAQ,EAAE,IAAI,CAAC,IAAI,KAAK,KAAK;KAC9B,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/util/hash.ts"],"names":[],"mappings":"AACA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAS1C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Fowler/Noll/Vo hashing.
|
|
2
|
+
export function fnv_hash(v) {
|
|
3
|
+
let a = 2166136261;
|
|
4
|
+
for (let i = 0, n = v.length; i < n; ++i) {
|
|
5
|
+
const c = v.charCodeAt(i);
|
|
6
|
+
const d = c & 0xff00;
|
|
7
|
+
if (d)
|
|
8
|
+
a = fnv_multiply(a ^ d >> 8);
|
|
9
|
+
a = fnv_multiply(a ^ c & 0xff);
|
|
10
|
+
}
|
|
11
|
+
return fnv_mix(a) >>> 0; // ensure non-zero value
|
|
12
|
+
}
|
|
13
|
+
// a * 16777619 mod 2**32
|
|
14
|
+
function fnv_multiply(a) {
|
|
15
|
+
return a + (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24);
|
|
16
|
+
}
|
|
17
|
+
// See https://web.archive.org/web/20131019013225/http://home.comcast.net/~bretm/hash/6.html
|
|
18
|
+
function fnv_mix(a) {
|
|
19
|
+
a += a << 13;
|
|
20
|
+
a ^= a >>> 7;
|
|
21
|
+
a += a << 3;
|
|
22
|
+
a ^= a >>> 17;
|
|
23
|
+
a += a << 5;
|
|
24
|
+
return a & 0xffffffff;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../../src/util/hash.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,IAAI,CAAC,GAAG,UAAU,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;QACzC,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC;YAAE,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,wBAAwB;AACnD,CAAC;AAED,yBAAyB;AACzB,SAAS,YAAY,CAAC,CAAS;IAC7B,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,4FAA4F;AAC5F,SA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