import { LoggerFn } from '@cubejs-backend/shared'; import { DownloadTableData, DriverCapabilities, DriverInterface, QueuePriority, SaveCancelFn, StreamOptions, UnloadOptions } from '@cubejs-backend/base-driver'; import { DriverFactory } from './DriverFactory'; import { QueryCache, QueryWithParams } from './QueryCache'; import { InvalidationKeys, LoadPreAggregationResult, PreAggregations, PreAggregationTableToTempTable, VersionEntry } from './PreAggregations'; import { PreAggregationLoadCache } from './PreAggregationLoadCache'; type IndexesSql = { sql: [string, unknown[]]; indexName: string; }[]; type QueryKey = [QueryWithParams, IndexesSql, InvalidationKeys] | [QueryWithParams, InvalidationKeys]; type QueryOptions = { queryKeyMd5: QueryKey | string; newVersionEntry: VersionEntry; values: unknown[]; requestId: string; buildRangeEnd?: string; }; export declare class PreAggregationLoader { private readonly driverFactory; private readonly logger; private readonly queryCache; private readonly loadCache; private preAggregations; preAggregation: any; private readonly preAggregationsTablesToTempTables; /** * Determines whether current instance instantiated for a jobbed build query * (initialized by the /cubejs-system/v1/pre-aggregations/jobs endpoint) or * not. */ private readonly isJob; private readonly waitForRenew; private readonly forceBuild; private readonly orphanedTimeout; private readonly externalDriverFactory; private readonly requestId; private readonly metadata; private readonly structureVersionPersistTime; private readonly externalRefresh; private buildLanded; constructor(driverFactory: DriverFactory, logger: LoggerFn, queryCache: QueryCache, preAggregations: PreAggregations, preAggregation: any, preAggregationsTablesToTempTables: PreAggregationTableToTempTable[], loadCache: PreAggregationLoadCache, options?: any); loadPreAggregation(throwOnMissingPartition: boolean): Promise; protected loadPreAggregationWithKeys(): Promise; private updateLastTouch; protected contentVersion(invalidationKeys: InvalidationKeys): string; protected priority(defaultValue: QueuePriority): QueuePriority; protected getInvalidationKeyValues(): Promise; protected getPartitionInvalidationKeyValues(): Promise; protected scheduleRefresh(invalidationKeys: InvalidationKeys, newVersionEntry: VersionEntry): void; protected executeInQueue(invalidationKeys: InvalidationKeys, priority: QueuePriority, newVersionEntry: VersionEntry): Promise; protected preAggregationQueryKey(invalidationKeys: InvalidationKeys): QueryKey; protected targetTableName(versionEntry: VersionEntry): string; refresh(newVersionEntry: VersionEntry, invalidationKeys: InvalidationKeys, client: any): any; /** * Marks the rows as landed in the partition table. From here on the table * speaks for itself, so the record that a build is in flight goes away and * nothing but a live build is left behind in the cache store. */ protected reportBuildLanded(targetTableName: string): Promise; /** * Persists that a build is running or has failed, so the jobs API can tell an * unfinished build from a versioned table that merely exists. Recorded for * every build, not just for the ones a job started: the queue de-duplicates * on the query key, so a job regularly ends up waiting on a build some other * request enqueued. */ private reportBuildStatus; protected logExecutingSql(payload: any): void; protected queryOptions(invalidationKeys: InvalidationKeys, _query: string, params: unknown[], targetTableName: string, newVersionEntry: VersionEntry): { queryKeyMd5: string; values: unknown[]; targetTableName: string; requestId: string; newVersionEntry: VersionEntry; buildRangeEnd: any; }; protected refreshStoreInSourceStrategy(client: DriverInterface, newVersionEntry: VersionEntry, saveCancelFn: SaveCancelFn, invalidationKeys: InvalidationKeys): Promise; protected refreshWriteStrategy(client: DriverInterface, newVersionEntry: VersionEntry, saveCancelFn: SaveCancelFn, invalidationKeys: InvalidationKeys): Promise; /** * Runs export strategy with write access in data source */ protected runWriteStrategy(client: DriverInterface, newVersionEntry: VersionEntry, saveCancelFn: SaveCancelFn, invalidationKeys: InvalidationKeys, withTempTable: boolean, dropSourceTempTable: boolean): Promise; /** * Cleanup tables after write strategy */ protected cleanupWriteStrategy(client: DriverInterface, targetTableName: string, queryOptions: QueryOptions, saveCancelFn: SaveCancelFn, withTempTable: boolean, dropSourceTempTable: boolean): Promise; /** * Create table (if required) and prepares query options object */ protected prepareWriteStrategy(client: DriverInterface, targetTableName: string, newVersionEntry: VersionEntry, saveCancelFn: SaveCancelFn, invalidationKeys: InvalidationKeys, withTempTable: boolean): Promise; /** * Strategy to copy pre-aggregation from source db (for read-only permissions) to external data */ protected refreshReadOnlyExternalStrategy(client: DriverInterface, newVersionEntry: VersionEntry, saveCancelFn: SaveCancelFn, invalidationKeys: InvalidationKeys): Promise; protected getUnloadOptions(): UnloadOptions; protected getStreamingOptions(): StreamOptions; /** * prepares download data for future cube store usage */ protected downloadExternalPreAggregation(client: DriverInterface, newVersionEntry: VersionEntry, saveCancelFn: SaveCancelFn, queryOptions: QueryOptions, withTempTable: boolean): Promise; /** * prepares download data when temp table = true */ protected getTableDataWithTempTable(client: DriverInterface, table: string, saveCancelFn: SaveCancelFn, queryOptions: QueryOptions, externalDriverCapabilities: DriverCapabilities): Promise; /** * prepares download data when temp table = false */ protected getTableDataWithoutTempTable(client: DriverInterface, table: string, saveCancelFn: SaveCancelFn, queryOptions: QueryOptions, externalDriverCapabilities: DriverCapabilities): Promise; protected uploadExternalPreAggregation(tableData: DownloadTableData, newVersionEntry: VersionEntry, saveCancelFn: SaveCancelFn, queryOptions: QueryOptions): Promise; private dropPartiallyBuiltTable; protected createIndexes(driver: DriverInterface, newVersionEntry: VersionEntry, saveCancelFn: SaveCancelFn, queryOptions: QueryOptions): Promise; protected prepareIndexesSql(newVersionEntry: VersionEntry, queryOptions: QueryOptions): any; protected prepareCreateTableIndexes(newVersionEntry: VersionEntry): any; private withDropLock; protected dropOrphanedTables(client: DriverInterface, justCreatedTable: string, saveCancelFn: SaveCancelFn, external: boolean, queryOptions: QueryOptions): Promise; private dropOrphanedLockKey; } export {}; //# sourceMappingURL=PreAggregationLoader.d.ts.map