public interface IQueryRuntimeContext
AbstractQueryRuntimeContext
instead directly this interface.AbstractQueryRuntimeContext
instead.Modifier and Type | Method and Description |
---|---|
void |
addUpdateListener(IInputKey key,
Tuple seed,
IQueryRuntimeContextListener listener)
Subscribes for updates in the extensional relation identified by the input key, optionally seeded with the given tuple.
|
<V> V |
coalesceTraversals(java.util.concurrent.Callable<V> callable)
The given callable will be executed, and all model traversals will be delayed until the execution is done.
|
boolean |
containsTuple(IInputKey key,
ITuple seed)
Simpler form of
#enumerateTuples(IInputKey, TupleMask, Tuple) in the case where all values of the tuples
are bound by the seed. |
int |
countTuples(IInputKey key,
TupleMask seedMask,
ITuple seed)
Returns the number of tuples in the extensional relation identified by the input key seeded with the given mask and tuple.
|
void |
ensureIndexed(IInputKey key,
IndexingService service)
If the given (enumerable) input key is not yet indexed, the model will be traversed
(after the end of the outermost coalescing block, see
coalesceTraversals(Callable) )
so that the index can be built. |
void |
ensureWildcardIndexing(IndexingService service)
Starts wildcard indexing for the given service.
|
java.lang.Iterable<Tuple> |
enumerateTuples(IInputKey key,
TupleMask seedMask,
ITuple seed)
Returns the tuples in the extensional relation identified by the input key, optionally seeded with the given tuple.
|
java.lang.Iterable<? extends java.lang.Object> |
enumerateValues(IInputKey key,
TupleMask seedMask,
ITuple seed)
Simpler form of
#enumerateTuples(IInputKey, TupleMask, Tuple) in the case where all values of the tuples
are bound by the seed except for one. |
default java.util.Optional<java.lang.Double> |
estimateAverageBucketSize(IInputKey key,
TupleMask groupMask,
Accuracy requiredAccuracy)
Gives an estimate of the average size of different groups the tuples of the given relation are projected into by the given mask
(e.g.
|
java.util.Optional<java.lang.Long> |
estimateCardinality(IInputKey key,
TupleMask groupMask,
Accuracy requiredAccuracy)
Gives an estimate of the number of different groups the tuples of the given relation are projected into by the given mask
(e.g.
|
void |
executeAfterTraversal(java.lang.Runnable runnable)
Execute the given runnable after traversal.
|
IQueryMetaContext |
getMetaContext()
Provides metamodel-specific info independent of the runtime instance model.
|
boolean |
isCoalescing() |
boolean |
isIndexed(IInputKey key,
IndexingService service)
Returns true if index is available for the given key providing the given service.
|
void |
removeUpdateListener(IInputKey key,
Tuple seed,
IQueryRuntimeContextListener listener)
Unsubscribes from updates in the extensional relation identified by the input key, optionally seeded with the given tuple.
|
java.lang.Object |
unwrapElement(java.lang.Object internalElement)
Unwraps the internal representation of the element into its original form
|
Tuple |
unwrapTuple(Tuple internalElements)
Unwraps the tuple of internal representations of elements into their original forms
|
java.lang.Object |
wrapElement(java.lang.Object externalElement)
Wraps the external element into the internal representation that is to be used by the query backend
|
Tuple |
wrapTuple(Tuple externalElements)
Unwraps the tuple of elements into the internal representation that is to be used by the query backend
|
IQueryMetaContext getMetaContext()
<V> V coalesceTraversals(java.util.concurrent.Callable<V> callable) throws java.lang.reflect.InvocationTargetException
Calls may be nested. A single coalesced traversal will happen at the end of the outermost call.
Caution: results returned by the runtime context may be incomplete during the coalescing period, to be corrected by notifications sent during the final coalesced traversal.
For example, if a certain input key is not cached yet, an empty relation may be reported during callable.call()
; the cache will be constructed after the call terminates and notifications will deliver the entire content of the relation.
Non-incremental query backends should therefore never enumerate input keys while coalesced (verify using isCoalescing()
).
callable
- java.lang.reflect.InvocationTargetException
boolean isCoalescing()
coalesceTraversals(Callable)
).boolean isIndexed(IInputKey key, IndexingService service)
java.lang.IllegalArgumentException
- if key is not enumerable or an unknown type, see IQueryMetaContext.isEnumerable(IInputKey)
.void ensureIndexed(IInputKey key, IndexingService service)
coalesceTraversals(Callable)
)
so that the index can be built. It is possible that the base indexer will select a higher indexing level merging
multiple indexing requests to an appropriate level.
Postcondition: After invoking this method, #getIndexed(IInputKey, IndexingService)
for the same key
and service will be guaranteed to return the requested or a highing indexing level as soon as isCoalescing()
first returns false.
Precondition: the given key is enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.
java.lang.IllegalArgumentException
- if key is not enumerable or an unknown type, see IQueryMetaContext.isEnumerable(IInputKey)
.int countTuples(IInputKey key, TupleMask seedMask, ITuple seed)
key
- an input keyseedMask
- a mask that extracts those parameters of the input key (from the entire parameter list) that should be
bound to a fixed value; must not be null. Note: any given index must occur at most once in seedMask.seed
- 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 hold. Must not be null.Precondition: the given key is enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.
java.lang.IllegalArgumentException
- if key is not enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.java.util.Optional<java.lang.Long> estimateCardinality(IInputKey key, TupleMask groupMask, Accuracy requiredAccuracy)
Must accept any input key, even non-enumerables or those not recognized by this runtime context.
If there is insufficient information to provide an answer up to the required precision, Optional.empty()
is returned.
PRE: TupleMask.isNonrepeating()
must hold for the group mask.
default java.util.Optional<java.lang.Double> estimateAverageBucketSize(IInputKey key, TupleMask groupMask, Accuracy requiredAccuracy)
Must accept any input key, even non-enumerables or those not recognized by this runtime context.
If there is insufficient information to provide an answer up to the required precision, Optional.empty()
may be returned.
For an empty relation, zero is acceptable as an exact answer.
PRE: TupleMask.isNonrepeating()
must hold for the group mask.
java.lang.Iterable<Tuple> enumerateTuples(IInputKey key, TupleMask seedMask, ITuple seed)
key
- an input keyseedMask
- a mask that extracts those parameters of the input key (from the entire parameter list) that should be
bound to a fixed value; must not be null. Note: any given index must occur at most once in seedMask.seed
- 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 hold. Must not be null.Precondition: the given key is enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.
java.lang.IllegalArgumentException
- if key is not enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.java.lang.Iterable<? extends java.lang.Object> enumerateValues(IInputKey key, TupleMask seedMask, ITuple seed)
#enumerateTuples(IInputKey, TupleMask, Tuple)
in the case where all values of the tuples
are bound by the seed except for one.
Selects the tuples in the extensional relation identified by the input key, optionally seeded with the given tuple, and then returns the single value from each tuple which is not bound by the ssed mask.
key
- an input keyseedMask
- a mask that extracts those parameters of the input key (from the entire parameter list) that should be
bound to a fixed value; must not be null. Note: any given index must occur at most
once in seedMask, and seedMask must include all parameters in any arbitrary order except one.seed
- 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 hold. Must not be null.
Precondition: the given key is enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.
java.lang.IllegalArgumentException
- if key is not enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.boolean containsTuple(IInputKey key, ITuple seed)
#enumerateTuples(IInputKey, TupleMask, Tuple)
in the case where all values of the tuples
are bound by the seed.
Returns whether the given tuple is in the extensional relation identified by the input key.
Note: this call works for non-enumerable input keys as well.
key
- an input keyseed
- 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 hold. Must not be null.void addUpdateListener(IInputKey key, Tuple seed, IQueryRuntimeContextListener listener)
This should be called after invoking
key
- an input keyseed
- can be null or a tuple with matching arity;
if non-null, only those updates in the model are notified about
that match the seed at positions where the seed is non-null.listener
- will be notified of future changes
Precondition: the given key is enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.
java.lang.IllegalArgumentException
- if key is not enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.void removeUpdateListener(IInputKey key, Tuple seed, IQueryRuntimeContextListener listener)
key
- an input keyseed
- can be null or a tuple with matching arity;
if non-null, only those updates in the model are notified about
that match the seed at positions where the seed is non-null.listener
- will no longer be notified of future changes
Precondition: the given key is enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.
java.lang.IllegalArgumentException
- if key is not enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.java.lang.Object wrapElement(java.lang.Object externalElement)
model element -> internal object.
null must be mapped to null.
java.lang.Object unwrapElement(java.lang.Object internalElement)
internal object -> model element
null must be mapped to null.
Tuple wrapTuple(Tuple externalElements)
model elements -> internal objects
null must be mapped to null.
Tuple unwrapTuple(Tuple internalElements)
internal objects -> model elements
null must be mapped to null.
void ensureWildcardIndexing(IndexingService service)
IndexingService
.
a previously set wildcard level cannot be lowered, only extended.void executeAfterTraversal(java.lang.Runnable runnable) throws java.lang.reflect.InvocationTargetException
traversalCallback
- java.lang.reflect.InvocationTargetException