import { BTreeSet } from '../../../shared/src/btree-set.ts';
import type { Condition, Ordering } from '../../../zero-protocol/src/ast.ts';
import type { Row } from '../../../zero-protocol/src/data.ts';
import type { PrimaryKey } from '../../../zero-protocol/src/primary-key.ts';
import type { SchemaValue } from '../../../zero-types/src/schema-value.ts';
import type { DebugDelegate } from '../builder/debug-delegate.ts';
import { type NoSubqueryCondition } from '../builder/filter.ts';
import { type Constraint } from './constraint.ts';
import { type Comparator, type Node } from './data.ts';
import { type Input, type Output, type Start } from './operator.ts';
import type { Source, SourceChange, SourceInput } from './source.ts';
import type { Stream } from './stream.ts';
export type Overlay = {
    epoch: number;
    change: SourceChange;
};
export type Overlays = {
    add: Row | undefined;
    remove: Row | undefined;
};
export type Connection = {
    input: Input;
    output: Output | undefined;
    sort: Ordering;
    splitEditKeys: Set<string> | undefined;
    compareRows: Comparator;
    filters: {
        condition: NoSubqueryCondition;
        predicate: (row: Row) => boolean;
    } | undefined;
    readonly debug?: DebugDelegate | undefined;
    lastPushedEpoch: number;
};
/**
 * A `MemorySource` is a source that provides data to the pipeline from an
 * in-memory data source.
 *
 * This data is kept in sorted order as downstream pipelines will always expect
 * the data they receive from `pull` to be in sorted order.
 */
export declare class MemorySource implements Source {
    #private;
    constructor(tableName: string, columns: Record<string, SchemaValue>, primaryKey: PrimaryKey, primaryIndexData?: BTreeSet<Row>);
    get tableSchema(): {
        name: string;
        columns: Record<string, SchemaValue>;
        primaryKey: readonly [string, ...string[]];
    };
    fork(): MemorySource;
    get data(): BTreeSet<Row>;
    connect(sort: Ordering, filters?: Condition, splitEditKeys?: Set<string>): SourceInput;
    getIndexKeys(): string[];
    push(change: SourceChange): Stream<'yield'>;
    genPush(change: SourceChange): Generator<"yield" | undefined, void, unknown>;
}
export declare function genPushAndWriteWithSplitEdit(connections: readonly Connection[], change: SourceChange, exists: (row: Row) => boolean, setOverlay: (o: Overlay | undefined) => Overlay | undefined, writeChange: (c: SourceChange) => void, getNextEpoch: () => number): Generator<"yield" | undefined, void, unknown>;
export declare function generateWithStart(nodes: Iterable<Node | 'yield'>, start: Start | undefined, compare: (r1: Row, r2: Row) => number): Stream<Node | 'yield'>;
/**
 * Takes an iterator and overlay.
 * Splices the overlay into the iterator at the correct position.
 *
 * @param startAt - if there is a lower bound to the stream. If the lower bound of the stream
 * is above the overlay, the overlay will be skipped.
 * @param rows - the stream into which the overlay should be spliced
 * @param constraint - constraint that was applied to the rowIterator and should
 * also be applied to the overlay.
 * @param overlay - the overlay values to splice in
 * @param compare - the comparator to use to find the position for the overlay
 */
export declare function generateWithOverlay(startAt: Row | undefined, rows: Iterable<Row>, constraint: Constraint | undefined, overlay: Overlay | undefined, lastPushedEpoch: number, compare: Comparator, filterPredicate?: (row: Row) => boolean | undefined): Generator<{
    row: Readonly<Record<string, import("../../../shared/src/json.ts").ReadonlyJSONValue | undefined>>;
    relationships: {};
}, void, unknown>;
export { overlaysForStartAt as overlaysForStartAtForTest };
declare function overlaysForStartAt({ add, remove }: Overlays, startAt: Row, compare: Comparator): Overlays;
export { overlaysForConstraint as overlaysForConstraintForTest };
declare function overlaysForConstraint({ add, remove }: Overlays, constraint: Constraint): Overlays;
export declare function generateWithOverlayInner(rowIterator: Iterable<Row>, overlays: Overlays, compare: (r1: Row, r2: Row) => number): Generator<{
    row: Readonly<Record<string, import("../../../shared/src/json.ts").ReadonlyJSONValue | undefined>>;
    relationships: {};
}, void, unknown>;
export declare function stringify(change: SourceChange): string;
//# sourceMappingURL=memory-source.d.ts.map