public abstract class AbstractLocalSearchResultProvider extends java.lang.Object implements IQueryResultProvider
Modifier and Type | Field and Description |
---|---|
protected LocalSearchBackend |
backend |
protected IQueryBackendContext |
backendContext |
protected java.util.Map<PQuery,LocalSearchHints> |
hintCache |
protected IPlanProvider |
planProvider |
protected PQuery |
query |
protected ResultProviderRequestor |
resultProviderRequestor |
protected IQueryRuntimeContext |
runtimeContext |
protected ISearchContext |
searchContext |
protected QueryEvaluationHint |
userHints |
Constructor and Description |
---|
AbstractLocalSearchResultProvider(LocalSearchBackend backend,
IQueryBackendContext context,
PQuery query,
IPlanProvider planProvider,
QueryEvaluationHint userHints) |
Modifier and Type | Method and Description |
---|---|
void |
addUpdateListener(IUpdateable listener,
java.lang.Object listenerTag,
boolean fireNow)
Internal method that registers low-level callbacks for match appearance and disappearance.
|
int |
countMatches(java.lang.Object[] parameters)
Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
|
int |
countMatches(TupleMask parameterSeedMask,
ITuple parameters)
Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
|
java.util.Optional<java.lang.Double> |
estimateAverageBucketSize(TupleMask groupMask,
Accuracy requiredAccuracy)
Gives an estimate of the average size of different groups the matches are projected into by the given mask
(e.g.
|
java.util.Optional<java.lang.Long> |
estimateCardinality(TupleMask groupMask,
Accuracy requiredAccuracy)
Gives an estimate of the number of different groups the matches are projected into by the given mask
(e.g.
|
double |
estimateCost(TupleMask inputBindingMask) |
void |
forgetAllPlans()
Forgets all stored plans in this result provider.
|
java.util.stream.Stream<Tuple> |
getAllMatches(java.lang.Object[] parameters)
Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
|
java.util.stream.Stream<Tuple> |
getAllMatches(TupleMask parameterSeedMask,
ITuple parameters)
Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
|
IMatcherCapability |
getCapabilites() |
java.util.Optional<Tuple> |
getOneArbitraryMatch(java.lang.Object[] parameters)
Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
|
java.util.Optional<Tuple> |
getOneArbitraryMatch(TupleMask parameterSeedMask,
ITuple parameters)
Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
|
protected abstract IOperationCompiler |
getOperationCompiler(IQueryBackendContext backendContext,
LocalSearchHints configuration) |
IQueryBackend |
getQueryBackend()
The underlying query evaluator backend.
|
IPlanDescriptor |
getSearchPlan(java.util.Set<PParameter> adornment)
Returns a search plan for a given adornment if exists
|
boolean |
hasMatch(java.lang.Object[] parameters)
Decides whether there are any matches of the pattern that conform to the given fixed values of some parameters.
|
boolean |
hasMatch(TupleMask parameterSeedMask,
ITuple parameters)
Decides whether there are any matches of the pattern that conform to the given fixed values of some parameters.
|
protected void |
indexInitializationBeforePlanning()
This method is called before planning start to allow indexing.
|
protected void |
indexReferredTypesOfQuery(PQuery query,
IndexingService requiredIndexingServices)
Collects and indexes all types _directly_ referred by the PQuery
query . |
LocalSearchMatcher |
newLocalSearchMatcher(ITuple parameters) |
LocalSearchMatcher |
newLocalSearchMatcher(java.lang.Object[] parameters) |
void |
prepare()
Prepare this result provider.
|
protected void |
prepareDirectDependencies() |
protected void |
preparePlansForExpectedAdornments() |
void |
removeUpdateListener(java.lang.Object listenerTag)
Removes an existing listener previously registered with the given tag.
|
protected final LocalSearchBackend backend
protected final IQueryBackendContext backendContext
protected final IQueryRuntimeContext runtimeContext
protected final PQuery query
protected final QueryEvaluationHint userHints
protected final java.util.Map<PQuery,LocalSearchHints> hintCache
protected final IPlanProvider planProvider
protected final ISearchContext searchContext
protected ResultProviderRequestor resultProviderRequestor
public AbstractLocalSearchResultProvider(LocalSearchBackend backend, IQueryBackendContext context, PQuery query, IPlanProvider planProvider, QueryEvaluationHint userHints)
protected abstract IOperationCompiler getOperationCompiler(IQueryBackendContext backendContext, LocalSearchHints configuration)
public void prepare()
protected void preparePlansForExpectedAdornments()
protected void prepareDirectDependencies()
protected void indexInitializationBeforePlanning()
ViatraQueryRuntimeException
protected void indexReferredTypesOfQuery(PQuery query, IndexingService requiredIndexingServices)
query
. Types indirectrequiredIndexingServices
- public LocalSearchMatcher newLocalSearchMatcher(ITuple parameters)
ViatraQueryRuntimeException
public LocalSearchMatcher newLocalSearchMatcher(java.lang.Object[] parameters)
ViatraQueryRuntimeException
public boolean hasMatch(java.lang.Object[] parameters)
IQueryResultProvider
hasMatch
in interface IQueryResultProvider
parameters
- array where each non-null element binds the corresponding pattern parameter to a fixed value.public boolean hasMatch(TupleMask parameterSeedMask, ITuple parameters)
IQueryResultProvider
hasMatch
in interface IQueryResultProvider
parameterSeedMask
- a mask that extracts those parameters of the query (from the entire parameter list) that should be
bound to a fixed valuepublic java.util.Optional<Tuple> getOneArbitraryMatch(java.lang.Object[] parameters)
IQueryResultProvider
getOneArbitraryMatch
in interface IQueryResultProvider
parameters
- array where each non-null element binds the corresponding pattern parameter to a fixed value.Tuple
representation.public java.util.Optional<Tuple> getOneArbitraryMatch(TupleMask parameterSeedMask, ITuple parameters)
IQueryResultProvider
getOneArbitraryMatch
in interface IQueryResultProvider
parameterSeedMask
- a mask that extracts those parameters of the query (from the entire parameter list) that should be
bound to a fixed valueparameters
- the tuple of fixed values restricting the match set to be considered, in the same order as given in
parameterSeedMask, so that for each considered match tuple,
projectedParameterSeed.equals(parameterSeedMask.transform(match)) should holdTuple
representation.public int countMatches(java.lang.Object[] parameters)
IQueryResultProvider
countMatches
in interface IQueryResultProvider
parameters
- array where each non-null element binds the corresponding pattern parameter to a fixed value.public int countMatches(TupleMask parameterSeedMask, ITuple parameters)
IQueryResultProvider
countMatches
in interface IQueryResultProvider
parameterSeedMask
- a mask that extracts those parameters of the query (from the entire parameter list) that should be
bound to a fixed valuepublic java.util.Optional<java.lang.Long> estimateCardinality(TupleMask groupMask, Accuracy requiredAccuracy)
IQueryResultProvider
If there is insufficient information to provide an answer up to the required precision, Optional.empty()
may be returned.
In other words, query backends may deny an answer, or do their best to give an estimate without actually determining the match set of the query.
However, caching backends are expected to simply return the indexed (projection) size, initialized on-demand if necessary.
PRE: TupleMask.isNonrepeating()
must hold for the group mask.
estimateCardinality
in interface IQueryResultProvider
public java.util.Optional<java.lang.Double> estimateAverageBucketSize(TupleMask groupMask, Accuracy requiredAccuracy)
IQueryResultProvider
If there is insufficient information to provide an answer up to the required precision, Optional.empty()
may be returned.
In other words, query backends may deny an answer, or do their best to give an estimate without actually determining the match set of the query.
However, caching backends are expected to simply return the exact value from the index, initialized on-demand if necessary.
For an empty match set, zero is acceptable as an exact answer.
PRE: TupleMask.isNonrepeating()
must hold for the group mask.
estimateAverageBucketSize
in interface IQueryResultProvider
public double estimateCost(TupleMask inputBindingMask)
public java.util.stream.Stream<Tuple> getAllMatches(java.lang.Object[] parameters)
IQueryResultProvider
getAllMatches
in interface IQueryResultProvider
parameters
- array where each non-null element binds the corresponding pattern parameter to a fixed value.Tuple
representation.public java.util.stream.Stream<Tuple> getAllMatches(TupleMask parameterSeedMask, ITuple parameters)
IQueryResultProvider
getAllMatches
in interface IQueryResultProvider
parameterSeedMask
- a mask that extracts those parameters of the query (from the entire parameter list) that should be
bound to a fixed valueparameters
- the tuple of fixed values restricting the match set to be considered, in the same order as given in
parameterSeedMask, so that for each considered match tuple,
projectedParameterSeed.equals(parameterSeedMask.transform(match)) should holdTuple
representation.public IQueryBackend getQueryBackend()
IQueryResultProvider
getQueryBackend
in interface IQueryResultProvider
public void addUpdateListener(IUpdateable listener, java.lang.Object listenerTag, boolean fireNow)
IQueryResultProvider
Caution: This is a low-level callback that is invoked when the pattern matcher is not necessarily in a consistent state yet. Importantly, no model modification permitted during the callback.
The callback can be unregistered via invoking IQueryResultProvider.removeUpdateListener(Object)
with the same tag.
addUpdateListener
in interface IQueryResultProvider
listener
- the listener that will be notified of each new match that appears or disappears, starting from now.listenerTag
- a tag by which to identify the listener for later removal by IQueryResultProvider.removeUpdateListener(Object)
.fireNow
- if true, the insertion update allback will be immediately invoked on all current matches as a one-time effect.public void removeUpdateListener(java.lang.Object listenerTag)
IQueryResultProvider
removeUpdateListener
in interface IQueryResultProvider
public IMatcherCapability getCapabilites()
public void forgetAllPlans()
LocalSearchBackend
.public IPlanDescriptor getSearchPlan(java.util.Set<PParameter> adornment)
LocalSearchBackend
.