import type { FetchRequest, Input, InputBase, Output } from './operator.ts'; import { type Node } from './data.ts'; import type { Change } from './change.ts'; import type { SourceSchema } from './schema.ts'; import type { Stream } from './stream.ts'; import type { BuilderDelegate } from '../builder/builder.ts'; /** * The `where` clause of a ZQL query is implemented using a sub-graph of * `FilterOperators`. This sub-graph starts with a `FilterStart` operator, * that adapts from the normal `Operator` `Output`, to the * `FilterOperator` `FilterInput`, and ends with a `FilterEnd` operator that * adapts from a `FilterOperator` `FilterOutput` to a normal `Operator` `Input`. * `FilterOperator'`s do not have `fetch` or `cleanup` instead they have a * `filter(node: Node, cleanup: boolean): boolean` method. * They also have `push` which is just like normal `Operator` push. * Not having a `fetch` means these `FilterOperator`'s cannot modify * `Node` `row`s or `relationship`s, but they shouldn't, they should just * filter. * * This `FilterOperator` abstraction enables much more efficient processing of * `fetch` for `where` clauses containing OR conditions. * * See https://github.com/rocicorp/mono/pull/4339 */ export interface FilterInput extends InputBase { /** Tell the input where to send its output. */ setFilterOutput(output: FilterOutput): void; } export interface FilterOutput extends Output { filter(node: Node, cleanup: boolean): boolean; } export interface FilterOperator extends FilterInput, FilterOutput { } /** * An implementation of FilterOutput that throws if push or filter is called. * It is used as the initial value for for an operator's output before it is * set. */ export declare const throwFilterOutput: FilterOutput; export declare class FilterStart implements FilterInput, Output { #private; constructor(input: Input); setFilterOutput(output: FilterOutput): void; destroy(): void; getSchema(): SourceSchema; push(change: Change): void; fetch(req: FetchRequest): Stream; cleanup(req: FetchRequest): Stream; } export declare class FilterEnd implements Input, FilterOutput { #private; constructor(start: FilterStart, input: FilterInput); fetch(req: FetchRequest): Stream; cleanup(req: FetchRequest): Stream; filter(_node: Node, _cleanup: boolean): boolean; setOutput(output: Output): void; destroy(): void; getSchema(): SourceSchema; push(change: Change): void; } export declare function buildFilterPipeline(input: Input, delegate: BuilderDelegate, pipeline: (filterInput: FilterInput) => FilterInput): Input; //# sourceMappingURL=filter-operators.d.ts.map