UNPKG

@jahed/sparql-engine

Version:

SPARQL query engine for servers and web browsers.

51 lines (50 loc) 2.55 kB
import type { PropertyPath } from "sparqljs"; import { Bindings } from "../../rdf/bindings.ts"; import Graph from "../../rdf/graph.ts"; import type { EngineIRI, EngineObject, EnginePathTriple, EngineSubject, 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"; /** * The base class to implements to evaluate Property Paths. * A subclass of this class only has to implement the `_executePropertyPath` method to provide an execution logic for property paths. * @abstract */ export default abstract class PathStageBuilder 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: EngineIRI[]): Promise<Graph>; /** * Get a {@link PipelineStage} for evaluating a succession of property paths, connected by joins. * @param source - Input {@link PipelineStage} * @param triples - Triple patterns * @param context - Execution context * @return A {@link PipelineStage} which yield set of bindings from the pipeline of joins */ execute(source: PipelineStage<Bindings>, triples: EnginePathTriple[], context: ExecutionContext): Promise<PipelineStage<Bindings>>; /** * Get a {@link PipelineStage} for evaluating the property path. * @param subject - Path subject * @param path - Property path * @param obj - Path object * @param context - Execution context * @return A {@link PipelineStage} which yield set of bindings */ _buildIterator(subject: EngineSubject, path: PropertyPath, obj: EngineObject, context: ExecutionContext): Promise<PipelineStage<Bindings>>; /** * Execute a property path against a RDF Graph. * @param subject - Path subject * @param path - Property path * @param obj - Path object * @param graph - RDF graph * @param context - Execution context * @return A {@link PipelineStage} which yield RDF triples matching the property path */ abstract _executePropertyPath(subject: EngineSubject, path: PropertyPath, obj: EngineObject, graph: Graph, context: ExecutionContext): PipelineStage<EngineTriple>; }