import { DifferenceStreamWriter, UnaryOperator, DifferenceStreamReader } from '../graph.js';
import { IndexedValue, TopK } from './topKArray.js';
import { PipedOperator } from '../types.js';
export interface GroupedTopKWithFractionalIndexOptions<K, T> {
    limit?: number;
    offset?: number;
    setSizeCallback?: (getSize: () => number) => void;
    setWindowFn?: (windowFn: (options: {
        offset?: number;
        limit?: number;
    }) => void) => void;
    /**
     * Function to extract a group key from the element's key and value.
     * Elements with the same group key will be sorted and limited together.
     */
    groupKeyFn: (key: K, value: T) => unknown;
}
/**
 * Operator for grouped fractional indexed topK operations.
 * This operator maintains separate topK windows for each group,
 * allowing per-group limits and ordering.
 *
 * The input is a keyed stream [K, T] and outputs [K, IndexedValue<T>].
 * Elements are grouped by the groupKeyFn, and each group maintains
 * its own sorted collection with independent limit/offset.
 */
export declare class GroupedTopKWithFractionalIndexOperator<K extends string | number, T> extends UnaryOperator<[K, T], [K, IndexedValue<T>]> {
    #private;
    constructor(id: number, inputA: DifferenceStreamReader<[K, T]>, output: DifferenceStreamWriter<[K, IndexedValue<T>]>, comparator: (a: T, b: T) => number, options: GroupedTopKWithFractionalIndexOptions<K, T>);
    /**
     * Creates a new TopK data structure for a group.
     * Can be overridden in subclasses to use different implementations (e.g., B+ tree).
     */
    protected createTopK(offset: number, limit: number, comparator: (a: [K, T], b: [K, T]) => number): TopK<[K, T]>;
    run(): void;
}
/**
 * Limits the number of results per group based on a comparator, with optional offset.
 * Uses fractional indexing to minimize the number of changes when elements move positions.
 * Each element is assigned a fractional index that is lexicographically sortable.
 * When elements move, only the indices of the moved elements are updated, not all elements.
 *
 * This operator groups elements by the provided groupKeyFn and applies the limit/offset
 * independently to each group.
 *
 * @param comparator - A function that compares two elements for ordering
 * @param options - Configuration including groupKeyFn, limit, and offset
 * @returns A piped operator that orders elements per group and limits results per group
 */
export declare function groupedTopKWithFractionalIndex<K extends string | number, T>(comparator: (a: T, b: T) => number, options: GroupedTopKWithFractionalIndexOptions<K, T>): PipedOperator<[K, T], [K, IndexedValue<T>]>;
