import { type CellValue } from '@bilig/protocol';
import { type CompiledCriteriaMatcher, type CriteriaOperator } from '@bilig/formula';
import type { EngineRuntimeColumnStoreService } from './runtime-column-store-service.js';
import type { DepPatternStore } from '../../deps/dep-pattern-store.js';
import type { RegionGraph } from '../../deps/region-graph.js';
export interface CriterionRangeDescriptor {
    readonly sheetName: string;
    readonly rowStart: number;
    readonly rowEnd: number;
    readonly col: number;
    readonly length: number;
}
export interface CriterionRangePair {
    readonly range: CriterionRangeDescriptor;
    readonly criteria: CellValue;
}
export interface CriterionRangeMatch {
    readonly rows: Uint32Array;
    readonly length: number;
}
export interface CriterionRangeCacheService {
    readonly getOrBuildMatchingRows: (request: {
        criteriaPairs: readonly CriterionRangePair[];
    }) => CriterionRangeMatch | CellValue;
    readonly getOrBuildExactCriteriaAggregate: (request: CriterionCompoundExactAggregateRequest) => CellValue | undefined;
    readonly getOrBuildExactAggregate: (request: CriterionExactAggregateRequest) => CellValue | undefined;
    readonly getOrBuildCompoundExactAggregate: (request: CriterionCompoundExactAggregateRequest) => CellValue | undefined;
    readonly getOrBuildIndexedPredicateAggregate: (request: CriterionCompoundExactAggregateRequest) => CellValue | undefined;
}
export interface CriterionExactAggregateRequest {
    readonly criteriaPair: CriterionRangePair;
    readonly aggregateRange?: CriterionRangeDescriptor;
    readonly aggregateKind: 'count' | 'sum' | 'average' | 'min' | 'max';
}
export interface CriterionCompoundExactAggregateRequest {
    readonly criteriaPairs: readonly CriterionRangePair[];
    readonly aggregateRange?: CriterionRangeDescriptor;
    readonly aggregateKind: CriterionExactAggregateRequest['aggregateKind'];
    readonly useCompoundBucketIndex?: boolean;
}
export interface CriterionExactAggregateBucket {
    count: number;
    sum: number;
    numericCount: number;
    minimum: number;
    maximum: number;
    firstError?: CellValue;
}
export type SliceFastPredicate = {
    kind: 'eq-empty';
    negate: boolean;
} | {
    kind: 'eq-bool';
    negate: boolean;
    value: boolean;
} | {
    kind: 'eq-number';
    negate: boolean;
    value: number;
} | {
    kind: 'eq-string';
    negate: boolean;
    value: string;
} | {
    kind: 'cmp-number';
    operator: Exclude<CriteriaOperator, '=' | '<>'>;
    value: number;
} | {
    kind: 'generic';
    compiled: CompiledCriteriaMatcher;
};
export declare function createCriterionRangeCacheService(args: {
    readonly runtimeColumnStore: EngineRuntimeColumnStoreService;
    readonly regionGraph: Pick<RegionGraph, 'internSingleColumnRegion'>;
    readonly depPatternStore: DepPatternStore;
}): CriterionRangeCacheService;
