import type * as RDF from '@rdfjs/types'; import type { ITermDictionary } from './dictionary/ITermDictionary'; import type { EncodedQuadTerms } from './PatternTerm'; /** * An iterator over the encoded results of an index lookup, which an ordered index can ask to skip ahead. */ export interface IIndexResultIterator extends Iterator> { /** * Skip forward to the first result whose component at `level` is not before the sought term. * @param level The nesting level, in the component order of the index being read. * @param isBefore Whether an encoded key at that level precedes the sought term. */ seek?: (level: number, isBefore: (key: TE) => boolean) => void; } /** * Converts the encoded results of an index lookup into bindings objects. * * This is a plain class with a `read` method instead of a generator function, * because the bindings of a single lookup are consumed in three different ways: * into an array by `RdfStore#getBindings`, through a generator by `RdfStore#readBindings`, * and through an async iterator by `RdfStore#matchBindings`. * Expressing the conversion as a generator would add a suspend/resume and an * iterator result object per produced binding to each of those, * on top of the ones the index iterator itself already produces. * * This class handles patterns without quoted triple patterns and without overlapping variables, * which is the case for virtually every pattern a query engine produces. * {@link FilteringBindingsProducer} handles the remaining cases. */ export declare class BindingsProducer { protected readonly bindingsFactory: RDF.BindingsFactory; protected readonly source: IIndexResultIterator; protected readonly dictionary: ITermDictionary; /** * The pattern terms, ordered in the component order of the index that is being read. */ protected readonly terms: RDF.Term[]; /** * The positions within {@link BindingsProducer#terms} that must be bound. */ protected readonly variableIndexes: number[]; protected readonly variableCount: number; constructor(bindingsFactory: RDF.BindingsFactory, source: IIndexResultIterator, dictionary: ITermDictionary, terms: RDF.Term[], variableIndexes: number[]); /** * Skip forward to the first result whose component at `level` is not before the sought term. * * Does nothing when the underlying index cannot skip, in which case the caller still gets every * result, just by reading through them. * @param level The nesting level, in the component order of the index being read. * @param isBefore Whether an encoded key at that level precedes the sought term. */ seek(level: number, isBefore: (key: TE) => boolean): void; /** * Produce the next bindings object, or `null` if no results remain. */ read(): RDF.Bindings | null; /** * Stop reading from the underlying index. */ close(): void; } /** * A {@link BindingsProducer} for patterns that contain quoted triple patterns * and/or overlapping variables, which require results to be post-filtered. */ export declare class FilteringBindingsProducer extends BindingsProducer { private readonly dataFactory; /** * For each entry of {@link BindingsProducer#variableIndexes}, * whether the corresponding pattern term is a quoted triple pattern. */ private readonly variableIsQuad; /** * For each component that occurs more than once within the pattern, * the other component positions that must have an equal value. */ private readonly filterIndexes; constructor(bindingsFactory: RDF.BindingsFactory, source: IIndexResultIterator, dictionary: ITermDictionary, terms: RDF.Term[], variableIndexes: number[], dataFactory: RDF.DataFactory, variableIsQuad: boolean[], filterIndexes: number[][] | undefined); read(): RDF.Bindings | null; /** * Create the bindings entries for a single index result, * or `undefined` if the result must be skipped. * @param decomposedQuadEncoded An encoded quad, ordered in the index's component order. */ private createBindingsEntries; }