semantic-ds-toolkit
Version:
Performance-first semantic layer for modern data stacks - Stable Column Anchors & intelligent inference
55 lines • 2.35 kB
TypeScript
import { ColumnData, StableColumnAnchor, ColumnFingerprint } from '../types/anchor.types';
type LazyValue<T> = () => T;
type LazyPromise<T> = () => Promise<T>;
interface ComputationContext {
priority: 'high' | 'medium' | 'low';
timeout?: number;
dependencies?: string[];
cacheable?: boolean;
retryAttempts?: number;
}
export declare class LazyEvaluator {
private computations;
private evaluationQueue;
private runningComputations;
private batchJobs;
private maxConcurrency;
private resultCache;
constructor(maxConcurrency?: number);
lazy<T>(id: string, computation: LazyValue<T> | LazyPromise<T>, context?: ComputationContext): LazyComputation<T>;
lazyFingerprint(columnId: string, column: ColumnData, fingerprintFn: (col: ColumnData) => ColumnFingerprint): LazyComputation<ColumnFingerprint>;
lazyAnchor(anchorId: string, datasetName: string, column: ColumnData, anchorFn: (dataset: string, col: ColumnData) => StableColumnAnchor): LazyComputation<StableColumnAnchor>;
lazyBatch<T>(batchId: string, items: any[], processFn: (batch: any[]) => T[], batchSize?: number): LazyComputation<T[]>;
evaluate<T>(computationId: string): Promise<T>;
private resolveDependencies;
private executeComputation;
private executeWithTimeout;
private isPromiseFunction;
private waitForCompletion;
private waitForSlot;
private getCachedResult;
private cacheResult;
evaluateBatch(computationIds: string[]): Promise<Map<string, any>>;
private topologicalSort;
cleanup(olderThanMs?: number): void;
getStats(): {
totalComputations: number;
completedComputations: number;
failedComputations: number;
runningComputations: number;
cacheSize: number;
averageExecutionTime: number;
};
}
export declare class LazyComputation<T> {
private evaluator;
private computationId;
constructor(evaluator: LazyEvaluator, computationId: string);
getValue(): Promise<T>;
map<U>(fn: (value: T) => U): LazyComputation<U>;
flatMap<U>(fn: (value: T) => LazyComputation<U>): LazyComputation<U>;
combine<U, V>(other: LazyComputation<U>, combiner: (a: T, b: U) => V): LazyComputation<V>;
}
export declare const globalLazyEvaluator: LazyEvaluator;
export {};
//# sourceMappingURL=lazy-evaluator.d.ts.map