import type * as RDF from '@rdfjs/types'; import type { QuadTermName } from 'rdf-terms'; import type { ITermDictionary } from './dictionary/ITermDictionary'; import type { EncodedQuadTerms, PatternTerm, QuadPatternTerms } from './PatternTerm'; export declare const QUAD_TERM_NAMES_INVERSE: Record; /** * Determine the best suitable order's index among the given orders for the given quad pattern. * @param componentOrders Possible orders of quad components. * @param quadPattern A quad pattern. */ export declare function getBestIndex(componentOrders: QuadTermName[][], quadPattern: QuadPatternTerms): number; /** * Determine the best suitable order's index among the given orders for the given terms. * @param componentOrders Possible orders of quad components. * @param terms The quad term names to lookup. * @param filters Optional quad components (SPOG order) that are bound to a single term. */ export declare function getBestIndexTerms(componentOrders: QuadTermName[][], terms: QuadTermName[], filters?: (RDF.Term | undefined)[]): number; /** * Determine the score of the given component order for looking up the given terms under the given filters. * Filtered components weigh double, as they must be matched before the terms can be read off the index. * @param componentOrder A quad component order. * @param terms The quad term names to lookup. * @param filters Optional quad components (SPOG order) that are bound to a single term. */ export declare function getComponentOrderScoreFiltered(componentOrder: QuadTermName[], terms: QuadTermName[], filters?: (RDF.Term | undefined)[]): number; /** * Construct the path to follow within the given index's component order for the given terms. * This returns a boolean[] indicating the path of terms to match within the index. * @param componentOrder The index's component order. * @param terms The terms to find. */ export declare function getIndexMatchTermsPath(componentOrder: QuadTermName[], terms: QuadTermName[]): boolean[]; /** * Determine the score of the given partial component order in the given component order. * @param componentOrder A quad component order. * @param partialComponentOrder A partial quad component order that originates from a quad pattern. */ export declare function getComponentOrderScore(componentOrder: QuadTermName[], partialComponentOrder: QuadTermName[]): number; /** * Order a quad pattern's terms based on the given component order. * @param desiredComponentOrder The desired order of components. * @param quadPattern A quad pattern. */ export declare function orderQuadComponents(desiredComponentOrder: QuadTermName[], quadPattern: T[]): T[]; /** * Order a quad pattern's terms based on the given precomputed component order permutation. * The permutation must be an array of four indexes into the SPOG-ordered input array, * as produced by {@link getComponentOrderPermutation}. * @param permutation A precomputed component order permutation. * @param quadPattern A quad pattern. */ export declare function orderQuadComponentsPermutation(permutation: number[], quadPattern: T[]): [T, T, T, T]; /** * Precompute the permutation of SPOG indexes corresponding to the given component order. * @param componentOrder A quad component order. */ export declare function getComponentOrderPermutation(componentOrder: QuadTermName[]): number[]; /** * Precompute, for every possible combination of defined quad pattern components, * the index of the best suitable component order. * * The returned array is indexed by a bitmask in which bit `i` is set * when `QUAD_TERM_NAMES[i]` is defined within the quad pattern. * This allows {@link getBestIndex} to be replaced by a single array lookup at query time. * The produced values are identical to what {@link getBestIndex} returns for such patterns. * * @param componentOrders Possible orders of quad components. */ export declare function getBestIndexLookupTable(componentOrders: QuadTermName[][]): Uint8Array; /** * Encode the given array of quad terms. * @param terms Non-encoded quad terms. * @param dictionary A dictionary * @return array An array of encoded terms. * The array will be undefined if at least one of the patterns does not occur within the dictionary. */ export declare function encodeOptionalTerms(terms: QuadPatternTerms, dictionary: ITermDictionary): (TE | undefined)[] | undefined; /** * Convert a quad patter to a `QuadPatternTerms` type. * @param subject The subject. * @param predicate The predicate. * @param object The object. * @param graph The graph. * @param quotedPatterns If the index supports quoted triple filtering. * @return Tuple A tuple of QuadPatternTerms * and a boolean indicating if post-filtering will be needed on quoted triples. * This boolean can only be true if `quotedPatterns` is false, and a quoted triple pattern was present. */ export declare function quadToPattern(subject: RDF.Term | null | undefined, predicate: RDF.Term | null | undefined, object: RDF.Term | null | undefined, graph: RDF.Term | null | undefined, quotedPatterns: boolean): [QuadPatternTerms, boolean]; /** * Check if the given quad contains variables, even in deeply nested quoted triples. * @param currentTerm The quad pattern term. */ export declare function quadHasVariables(currentTerm: RDF.Quad): boolean; /** * Create a boolean array indicating which terms are quoted triple patterns. * @param terms An array of terms. */ export declare function arePatternsQuoted(terms: QuadPatternTerms): boolean[]; /** * Check if the given term is a quoted triple pattern. * @param term A pattern term. */ export declare function isPatternQuoted(term: PatternTerm): boolean; /** * Compute the deepest level to navigate to, based on matchTerms and filterTerms. * @param matchTerms An array of booleans indicating which terms to collect. * @param filterTerms An optional array of filter terms. */ export declare function computeEndDepth(matchTerms: boolean[], filterTerms?: (TE | undefined)[]): number; /** * Encode filter terms and extend the matchTerms path if needed. * * Reorders the filters from SPOG order to the index's component order, encodes each defined * filter term using the dictionary, and pads `matchTerms` with `false` entries when filters * reach deeper into the index than the current path. * * @param filters An array of quad components (SPOG order) to filter on. * @param matchTerms The current index-path boolean array (mutated copy is returned). * @param componentOrder The index's component order. * @param dictionary The term dictionary used for encoding. * @returns An object with the encoded filter array and the (possibly extended) matchTerms, * or `null` when a filter term is absent from the dictionary (meaning no results exist). */ export declare function encodeAndExtendFilters(filters: (RDF.Term | undefined)[], matchTerms: boolean[], componentOrder: QuadTermName[], dictionary: ITermDictionary): { filterTermsEncoded: EncodedQuadTerms; matchTerms: boolean[]; } | null;