import { type Connector } from './connectors/Connector.js'; import { PreAggregator, type PreAggregateOptions } from './preagg/PreAggregator.js'; import { QueryManager } from './QueryManager.js'; import { type Selection } from './Selection.js'; import { type Logger, type QueryType } from './types.js'; import { type QueryResult } from './util/query-result.js'; import { type MosaicClient } from './MosaicClient.js'; import { MaybeArray } from '@uwdata/mosaic-sql'; import { Table } from '@uwdata/flechette'; interface FilterGroupEntry { selection: Selection; clients: Set; disconnect(): void; } /** * Set or retrieve the coordinator instance. * @param instance The coordinator instance to set * @returns The coordinator instance */ export declare function coordinator(instance?: Coordinator): Coordinator; /** * A Mosaic Coordinator manages all database communication for clients and * handles selection updates. The Coordinator also performs optimizations * including query caching, consolidation, and pre-aggregation. */ export declare class Coordinator { manager: QueryManager; preaggregator: PreAggregator; clients: Set; filterGroups: Map; protected _logger: Logger; /** * @param db Database connector. Defaults to a web socket connection. * @param options Coordinator options. * @param options.logger The logger to use, defaults to `console`. * @param options.manager The query manager to use. * @param options.cache Boolean flag to enable/disable query caching. * @param options.consolidate Boolean flag to enable/disable query consolidation. * @param options.preagg Options for the Pre-aggregator. */ constructor(db?: Connector, options?: { logger?: Logger | null; manager?: QueryManager; cache?: boolean; consolidate?: boolean; preagg?: PreAggregateOptions; }); /** * Clear the coordinator state. * @param options Options object. * @param options.clients If true, disconnect all clients. * @param options.cache If true, clear the query cache. */ clear(options?: { clients?: boolean; cache?: boolean; }): void; /** * Get or set the database connector. * @param db The database connector to use. * @returns The current database connector. */ databaseConnector(): Connector | null; databaseConnector(db: Connector): Connector; /** * Get or set the logger. * @param logger The logger to use. * @returns The current logger */ logger(logger?: Logger | null): Logger; /** * Cancel previously submitted query requests. These queries will be * canceled if they are queued but have not yet been submitted. * @param requests An array of query result objects, such as those returned by the `query` method. */ cancel(requests: QueryResult[]): void; /** * Issue a query for which no result (return value) is needed. * @param query The query or an array of queries. Each query should be either a Query builder object or a SQL string. * @param options An options object. * @param options.priority The query priority, defaults to `Priority.Normal`. * @returns A query result promise. */ exec(query: MaybeArray, options?: { priority?: number; }): QueryResult; /** * Issue a query to the backing database. The submitted query may be * consolidate with other queries and its results may be cached. * @param query The query as either a Query builder object or a SQL string. * @param options An options object. * @param options.type The query result format type. * @param options.cache If true, cache the query result client-side within the QueryManager. * @param options.persist If true, request the database server to persist a cached query server-side. * @param options.priority The query priority, defaults to `Priority.Normal`. * @returns A query result promise. */ query(query: QueryType, options?: { type?: 'arrow'; cache?: boolean; persist?: boolean; priority?: number; [key: string]: unknown; }): QueryResult; query(query: QueryType, options?: { type?: 'json'; cache?: boolean; persist?: boolean; priority?: number; [key: string]: unknown; }): QueryResult; /** * Issue a query to prefetch data for later use. The query result is cached * for efficient future access. * @param query The query as either a Query builder object or a SQL string. * @param options An options object. * @param options.type The query result format type. * @returns A query result promise. */ prefetch(query: QueryType, options?: { type?: 'arrow'; [key: string]: unknown; }): QueryResult
; prefetch(query: QueryType, options?: { type?: 'json'; [key: string]: unknown; }): QueryResult; /** * Update client data by submitting the given query and returning the() * data (or error) to the client. * @param client A Mosaic client. * @param query The data query. * @param priority The query priority. * @returns A Promise that resolves upon completion of the update. */ updateClient(client: MosaicClient, query: QueryType, priority?: number): Promise; /** * Issue a query request for a client. If the query is null or undefined, * the client is simply updated. Otherwise `updateClient` is called. As a * side effect, this method clears the current preaggregator state. * @param client The client to update. * @param query The query to issue. */ requestQuery(client: MosaicClient, query?: QueryType | null): Promise; /** * Connect a client to the coordinator. * Throws an error if the client is already connected. * @param client The Mosaic client to connect. */ connect(client: MosaicClient): void; /** * Disconnect a client from the coordinator. * This method has no effect if the client is already disconnected. * @param client The Mosaic client to disconnect. */ disconnect(client: MosaicClient): void; } export {}; //# sourceMappingURL=Coordinator.d.ts.map