import type { BindingsStream, ComunicaDataFactory, FragmentSelectorShape, IActionContext, IQuerySource, QuerySourceReference } from '@comunica/types'; import { Algebra } from '@comunica/utils-algebra'; import type { BindingsFactory } from '@comunica/utils-bindings-factory'; import type * as RDF from '@rdfjs/types'; import { AsyncIterator } from 'asynciterator'; import type { IRdfJsSourceExtended } from './IRdfJsSourceExtended'; export declare class QuerySourceRdfJs implements IQuerySource { protected readonly selectorShape: FragmentSelectorShape; referenceValue: QuerySourceReference; protected readonly source: IRdfJsSourceExtended | RDF.DatasetCore; private readonly dataFactory; private readonly bindingsFactory; private readonly dummyDefaultGraph; /** * Cardinalities of patterns that have already been counted during a query execution. * Keyed on the query execution scope from the context, so that entries are dropped as soon as that * execution is garbage-collected, and are never reused across query executions. */ private readonly cardinalityCache; constructor(source: RDF.Source | RDF.DatasetCore, dataFactory: ComunicaDataFactory, bindingsFactory: BindingsFactory); static nullifyVariables(term: RDF.Term | undefined, quotedTripleFiltering: boolean): RDF.Term | undefined; static hasDuplicateVariables(pattern: RDF.BaseQuad): boolean; getSelectorShape(): Promise; getFilterFactor(): Promise; queryBindings(operation: Algebra.Operation, context: IActionContext): BindingsStream; /** * Check whether counting the given (already nullified) quad pattern is expensive enough to be worth caching. * * Patterns with at most one wildcard are answered by a direct index lookup, so counting them is cheap. * In bind joins those are the materialized patterns, which differ for every binding, so caching them * would only add lookup and storage cost. * Patterns with more wildcards require an index walk proportional to their cardinality, and are exactly * the patterns that a bind join re-evaluates unchanged once per binding. * @param terms The quad pattern terms, where undefined represents a wildcard. */ static isCardinalityCacheable(...terms: (RDF.Term | undefined)[]): boolean; /** * Obtain the cardinality cache for the query execution that the given context belongs to. * Returns undefined if the context carries no query execution scope, in which case nothing is cached. * @param context The action context. */ protected getCardinalityCache(context: IActionContext): Map | undefined; /** * Determine how many distinct values the given variable of the given pattern takes. * Only counted when the source can answer it with an index lookup, and left undefined otherwise. * @param operation The pattern being evaluated. * @param variable A variable of that pattern. * @param cardinality The cardinality of that pattern. * @param quotedTripleFiltering If the source supports quoted triple filtering. */ protected getDistinctValues(operation: Algebra.Pattern, variable: RDF.Variable, cardinality: number, quotedTripleFiltering: boolean): number | undefined; /** * Determine a cardinality cache key for the given (already nullified) quad pattern terms. * Returns undefined for patterns that must not be cached, i.e. those containing quoted triples, * as those are matched structurally rather than by value. * @param terms The quad pattern terms, where undefined represents a wildcard. */ static getCardinalityCacheKey(...terms: (RDF.Term | undefined)[]): string | undefined; protected setMetadata(it: AsyncIterator, operation: Algebra.Pattern, context: IActionContext, forceEstimateCardinality?: boolean, extraMetadata?: Record): Promise; queryQuads(operation: Algebra.Operation, _context: IActionContext): AsyncIterator; queryBoolean(_operation: Algebra.Ask, _context: IActionContext): Promise; queryVoid(_operation: Algebra.Operation, _context: IActionContext): Promise; toString(): string; }