@comunica/actor-query-source-identify-hypermedia-sparql
Version:
A sparql query-source-identify-hypermedia actor
112 lines (111 loc) • 6.51 kB
TypeScript
import type { MediatorHttp } from '@comunica/bus-http';
import type { MediatorQuerySerialize } from '@comunica/bus-query-serialize';
import type { BindingsStream, ComunicaDataFactory, FragmentSelectorShape, IActionContext, IQueryBindingsOptions, IQuerySource, MetadataBindings, QueryResultCardinality } from '@comunica/types';
import type { AlgebraFactory } from '@comunica/utils-algebra';
import { Algebra } from '@comunica/utils-algebra';
import type { BindingsFactory } from '@comunica/utils-bindings-factory';
import type * as RDF from '@rdfjs/types';
import type { AsyncIterator } from 'asynciterator';
import type { BindMethod } from './ActorQuerySourceIdentifyHypermediaSparql';
export declare class QuerySourceSparql implements IQuerySource {
readonly referenceValue: string;
private url;
private readonly urlBackup;
private readonly context;
private readonly mediatorHttp;
private readonly mediatorQuerySerialize;
private readonly bindMethod;
private readonly countTimeout;
private readonly cardinalityCountQueries;
private readonly cardinalityEstimateConstruction;
private readonly defaultGraph?;
private readonly unionDefaultGraph;
private readonly propertyFeatures?;
private readonly datasets?;
readonly extensionFunctions?: string[];
private readonly dataFactory;
private readonly algebraFactory;
private readonly bindingsFactory;
private readonly endpointFetcher;
private readonly cache;
private lastSourceContext;
constructor(url: string, urlBackup: string, context: IActionContext, mediatorHttp: MediatorHttp, mediatorQuerySerialize: MediatorQuerySerialize, bindMethod: BindMethod, dataFactory: ComunicaDataFactory, algebraFactory: AlgebraFactory, bindingsFactory: BindingsFactory, forceHttpGet: boolean, cacheSize: number, countTimeout: number, cardinalityCountQueries: boolean, cardinalityEstimateConstruction: boolean, forceGetIfUrlLengthBelow: number, parseUnsupportedVersions: boolean, metadata: Record<string, any>);
getFilterFactor(): Promise<number>;
getSelectorShape(): Promise<FragmentSelectorShape>;
queryBindings(operationIn: Algebra.Operation, context: IActionContext, options?: IQueryBindingsOptions): BindingsStream;
queryQuads(operation: Algebra.Operation, context: IActionContext): AsyncIterator<RDF.Quad>;
queryBoolean(operation: Algebra.Ask, context: IActionContext): Promise<boolean>;
queryVoid(operation: Algebra.Operation, context: IActionContext): Promise<void>;
protected attachMetadata(target: AsyncIterator<any>, context: IActionContext, operationPromise: Promise<Algebra.Operation>): void;
/**
* Convert an algebra operation into a query string, and if the operation is a simple triple pattern,
* then also replace any variables with s, p, and o to increase the chance of cache hits.
* @param {Algebra.Operation} operation The operation to convert into a query string.
* @returns {string} Query string for a COUNT query over the operation.
*/
operationToNormalizedCountQuery(operation: Algebra.Operation): Promise<string>;
/**
* Performs local cardinality estimation for the specified SPARQL algebra operation, which should
* result in better estimation performance at the expense of accuracy.
* @param {Algebra.Operation} operation A query operation.
*/
estimateOperationCardinality(operation: Algebra.Operation): Promise<QueryResultCardinality>;
/**
* Checks whether the provided operation makes use of this endpoint's property features,
* if the endpoint has property features detected.
* @param {Algebra.Operation} operation The operation to check.
* @returns {boolean} Whether the operation makes use of property features.
*/
operationUsesPropertyFeatures(operation: Algebra.Operation): boolean;
/**
* Create an operation that includes the bindings from the given bindings stream.
* @param algebraFactory The algebra factory.
* @param bindMethod A method for adding bindings to an operation.
* @param operation The operation to bind to.
* @param addBindings The bindings to add.
* @param addBindings.bindings The bindings stream.
* @param addBindings.metadata The bindings metadata.
*/
static addBindingsToOperation(algebraFactory: AlgebraFactory, bindMethod: BindMethod, operation: Algebra.Operation, addBindings: {
bindings: BindingsStream;
metadata: MetadataBindings;
}): Promise<Algebra.Operation>;
/**
* Convert an operation to a select query for this pattern.
* @param algebraFactory The algebra factory.
* @param {Algebra.Operation} operation A query operation.
* @param {RDF.Variable[]} variables The variables in scope for the operation.
* @return {string} A select query string.
*/
operationToSelectQuery(algebraFactory: AlgebraFactory, operation: Algebra.Operation, variables: RDF.Variable[]): Promise<string>;
/**
* Convert an operation to a count query for the number of matching triples for this pattern.
* @param dataFactory The data factory.
* @param algebraFactory The algebra factory.
* @param {Algebra.Operation} operation A query operation.
* @return {string} A count query string.
*/
operationToCountQuery(dataFactory: ComunicaDataFactory, algebraFactory: AlgebraFactory, operation: Algebra.Operation): Promise<string>;
/**
* Convert an operation to a query for this pattern.
* @param {Algebra.Operation} operation A query operation.
* @return {string} A query string.
*/
operationToQuery(operation: Algebra.Operation): Promise<string>;
/**
* Check if the given operation may produce undefined values.
* @param operation
*/
static getOperationUndefs(operation: Algebra.Operation): RDF.Variable[];
/**
* Send a SPARQL query to a SPARQL endpoint and retrieve its bindings as a stream.
* @param {string} endpoint A SPARQL endpoint URL.
* @param {string} query A SPARQL query string.
* @param {RDF.Variable[]} variables The expected variables.
* @param {IActionContext} context The source context.
* @param undefVariables Variables that may have undefs.
* @return {BindingsStream} A stream of bindings.
*/
queryBindingsRemote(endpoint: string, query: string, variables: RDF.Variable[], context: IActionContext, undefVariables: RDF.Variable[]): Promise<BindingsStream>;
toString(): string;
}