rdf-stores
Version:
A TypeScript/JavaScript implementation of the RDF/JS store interface with support for quoted triples.
54 lines (53 loc) • 2.84 kB
TypeScript
import type * as RDF from '@rdfjs/types';
import type { QuadTermName } from 'rdf-terms';
import type { ITermDictionary } from './dictionary/ITermDictionary';
import type { QuadPatternTerms } from './PatternTerm';
export declare const QUAD_TERM_NAMES_INVERSE: Record<QuadTermName, number>;
/**
* 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 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<T>(desiredComponentOrder: QuadTermName[], quadPattern: T[]): T[];
/**
* 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<E>(terms: QuadPatternTerms, dictionary: ITermDictionary<E>): (E | 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[];