Class AbstractDataSource<NativeQueryType, NativeResultType>
java.lang.Object
fr.inria.rules.integraal.views.datasource.AbstractDataSource<NativeQueryType, NativeResultType>
- Type Parameters:
NativeQueryType- the type used to represent the native queryNativeResultType- the type used to represent the results as the native format
- All Implemented Interfaces:
QueryableData, DataSource<NativeQueryType, NativeResultType>
- Direct Known Subclasses:
MongoDBDataSource, SPARQLDataSource, SQLDataSource, WebAPIDataSource
public abstract class AbstractDataSource<NativeQueryType, NativeResultType>
extends Object
implements DataSource<NativeQueryType, NativeResultType>
This wrapper represents data-sources accessed using mappings.
These sources are queried by user-given queries with read-only rights
A data-source can define several relational views, which associate a Predicate (of the relational view) to a specification of this view
A data-source can define several relational views, which associate a Predicate (of the relational view) to a specification of this view
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDataSource(Specializer<NativeQueryType> specializer, NativeQueryEvaluator<NativeQueryType, NativeResultType> evaluator, fr.inria.rules.integraal.views.transformer.Transformer<NativeResultType> transformer) Create a new wrapper over a data-source with a relational viewprotectedAbstractDataSource(String name, Specializer<NativeQueryType> specializer, NativeQueryEvaluator<NativeQueryType, NativeResultType> evaluator, fr.inria.rules.integraal.views.transformer.Transformer<NativeResultType> transformer) Create a new wrapper over a data-source with a relational view -
Method Summary
Modifier and TypeMethodDescriptionestimateBound(BasicQuery query) Estimate the number of answers to a query The estimation is the upper bound, meaning the actual number of answers will not exceed this number.evaluate(BasicQuery query) Try to evaluate a basic queryevaluate(BasicQuery query, List<Integer> sequenceOfAnswerVariables) Try to evaluate a basic querygetAtomicPattern(Predicate predicate) Get the basic pattern for a given predicategetName()Returns the optional user-facing name of this data source.Returns a collection of all predicates in this Readable.Returns the parameters used to query the supplied predicate from this source.booleanAllows checking if this QueryableData provides the predicate pvoidregisterView(Predicate p, ViewParameters<NativeQueryType> viewParameters) Register the given view and configuration Replaces existing mapping associated to the given predicate if any existsvoidSets the user-facing name of this data source.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface QueryableData
estimateBound, getSupportedOperations
-
Constructor Details
-
AbstractDataSource
protected AbstractDataSource(Specializer<NativeQueryType> specializer, NativeQueryEvaluator<NativeQueryType, NativeResultType> evaluator, fr.inria.rules.integraal.views.transformer.Transformer<NativeResultType> transformer) Create a new wrapper over a data-source with a relational view- Parameters:
specializer- to specialize the native queryevaluator- to evaluate the native querytransformer- to transform the native result into atoms
-
AbstractDataSource
protected AbstractDataSource(String name, Specializer<NativeQueryType> specializer, NativeQueryEvaluator<NativeQueryType, NativeResultType> evaluator, fr.inria.rules.integraal.views.transformer.Transformer<NativeResultType> transformer) Create a new wrapper over a data-source with a relational view- Parameters:
name- to identify the datasourcespecializer- to specialize the native queryevaluator- to evaluate the native querytransformer- to transform the native result into atoms
-
-
Method Details
-
registerView
Register the given view and configuration Replaces existing mapping associated to the given predicate if any exists- Parameters:
p- view predicate associated to this mappingviewParameters- associated to this view predicate
-
getViewParameters
Description copied from interface:DataSourceReturns the parameters used to query the supplied predicate from this source.- Specified by:
getViewParametersin interfaceDataSource<NativeQueryType, NativeResultType>- Parameters:
p- the predicate representing the relational view- Returns:
- the native query associated to the view predicate p
-
getPredicates
Description copied from interface:QueryableDataReturns a collection of all predicates in this Readable.- Specified by:
getPredicatesin interfaceQueryableData- Returns:
- the predicates corresponding to the relational views of the datasource
-
hasPredicate
Description copied from interface:QueryableDataAllows checking if this QueryableData provides the predicate p- Specified by:
hasPredicatein interfaceQueryableData- Parameters:
p- the predicate to look up- Returns:
- boolean that is true iff the QueryableData provides this predicate
-
evaluate
Description copied from interface:QueryableDataTry to evaluate a basic query- Specified by:
evaluatein interfaceQueryableData- Parameters:
query- the query to evaluate- Returns:
- Empty if the query is not evaluable, otherwise a stream containing substitutions that are the answers to the query
- Throws:
EvaluationException- if query evaluation fails
-
evaluate
public Stream<List<Term>> evaluate(BasicQuery query, List<Integer> sequenceOfAnswerVariables) throws EvaluationException Description copied from interface:QueryableDataTry to evaluate a basic query- Specified by:
evaluatein interfaceQueryableData- Parameters:
query- the query to evaluatesequenceOfAnswerVariables- the sequence of answer variables that define the signature of the resulting tuple- Returns:
- Empty if the query is not evaluable, otherwise a stream containing lists of term ; each list corresponds to the substitution of the answer variables with the corresponding terms
- Throws:
EvaluationException- if query evaluation fails
-
estimateBound
Description copied from interface:QueryableDataEstimate the number of answers to a query The estimation is the upper bound, meaning the actual number of answers will not exceed this number. Implementations may return an empty Optional if they cannot provide an estimation.- Specified by:
estimateBoundin interfaceQueryableData- Parameters:
query- the query for which we want to know the upper bound- Returns:
- an Optional containing the estimated upper bound of answers, or an empty Optional if estimation is not possible
-
getAtomicPattern
Description copied from interface:QueryableDataGet the basic pattern for a given predicate- Specified by:
getAtomicPatternin interfaceQueryableData- Parameters:
predicate- the predicate for which we want to know the basic pattern- Returns:
- a basic pattern for predicate
-
getName
Description copied from interface:DataSourceReturns the optional user-facing name of this data source.- Specified by:
getNamein interfaceDataSource<NativeQueryType, NativeResultType>- Returns:
- an optional that contains the datasource name if there is one
-
setName
Description copied from interface:DataSourceSets the user-facing name of this data source.- Specified by:
setNamein interfaceDataSource<NativeQueryType, NativeResultType>- Parameters:
name- the new datasource name
-