@jahed/sparql-engine
Version:
SPARQL query engine for servers and web browsers.
57 lines (56 loc) • 3.18 kB
TypeScript
import type { IriTerm, VariableTerm } from "sparqljs";
import { Bindings } from "../../rdf/bindings.ts";
import Graph from "../../rdf/graph.ts";
import type { EngineTriple } from "../../types.ts";
import ExecutionContext from "../context/execution-context.ts";
import type { PipelineStage } from "../pipeline/pipeline-engine.ts";
import StageBuilder from "./stage-builder.ts";
/**
* A BGPStageBuilder evaluates Basic Graph Patterns in a SPARQL query.
* Users can extend this class and overrides the "_buildIterator" method to customize BGP evaluation.
*/
export default class BGPStageBuilder extends StageBuilder {
/**
* Return the RDF Graph to be used for BGP evaluation.
* * If `iris` is empty, returns the default graph
* * If `iris` has a single entry, returns the corresponding named graph
* * Otherwise, returns an UnionGraph based on the provided iris
* @param iris - List of Graph's iris
* @return An RDF Graph
*/
_getGraph(iris: IriTerm[]): Promise<Graph>;
/**
* Build a {@link PipelineStage} to evaluate a BGP
* @param source - Input {@link PipelineStage}
* @param patterns - Set of triple patterns
* @param options - Execution options
* @return A {@link PipelineStage} used to evaluate a Basic Graph pattern
*/
execute(source: PipelineStage<Bindings>, patterns: EngineTriple[], context: ExecutionContext): Promise<PipelineStage<Bindings>>;
/**
* Replace the blank nodes in a BGP by SPARQL variables
* @param patterns - BGP to rewrite, i.e., a set of triple patterns
* @return A Tuple [Rewritten BGP, List of SPARQL variable added]
*/
_replaceBlankNodes(patterns: EngineTriple[]): [EngineTriple[], VariableTerm[]];
/**
* Returns a {@link PipelineStage} used to evaluate a Basic Graph pattern
* @param source - Input {@link PipelineStage}
* @param graph - The graph on which the BGP should be executed
* @param patterns - Set of triple patterns
* @param context - Execution options
* @return A {@link PipelineStage} used to evaluate a Basic Graph pattern
*/
_buildIterator(source: PipelineStage<Bindings>, graph: Graph, patterns: EngineTriple[], context: ExecutionContext): PipelineStage<Bindings>;
/**
* Returns a {@link PipelineStage} used to evaluate a Full Text Search query from a set of magic patterns.
* @param source - Input {@link PipelineStage}
* @param graph - The graph on which the full text search should be executed
* @param pattern - Input triple pattern
* @param queryVariable - SPARQL variable on which the full text search is performed
* @param magicTriples - Set of magic triple patterns used to configure the full text search
* @param context - Execution options
* @return A {@link PipelineStage} used to evaluate the Full Text Search query
*/
_buildFullTextSearchIterator(source: PipelineStage<Bindings>, graph: Graph, pattern: EngineTriple, queryVariable: VariableTerm, magicTriples: EngineTriple[], context: ExecutionContext): PipelineStage<Bindings>;
}