@uwdata/mosaic-core 0.11.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.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/dist/mosaic-core.js +11612 -10855
  3. package/dist/mosaic-core.min.js +7 -7
  4. package/dist/types/Coordinator.d.ts +169 -0
  5. package/dist/types/MosaicClient.d.ts +94 -0
  6. package/dist/types/Param.d.ts +47 -0
  7. package/dist/types/QueryConsolidator.d.ts +9 -0
  8. package/dist/types/QueryManager.d.ts +64 -0
  9. package/dist/types/Selection.d.ts +224 -0
  10. package/dist/types/SelectionClause.d.ts +105 -0
  11. package/dist/types/connectors/rest.d.ts +17 -0
  12. package/dist/types/connectors/socket.d.ts +18 -0
  13. package/dist/types/connectors/wasm.d.ts +16 -0
  14. package/dist/types/index.d.ts +25 -0
  15. package/dist/types/preagg/PreAggregator.d.ts +178 -0
  16. package/dist/types/preagg/preagg-columns.d.ts +14 -0
  17. package/dist/types/preagg/sufficient-statistics.d.ts +13 -0
  18. package/dist/types/util/AsyncDispatch.d.ts +100 -0
  19. package/dist/types/util/cache.d.ts +13 -0
  20. package/dist/types/util/decode-ipc.d.ts +7 -0
  21. package/dist/types/util/distinct.d.ts +2 -0
  22. package/dist/types/util/field-info.d.ts +13 -0
  23. package/dist/types/util/hash.d.ts +1 -0
  24. package/dist/types/util/is-arrow-table.d.ts +8 -0
  25. package/dist/types/util/js-type.d.ts +1 -0
  26. package/dist/types/util/priority-queue.d.ts +37 -0
  27. package/dist/types/util/query-result.d.ts +44 -0
  28. package/dist/types/util/selection-types.d.ts +114 -0
  29. package/dist/types/util/synchronizer.d.ts +29 -0
  30. package/dist/types/util/throttle.d.ts +11 -0
  31. package/dist/types/util/to-data-columns.d.ts +29 -0
  32. package/dist/types/util/void-logger.d.ts +7 -0
  33. package/jsconfig.json +11 -0
  34. package/package.json +10 -8
  35. package/src/Coordinator.js +14 -14
  36. package/src/MosaicClient.js +5 -4
  37. package/src/QueryConsolidator.js +22 -33
  38. package/src/QueryManager.js +76 -45
  39. package/src/Selection.js +8 -5
  40. package/src/SelectionClause.js +19 -22
  41. package/src/connectors/rest.js +3 -1
  42. package/src/connectors/socket.js +3 -1
  43. package/src/connectors/wasm.js +1 -1
  44. package/src/index.js +13 -0
  45. package/src/preagg/PreAggregator.js +407 -0
  46. package/src/preagg/preagg-columns.js +103 -0
  47. package/src/preagg/sufficient-statistics.js +439 -0
  48. package/src/util/field-info.js +16 -5
  49. package/src/util/hash.js +1 -1
  50. package/src/util/query-result.js +44 -2
  51. package/src/util/selection-types.ts +3 -3
  52. package/src/util/throttle.js +11 -9
  53. package/src/util/void-logger.js +6 -5
  54. package/tsconfig.json +11 -0
  55. package/src/DataCubeIndexer.js +0 -378
  56. package/src/util/index-columns.js +0 -537
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @typedef {import('./util/selection-types.js').SelectionClause} SelectionClause
3
+ * @typedef {import('./util/selection-types.js').Scale} Scale
4
+ * @typedef {import('./util/selection-types.js').Extent} Extent
5
+ * @typedef {import('./util/selection-types.js').MatchMethod} MatchMethod
6
+ * @typedef {import('./util/selection-types.js').BinMethod} BinMethod
7
+ */
8
+ /**
9
+ * Generate a selection clause for a single selected point value.
10
+ * @param {import('@uwdata/mosaic-sql').ExprValue} field The table column or expression to select.
11
+ * @param {*} value The selected value.
12
+ * @param {object} options Additional clause properties.
13
+ * @param {*} options.source The source component generating this clause.
14
+ * @param {Set<MosaicClient>} [options.clients] The Mosaic clients associated
15
+ * with this clause. These clients are not filtered by this clause in
16
+ * cross-filtering contexts.
17
+ * @returns {SelectionClause} The generated selection clause.
18
+ */
19
+ export function clausePoint(field: import("@uwdata/mosaic-sql").ExprValue, value: any, { source, clients }: {
20
+ source: any;
21
+ clients?: Set<MosaicClient>;
22
+ }): SelectionClause;
23
+ /**
24
+ * Generate a selection clause for multiple selected point values.
25
+ * @param {import('@uwdata/mosaic-sql').ExprValue[]} fields The table columns or expressions to select.
26
+ * @param {any[][] | undefined} value The selected values, as an array of
27
+ * arrays. Each subarray contains values for each *fields* entry.
28
+ * @param {object} options Additional clause properties.
29
+ * @param {*} options.source The source component generating this clause.
30
+ * @param {Set<MosaicClient>} [options.clients] The Mosaic clients associated
31
+ * with this clause. These clients are not filtered by this clause in
32
+ * cross-filtering contexts.
33
+ * @returns {SelectionClause} The generated selection clause.
34
+ */
35
+ export function clausePoints(fields: import("@uwdata/mosaic-sql").ExprValue[], value: any[][] | undefined, { source, clients }: {
36
+ source: any;
37
+ clients?: Set<MosaicClient>;
38
+ }): SelectionClause;
39
+ /**
40
+ * Generate a selection clause for a selected 1D interval.
41
+ * @param {import('@uwdata/mosaic-sql').ExprValue} field The table column or expression to select.
42
+ * @param {Extent} value The selected interval as a [lo, hi] array.
43
+ * @param {object} options Additional clause properties.
44
+ * @param {*} options.source The source component generating this clause.
45
+ * @param {Set<MosaicClient>} [options.clients] The Mosaic clients associated
46
+ * with this clause. These clients are not filtered by this clause in
47
+ * cross-filtering contexts.
48
+ * @param {Scale} [options.scale] The scale mapping descriptor.
49
+ * @param {BinMethod} [options.bin] A binning method hint.
50
+ * @param {number} [options.pixelSize=1] The interactive pixel size.
51
+ * @returns {SelectionClause} The generated selection clause.
52
+ */
53
+ export function clauseInterval(field: import("@uwdata/mosaic-sql").ExprValue, value: Extent, { source, clients, bin, scale, pixelSize }: {
54
+ source: any;
55
+ clients?: Set<MosaicClient>;
56
+ scale?: Scale;
57
+ bin?: BinMethod;
58
+ pixelSize?: number;
59
+ }): SelectionClause;
60
+ /**
61
+ * Generate a selection clause for multiple selected intervals.
62
+ * @param {import('@uwdata/mosaic-sql').ExprValue[]} fields The table columns or expressions to select.
63
+ * @param {Extent[]} value The selected intervals, as an array of extents.
64
+ * @param {object} options Additional clause properties.
65
+ * @param {*} options.source The source component generating this clause.
66
+ * @param {Set<MosaicClient>} [options.clients] The Mosaic clients associated
67
+ * with this clause. These clients are not filtered by this clause in
68
+ * cross-filtering contexts.
69
+ * @param {Scale[]} [options.scales] The scale mapping descriptors,
70
+ * in an order matching the given *fields* and *value* extents.
71
+ * @param {BinMethod} [options.bin] A binning method hint.
72
+ * @param {number} [options.pixelSize=1] The interactive pixel size.
73
+ * @returns {SelectionClause} The generated selection clause.
74
+ */
75
+ export function clauseIntervals(fields: import("@uwdata/mosaic-sql").ExprValue[], value: Extent[], { source, clients, bin, scales, pixelSize }: {
76
+ source: any;
77
+ clients?: Set<MosaicClient>;
78
+ scales?: Scale[];
79
+ bin?: BinMethod;
80
+ pixelSize?: number;
81
+ }): SelectionClause;
82
+ /**
83
+ * Generate a selection clause for text search matching.
84
+ * @param {import('@uwdata/mosaic-sql').ExprValue} field The table column or expression to select.
85
+ * @param {string} value The selected text search query string.
86
+ * @param {object} options Additional clause properties.
87
+ * @param {*} options.source The source component generating this clause.
88
+ * @param {Set<MosaicClient>} [options.clients] The Mosaic clients associated
89
+ * with this clause. These clients are not filtered by this clause in
90
+ * cross-filtering contexts.
91
+ * @param {MatchMethod} [options.method] The
92
+ * text matching method to use. Defaults to `'contains'`.
93
+ * @returns {SelectionClause} The generated selection clause.
94
+ */
95
+ export function clauseMatch(field: import("@uwdata/mosaic-sql").ExprValue, value: string, { source, clients, method }: {
96
+ source: any;
97
+ clients?: Set<MosaicClient>;
98
+ method?: MatchMethod;
99
+ }): SelectionClause;
100
+ export type SelectionClause = import("./util/selection-types.js").SelectionClause;
101
+ export type Scale = import("./util/selection-types.js").Scale;
102
+ export type Extent = import("./util/selection-types.js").Extent;
103
+ export type MatchMethod = import("./util/selection-types.js").MatchMethod;
104
+ export type BinMethod = import("./util/selection-types.js").BinMethod;
105
+ import { MosaicClient } from './MosaicClient.js';
@@ -0,0 +1,17 @@
1
+ export function restConnector(uri?: string): {
2
+ /**
3
+ * Query the DuckDB server.
4
+ * @param {object} query
5
+ * @param {'exec' | 'arrow' | 'json' | 'create-bundle' | 'load-bundle'} [query.type] The query type.
6
+ * @param {string} [query.sql] A SQL query string.
7
+ * @param {string[]} [query.queries] The queries used to create a bundle.
8
+ * @param {string} [query.name] The name of a bundle to create or load.
9
+ * @returns the query result
10
+ */
11
+ query(query: {
12
+ type?: "exec" | "arrow" | "json" | "create-bundle" | "load-bundle";
13
+ sql?: string;
14
+ queries?: string[];
15
+ name?: string;
16
+ }): Promise<any>;
17
+ };
@@ -0,0 +1,18 @@
1
+ export function socketConnector(uri?: string): {
2
+ readonly connected: boolean;
3
+ /**
4
+ * Query the DuckDB server.
5
+ * @param {object} query
6
+ * @param {'exec' | 'arrow' | 'json' | 'create-bundle' | 'load-bundle'} [query.type] The query type.
7
+ * @param {string} [query.sql] A SQL query string.
8
+ * @param {string[]} [query.queries] The queries used to create a bundle.
9
+ * @param {string} [query.name] The name of a bundle to create or load.
10
+ * @returns the query result
11
+ */
12
+ query(query: {
13
+ type?: "exec" | "arrow" | "json" | "create-bundle" | "load-bundle";
14
+ sql?: string;
15
+ queries?: string[];
16
+ name?: string;
17
+ }): Promise<any>;
18
+ };
@@ -0,0 +1,16 @@
1
+ export function wasmConnector(options?: {}): {
2
+ getDuckDB: () => Promise<duckdb.AsyncDuckDB>;
3
+ getConnection: () => Promise<duckdb.AsyncDuckDBConnection>;
4
+ /**
5
+ * Query the DuckDB-WASM instance.
6
+ * @param {object} query
7
+ * @param {'exec' | 'arrow' | 'json'} [query.type] The query type.
8
+ * @param {string} query.sql A SQL query string.
9
+ * @returns the query result
10
+ */
11
+ query: (query: {
12
+ type?: "exec" | "arrow" | "json";
13
+ sql: string;
14
+ }) => Promise<import("@uwdata/flechette").Table | Record<string, any>[]>;
15
+ };
16
+ import * as duckdb from '@duckdb/duckdb-wasm';
@@ -0,0 +1,25 @@
1
+ export { MosaicClient } from "./MosaicClient.js";
2
+ export { Priority } from "./QueryManager.js";
3
+ export { restConnector } from "./connectors/rest.js";
4
+ export { socketConnector } from "./connectors/socket.js";
5
+ export { wasmConnector } from "./connectors/wasm.js";
6
+ export { decodeIPC } from "./util/decode-ipc.js";
7
+ export { distinct } from "./util/distinct.js";
8
+ export { isArrowTable } from "./util/is-arrow-table.js";
9
+ export { synchronizer } from "./util/synchronizer.js";
10
+ export { throttle } from "./util/throttle.js";
11
+ export { toDataColumns } from "./util/to-data-columns.js";
12
+ export type ClauseMetadata = import("./util/selection-types.js").ClauseMetadata;
13
+ export type PointMetadata = import("./util/selection-types.js").PointMetadata;
14
+ export type MatchMethod = import("./util/selection-types.js").MatchMethod;
15
+ export type MatchMetadata = import("./util/selection-types.js").MatchMetadata;
16
+ export type ScaleType = import("./util/selection-types.js").ScaleType;
17
+ export type Extent = import("./util/selection-types.js").Extent;
18
+ export type Scale = import("./util/selection-types.js").Scale;
19
+ export type BinMethod = import("./util/selection-types.js").BinMethod;
20
+ export type IntervalMetadata = import("./util/selection-types.js").IntervalMetadata;
21
+ export type SelectionClause = import("./util/selection-types.js").SelectionClause;
22
+ export { Coordinator, coordinator } from "./Coordinator.js";
23
+ export { Selection, isSelection } from "./Selection.js";
24
+ export { Param, isParam } from "./Param.js";
25
+ export { clauseInterval, clauseIntervals, clausePoint, clausePoints, clauseMatch } from "./SelectionClause.js";
@@ -0,0 +1,178 @@
1
+ /**
2
+ * @typedef {object} PreAggregateOptions
3
+ * @property {string} [schema] Database schema (namespace) in which to write
4
+ * pre-aggregated materialzied views (default 'mosaic').
5
+ * @property {boolean} [options.enabled=true] Flag to enable or disable the
6
+ * pre-aggregation. This flag can be updated later via the `enabled` property.
7
+ */
8
+ /**
9
+ * Build and query optimized pre-aggregated materaialized views, for fast
10
+ * computation of groupby aggregate queries over compatible client queries
11
+ * and selections. The materialized views contains pre-aggregated data for a
12
+ * Mosaic client, subdivided by possible query values from an active selection
13
+ * clause. These materialized views are database tables that can be queried
14
+ * for rapid updates.
15
+ *
16
+ * Compatible client queries must consist of only groupby dimensions and
17
+ * supported aggregate functions. Compatible selections must contain an active
18
+ * clause that exposes metadata for an interval or point value predicate.
19
+ *
20
+ * Materialized views are written to a dedicated schema (namespace) that
21
+ * can be set using the *schema* constructor option. This schema acts as a
22
+ * persistent cache, and materialized view tables may be used across sessions.
23
+ * The `dropSchema` method issues a query to remove *all* tables within this
24
+ * schema. This may be needed if the original tables have updated data, but
25
+ * should be used with care.
26
+ */
27
+ export class PreAggregator {
28
+ /**
29
+ * Create a new manager of materialized views of pre-aggregated data.
30
+ * @param {import('../Coordinator.js').Coordinator} coordinator A Mosaic coordinator.
31
+ * @param {PreAggregateOptions} [options] Pre-aggregation options.
32
+ */
33
+ constructor(coordinator: import("../Coordinator.js").Coordinator, { schema, enabled }?: PreAggregateOptions);
34
+ /** @type {Map<import('../MosaicClient.js').MosaicClient, PreAggregateInfo | Skip | null>} */
35
+ entries: Map<import("../MosaicClient.js").MosaicClient, PreAggregateInfo | {
36
+ skip: boolean;
37
+ result: any;
38
+ } | null>;
39
+ active: any;
40
+ mc: import("../Coordinator.js").Coordinator;
41
+ _schema: string;
42
+ _enabled: boolean;
43
+ /**
44
+ * Set the enabled state of this manager. If false, any local state is
45
+ * cleared and subsequent request calls will return null until re-enabled.
46
+ * This method has no effect on any pre-aggregated tables already in the
47
+ * database.
48
+ * @param {boolean} [state] The enabled state to set.
49
+ */
50
+ set enabled(state: boolean);
51
+ /**
52
+ * Get the enabled state of this manager.
53
+ * @returns {boolean} The current enabled state.
54
+ */
55
+ get enabled(): boolean;
56
+ /**
57
+ * Set the database schema used for pre-aggregated materialized view tables.
58
+ * Upon changes, any local state is cleared. This method does _not_ drop any
59
+ * existing materialized views, use `dropSchema` before changing the schema
60
+ * to also remove existing materalized views in the database.
61
+ * @param {string} [schema] The schema name to set.
62
+ */
63
+ set schema(schema: string);
64
+ /**
65
+ * Get the database schema used for pre-aggregated materialized view tables.
66
+ * @returns {string} The current schema name.
67
+ */
68
+ get schema(): string;
69
+ /**
70
+ * Issues a query through the coordinator to drop the current schema for
71
+ * pre-aggregated materialized views. *All* materialized view tables in the
72
+ * schema will be removed and local state is cleared. Call this method if
73
+ * the underlying base tables have been updated, causing materialized view
74
+ * to become stale and inaccurate. Use this method with care! Once dropped,
75
+ * the schema will be repopulated by future pre-aggregation requests.
76
+ * @returns A query result promise.
77
+ */
78
+ dropSchema(): import("../util/query-result.js").QueryResult;
79
+ /**
80
+ * Clear the cache of pre-aggregation entries for the current active
81
+ * selection clause. This method does _not_ drop any existing materialized
82
+ * views. Use `dropSchema` to remove existing materialized view tables from
83
+ * the database.
84
+ */
85
+ clear(): void;
86
+ /**
87
+ * Return pre-aggregation information for the active state of a
88
+ * client-selection pair, or null if the client has unstable filters.
89
+ * This method has multiple possible side effects, including materialized
90
+ * view creation and updating internal caches.
91
+ * @param {import('../MosaicClient.js').MosaicClient} client A Mosaic client.
92
+ * @param {import('../Selection.js').Selection} selection A Mosaic selection
93
+ * to filter the client by.
94
+ * @param {import('../util/selection-types.js').SelectionClause} activeClause
95
+ * A representative active selection clause for which to (possibly) generate
96
+ * materialized views of pre-aggregates.
97
+ * @returns {PreAggregateInfo | Skip | null} Information and query generator
98
+ * for pre-aggregated tables, or null if the client has unstable filters.
99
+ */
100
+ request(client: import("../MosaicClient.js").MosaicClient, selection: import("../Selection.js").Selection, activeClause: import("../util/selection-types.js").SelectionClause): PreAggregateInfo | {
101
+ skip: boolean;
102
+ result: any;
103
+ } | null;
104
+ }
105
+ /**
106
+ * Metadata and query generator for materialized views of pre-aggregated data.
107
+ * This object provides the information needed to generate and query the
108
+ * materialized views for a client-selection pair relative to a specific
109
+ * active clause and selection state.
110
+ */
111
+ export class PreAggregateInfo {
112
+ /**
113
+ * Create a new pre-aggregation information instance.
114
+ * @param {object} options Options object.
115
+ * @param {string} options.table The materialized view table name.
116
+ * @param {string} options.create The table creation query.
117
+ * @param {*} options.active Active column information.
118
+ * @param {SelectQuery} options.select Base query for requesting updates
119
+ * using a pre-aggregated materialized view.
120
+ */
121
+ constructor({ table, create, active, select }: {
122
+ table: string;
123
+ create: string;
124
+ active: any;
125
+ select: SelectQuery;
126
+ });
127
+ /**
128
+ * The name of the materialized view.
129
+ * @type {string}
130
+ */
131
+ table: string;
132
+ /**
133
+ * The SQL query used to generate the materialized view.
134
+ * @type {string}
135
+ */
136
+ create: string;
137
+ /**
138
+ * A result promise returned for the materialized view creation query.
139
+ * @type {Promise | null}
140
+ */
141
+ result: Promise<any> | null;
142
+ /**
143
+ * Definitions and predicate function for the active columns,
144
+ * which are dynamically filtered by the active clause.
145
+ */
146
+ active: any;
147
+ /**
148
+ * Select query (sans where clause) for materialized views.
149
+ * @type {SelectQuery}
150
+ */
151
+ select: SelectQuery;
152
+ /**
153
+ * Boolean flag indicating a client that should be skipped.
154
+ * This value is always false for a created materialized view.
155
+ * @type {boolean}
156
+ */
157
+ skip: boolean;
158
+ /**
159
+ * Generate a materialized view query for the given predicate.
160
+ * @param {import('@uwdata/mosaic-sql').ExprNode} predicate The current
161
+ * active clause predicate.
162
+ * @returns {SelectQuery} A materialized view query.
163
+ */
164
+ query(predicate: import("@uwdata/mosaic-sql").ExprNode): SelectQuery;
165
+ }
166
+ export type PreAggregateOptions = {
167
+ /**
168
+ * Database schema (namespace) in which to write
169
+ * pre-aggregated materialzied views (default 'mosaic').
170
+ */
171
+ schema?: string;
172
+ /**
173
+ * Flag to enable or disable the
174
+ * pre-aggregation. This flag can be updated later via the `enabled` property.
175
+ */
176
+ enabled?: boolean;
177
+ };
178
+ import { SelectQuery } from '@uwdata/mosaic-sql';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Determine pre-aggregation columns for a given Mosaic client.
3
+ * @param {MosaicClient} client The Mosaic client.
4
+ * @returns An object with necessary column data to generate pre-aggregated
5
+ * columns, or null if the client can't be optimized or the client query
6
+ * contains an invalid or unsupported expression.
7
+ */
8
+ export function preaggColumns(client: MosaicClient): {
9
+ group: string[];
10
+ preagg: Record<string, ExprNode>;
11
+ output: Record<string, ExprNode>;
12
+ };
13
+ import { MosaicClient } from '../MosaicClient.js';
14
+ import { ExprNode } from '@uwdata/mosaic-sql';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Determine sufficient statistics to preaggregate the given node. This
3
+ * method populates the *preagg* and *aggrs* arguments with necessary
4
+ * information for preaggregation optimization.
5
+ * @param {AggregateNode} node An aggregate function.
6
+ * @param {Record<string, ExprNode>} preagg Map of column names to
7
+ * expressions to include in the preaggregation table.
8
+ * @returns {ExprNode} Output aggregate expression that uses preaggregated
9
+ * sufficient statistics to service updates.
10
+ */
11
+ export function sufficientStatistics(node: AggregateNode, preagg: Record<string, ExprNode>, avg: any): ExprNode;
12
+ import { AggregateNode } from '@uwdata/mosaic-sql';
13
+ import { ExprNode } from '@uwdata/mosaic-sql';
@@ -0,0 +1,100 @@
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: Map<any, any>;
8
+ /**
9
+ * Add an event listener callback for the provided event type.
10
+ * @param {string} type The event type.
11
+ * @param {(value: *) => void | Promise} callback The event handler
12
+ * callback function to add. If the callback has already been
13
+ * added for the event type, this method has no effect.
14
+ */
15
+ addEventListener(type: string, callback: (value: any) => void | Promise<any>): void;
16
+ /**
17
+ * Remove an event listener callback for the provided event type.
18
+ * @param {string} type The event type.
19
+ * @param {(value: *) => void | Promise} callback The event handler
20
+ * callback function to remove.
21
+ */
22
+ removeEventListener(type: string, callback: (value: any) => void | Promise<any>): void;
23
+ /**
24
+ * Lifecycle method that returns the event value to emit.
25
+ * This default implementation simply returns the input value as-is.
26
+ * Subclasses may override this method to implement custom transformations
27
+ * prior to emitting an event value to all listeners.
28
+ * @param {string} type The event type.
29
+ * @param {*} value The event value.
30
+ * @returns The (possibly transformed) event value to emit.
31
+ */
32
+ willEmit(type: string, value: any): any;
33
+ /**
34
+ * Lifecycle method that returns a filter function for updating the
35
+ * queue of unemitted event values prior to enqueueing a new value.
36
+ * This default implementation simply returns null, indicating that
37
+ * any other unemitted event values should be dropped (that is, all
38
+ * queued events are filtered).
39
+ * @param {string} type The event type.
40
+ * @param {*} value The new event value that will be enqueued.
41
+ * @returns {(value: *) => boolean|null} A dispatch queue filter
42
+ * function, or null if all unemitted event values should be filtered.
43
+ */
44
+ emitQueueFilter(type: string, value: any): (value: any) => boolean | null;
45
+ /**
46
+ * Cancel all unemitted event values for the given event type.
47
+ * @param {string} type The event type.
48
+ */
49
+ cancel(type: string): void;
50
+ /**
51
+ * Returns a promise that resolves when any pending updates complete for
52
+ * the event of the given type currently being processed. The Promise will
53
+ * resolve immediately if the queue for the given event type is empty.
54
+ * @param {string} type The event type to wait for.
55
+ * @returns {Promise} A pending event promise.
56
+ */
57
+ pending(type: string): Promise<any>;
58
+ /**
59
+ * Emit an event value to listeners for the given event type.
60
+ * If a previous emit has not yet resolved, the event value
61
+ * will be queued to be emitted later.
62
+ * The actual event value given to listeners will be the result
63
+ * of passing the input value through the emitValue() method.
64
+ * @param {string} type The event type.
65
+ * @param {*} value The event value.
66
+ */
67
+ emit(type: string, value: any): void;
68
+ }
69
+ /**
70
+ * Queue for managing unemitted event values.
71
+ */
72
+ export class DispatchQueue {
73
+ /**
74
+ * Clear the queue state of all event values.
75
+ */
76
+ clear(): void;
77
+ next: any;
78
+ /**
79
+ * Indicate if the queue is empty.
80
+ * @returns {boolean} True if queue is empty, false otherwise.
81
+ */
82
+ isEmpty(): boolean;
83
+ /**
84
+ * Add a new value to the queue, and optionally filter the
85
+ * current queue content in response.
86
+ * @param {*} value The value to add.
87
+ * @param {(value: *) => boolean} [filter] An optional filter
88
+ * function to apply to existing queue content. If unspecified
89
+ * or falsy, all previously queued values are removed. Otherwise,
90
+ * the provided function is applied to all queue entries. The
91
+ * entry is retained if the filter function returns a truthy value,
92
+ * otherwise the entry is removed.
93
+ */
94
+ enqueue(value: any, filter?: (value: any) => boolean): void;
95
+ /**
96
+ * Remove and return the next queued event value.
97
+ * @returns {*} The next event value in the queue.
98
+ */
99
+ dequeue(): any;
100
+ }
@@ -0,0 +1,13 @@
1
+ export function lruCache({ max, ttl }?: {
2
+ max?: number;
3
+ ttl?: number;
4
+ }): {
5
+ get(key: any): any;
6
+ set(key: any, value: any): any;
7
+ clear(): void;
8
+ };
9
+ export function voidCache(): {
10
+ get: () => any;
11
+ set: (key: any, value: any) => any;
12
+ clear: () => void;
13
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Decode Arrow IPC bytes to a table instance, with an option to map date and
3
+ * timestamp values to JS Date objects.
4
+ * @param {ArrayBuffer | Uint8Array} data Arrow IPC bytes.
5
+ * @returns {import('@uwdata/flechette').Table} A table instance.
6
+ */
7
+ export function decodeIPC(data: ArrayBuffer | Uint8Array): import("@uwdata/flechette").Table;
@@ -0,0 +1,2 @@
1
+ export function distinct(a: any, b: any): boolean;
2
+ export function distinctArray(a: any, b: any): boolean;
@@ -0,0 +1,13 @@
1
+ export function queryFieldInfo(mc: any, fields: any): Promise<any[]>;
2
+ export const Count: "count";
3
+ export const Nulls: "nulls";
4
+ export const Max: "max";
5
+ export const Min: "min";
6
+ export const Distinct: "distinct";
7
+ export namespace Stats {
8
+ export { Count };
9
+ export { Nulls };
10
+ export { Max };
11
+ export { Min };
12
+ export { Distinct };
13
+ }
@@ -0,0 +1 @@
1
+ export function fnv_hash(v: any): number;
@@ -0,0 +1,8 @@
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: any): values is import("@uwdata/flechette").Table;
@@ -0,0 +1 @@
1
+ export function jsType(type: any): "string" | "number" | "date" | "boolean" | "array" | "object";
@@ -0,0 +1,37 @@
1
+ export class PriorityQueue {
2
+ /**
3
+ * Create a new priority queue instance.
4
+ * @param {number} ranks An integer number of rank-order priority levels.
5
+ */
6
+ constructor(ranks: number);
7
+ queue: {
8
+ head: any;
9
+ tail: any;
10
+ }[];
11
+ /**
12
+ * Indicate if the queue is empty.
13
+ * @returns {boolean} true if empty, false otherwise.
14
+ */
15
+ isEmpty(): boolean;
16
+ /**
17
+ * Insert an item into the queue with a given priority rank.
18
+ * @param {*} item The item to add.
19
+ * @param {number} rank The integer priority rank.
20
+ * Priority ranks are integers starting at zero.
21
+ * Lower ranks indicate higher priority.
22
+ */
23
+ insert(item: any, rank: number): void;
24
+ /**
25
+ * Remove a set of items from the queue, regardless of priority rank.
26
+ * If a provided item is not in the queue it will be ignored.
27
+ * @param {(item: *) => boolean} test A predicate function to test
28
+ * if an item should be removed (true to drop, false to keep).
29
+ */
30
+ remove(test: (item: any) => boolean): void;
31
+ /**
32
+ * Remove and return the next highest priority item.
33
+ * @returns {*} The next item in the queue,
34
+ * or undefined if this queue is empty.
35
+ */
36
+ next(): any;
37
+ }
@@ -0,0 +1,44 @@
1
+ export const QueryState: Readonly<{
2
+ pending: symbol;
3
+ ready: symbol;
4
+ error: symbol;
5
+ done: symbol;
6
+ }>;
7
+ /**
8
+ * A query result Promise that can allows external callers
9
+ * to resolve or reject the Promise.
10
+ */
11
+ export class QueryResult extends Promise<any> {
12
+ /**
13
+ * Create a new query result Promise.
14
+ */
15
+ constructor();
16
+ _resolve: any;
17
+ _reject: any;
18
+ _state: symbol;
19
+ _value: any;
20
+ /**
21
+ * Resolve the result Promise with a prepared value or the provided value.
22
+ * This method will only succeed if either a value is provided or the promise is ready.
23
+ * @param {*} value The result value.
24
+ * @returns {this}
25
+ */
26
+ fulfill(value: any): this;
27
+ /**
28
+ * Prepare to resolve with the provided value.
29
+ * @param {*} value The result value.
30
+ * @returns {this}
31
+ */
32
+ ready(value: any): this;
33
+ /**
34
+ * Rejects the result Promise with the provided error.
35
+ * @param {*} error The error value.
36
+ * @returns {this}
37
+ */
38
+ reject(error: any): this;
39
+ /**
40
+ * Returns the state of this query result.
41
+ * @returns {symbol}
42
+ */
43
+ get state(): symbol;
44
+ }