UNPKG

@jahed/sparql-engine

Version:

SPARQL query engine for servers and web browsers.

54 lines (53 loc) 3.39 kB
import { type PipelineInput, type PipelineObserverOrNext, type PipelineStage, type PipelineSubscription, type StreamPipelineInput, PipelineEngine } from "./pipeline-engine.ts"; /** * A PipelineStage which materializes all intermediate results in main memory. */ export declare class VectorStage<T> implements PipelineStage<T> { private readonly _content; constructor(content: Promise<Array<T>>); getContent(): Promise<Array<T>>; subscribe(observerOrNext: PipelineObserverOrNext<T>): PipelineSubscription; forEach(cb: (value: T) => void): void; pipe<N>(fn: (source: PipelineStage<T>) => PipelineStage<N>): PipelineStage<N>; [Symbol.asyncIterator](): AsyncIterator<T>; } export declare class VectorStreamInput<T> implements StreamPipelineInput<T> { private readonly _resolve; private readonly _reject; private _content; constructor(resolve: any, reject: any); next(value: T): void; error(err: any): void; complete(): void; } /** * A pipeline implemented using {@link VectorStage}, *i.e.*, all intermediate results are materialized in main memory. This approach is often called **vectorized approach**. * This pipeline is more efficient CPU-wise than {@link RxjsPipeline}, but it also consumes much more memory, as it materializes evey stage of the pipeline before moving to the next. * It should only be used when SPARQL queries generate few intermediate results. * @see P. A. Boncz, S. Manegold, and M. L. Kersten. "Database architecture evolution: Mammals flourished long before dinosaurs became extinct". PVLDB, (2009) */ export default class VectorPipeline extends PipelineEngine { empty<T>(): VectorStage<T>; of<T>(...values: T[]): VectorStage<T>; getContent<T>(x: PipelineInput<T>): Promise<T[]>; from<T>(x: PipelineInput<T>): VectorStage<T>; fromAsync<T>(cb: (input: StreamPipelineInput<T>) => void): VectorStage<T>; clone<T>(stage: VectorStage<T>): VectorStage<T>; catch<T, O>(input: VectorStage<T>, handler?: (err: Error) => VectorStage<O>): VectorStage<T | O>; merge<T>(...inputs: Array<VectorStage<T> | PipelineInput<T>>): VectorStage<T>; map<F, T>(input: VectorStage<F>, mapper: (value: F) => T): VectorStage<T>; flatMap<F, T>(input: VectorStage<F>, mapper: (value: F) => T[]): VectorStage<T>; mergeMap<F, T>(input: VectorStage<F>, mapper: (value: F) => VectorStage<T>): VectorStage<T>; mergeMapAsync<F, T>(input: VectorStage<F>, mapper: (value: F) => VectorStage<T> | Promise<VectorStage<T>>): VectorStage<T>; filter<T>(input: VectorStage<T>, predicate: (value: T) => boolean): VectorStage<T>; filterAsync<T>(input: VectorStage<T>, predicate: (value: T) => boolean | Promise<boolean>): VectorStage<T>; finalize<T>(input: VectorStage<T>, callback: () => void): VectorStage<T>; reduce<F, T>(input: VectorStage<F>, reducer: (acc: T, value: F) => T, initial: T): VectorStage<T>; limit<T>(input: VectorStage<T>, stopAfter: number): VectorStage<T>; skip<T>(input: VectorStage<T>, toSkip: number): VectorStage<T>; defaultValues<T>(input: VectorStage<T>, ...values: T[]): VectorStage<T>; bufferCount<T>(input: VectorStage<T>, count: number): VectorStage<T[]>; forEach<T>(input: VectorStage<T>, cb: (value: T) => void): void; first<T>(input: VectorStage<T>): VectorStage<T>; collect<T>(input: VectorStage<T>): VectorStage<T[]>; }