public class EMFQueryRuntimeContext extends AbstractQueryRuntimeContext
Modifier and Type | Field and Description |
---|---|
protected NavigationHelper |
baseIndex |
protected java.util.Map<org.eclipse.emf.ecore.EClass,java.util.EnumSet<IndexingService>> |
indexedClasses |
protected java.util.Map<org.eclipse.emf.ecore.EDataType,java.util.EnumSet<IndexingService>> |
indexedDataTypes |
protected java.util.Map<org.eclipse.emf.ecore.EStructuralFeature,java.util.EnumSet<IndexingService>> |
indexedFeatures |
protected org.apache.log4j.Logger |
logger |
protected EMFQueryMetaContext |
metaContext |
Constructor and Description |
---|
EMFQueryRuntimeContext(NavigationHelper baseIndex,
org.apache.log4j.Logger logger,
EMFScope emfScope) |
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,
Tuple seed)
Simpler form of
IQueryRuntimeContext.enumerateTuples(IInputKey, Tuple) in the case where all values of the tuples are bound by the seed. |
int |
countTuples(IInputKey key,
Tuple seed)
Returns the number of tuples in the extensional relation identified by the input key, optionally seeded with the given tuple.
|
void |
dispose() |
void |
ensureEnumerableKey(IInputKey key) |
void |
ensureIndexed(org.eclipse.emf.ecore.EClass eClass)
Deprecated.
use
ensureIndexed(EClass, IndexingService) instead |
void |
ensureIndexed(org.eclipse.emf.ecore.EClass eClass,
IndexingService service) |
void |
ensureIndexed(org.eclipse.emf.ecore.EDataType eDataType)
Deprecated.
use
ensureIndexed(EDataType, IndexingService) instead |
void |
ensureIndexed(org.eclipse.emf.ecore.EDataType eDataType,
IndexingService service) |
void |
ensureIndexed(org.eclipse.emf.ecore.EStructuralFeature feature)
Deprecated.
|
void |
ensureIndexed(org.eclipse.emf.ecore.EStructuralFeature feature,
IndexingService service) |
void |
ensureIndexed(IInputKey key)
If the given (enumerable) input key is not yet indexed, the model will be traversed
(after the end of the outermost coalescing block, see
IQueryRuntimeContext.coalesceTraversals(Callable) )
so that the index can be built. |
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
IQueryRuntimeContext.coalesceTraversals(Callable) )
so that the index can be built. |
void |
ensureValidKey(IInputKey key) |
void |
ensureWildcardIndexing(IndexingService service)
Starts wildcard indexing for the given service.
|
java.lang.Iterable<Tuple> |
enumerateTuples(IInputKey key,
Tuple 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,
Tuple seed)
Simpler form of
IQueryRuntimeContext.enumerateTuples(IInputKey, Tuple) in the case where all values of the tuples are bound by the seed except for one. |
void |
executeAfterTraversal(java.lang.Runnable runnable)
Execute the given runnable after traversal.
|
protected java.util.EnumSet<IndexingService> |
getCurrentIndexingServiceFor(IInputKey key)
Retrieve the current registered indexing services for the given key.
|
EMFScope |
getEmfScope() |
IQueryMetaContext |
getMetaContext()
Provides metamodel-specific info independent of the runtime instance model.
|
void |
illegalEnumerateValues(Tuple seed) |
void |
illegalInputKey(IInputKey key) |
boolean |
isCoalescing() |
boolean |
isIndexed(IInputKey key) |
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
|
protected final NavigationHelper baseIndex
protected final java.util.Map<org.eclipse.emf.ecore.EClass,java.util.EnumSet<IndexingService>> indexedClasses
protected final java.util.Map<org.eclipse.emf.ecore.EDataType,java.util.EnumSet<IndexingService>> indexedDataTypes
protected final java.util.Map<org.eclipse.emf.ecore.EStructuralFeature,java.util.EnumSet<IndexingService>> indexedFeatures
protected final EMFQueryMetaContext metaContext
protected org.apache.log4j.Logger logger
public EMFQueryRuntimeContext(NavigationHelper baseIndex, org.apache.log4j.Logger logger, EMFScope emfScope)
public EMFScope getEmfScope()
public void dispose()
public <V> V coalesceTraversals(java.util.concurrent.Callable<V> callable) throws java.lang.reflect.InvocationTargetException
IQueryRuntimeContext
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 IQueryRuntimeContext.isCoalescing()
).
java.lang.reflect.InvocationTargetException
public boolean isCoalescing()
IQueryRuntimeContext.coalesceTraversals(Callable)
).public IQueryMetaContext getMetaContext()
IQueryRuntimeContext
public void ensureIndexed(IInputKey key, IndexingService service)
IQueryRuntimeContext
IQueryRuntimeContext.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 IQueryRuntimeContext.isCoalescing()
first returns false.
Precondition: the given key is enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.
ensureIndexed
in interface IQueryRuntimeContext
ensureIndexed
in class AbstractQueryRuntimeContext
public void ensureIndexed(IInputKey key)
IQueryRuntimeContext
IQueryRuntimeContext.coalesceTraversals(Callable)
)
so that the index can be built.
Postcondition: After invoking this method, IQueryRuntimeContext.isIndexed(IInputKey)
for the same key
will be guaranteed to return true as soon as IQueryRuntimeContext.isCoalescing()
first returns false.
Precondition: the given key is enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.
protected java.util.EnumSet<IndexingService> getCurrentIndexingServiceFor(IInputKey key)
public boolean isIndexed(IInputKey key, IndexingService service)
IQueryRuntimeContext
isIndexed
in interface IQueryRuntimeContext
isIndexed
in class AbstractQueryRuntimeContext
public boolean isIndexed(IInputKey key)
public boolean containsTuple(IInputKey key, Tuple seed)
IQueryRuntimeContext
IQueryRuntimeContext.enumerateTuples(IInputKey, 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
- a tuple with matching arity, consisting of non-null elements (null can be used in the 0-ary case).public java.lang.Iterable<Tuple> enumerateTuples(IInputKey key, Tuple seed)
IQueryRuntimeContext
key
- an input keyseed
- can be null or a tuple with matching arity;
if non-null, only those tuples in the model are enumerated
that match the seed at positions where the seed is non-null.Precondition: the given key is enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.
public java.lang.Iterable<? extends java.lang.Object> enumerateValues(IInputKey key, Tuple seed)
IQueryRuntimeContext
IQueryRuntimeContext.enumerateTuples(IInputKey, 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 corresponds to the only null value in the seed.
key
- an input keyseed
- can be null (if key is unary) or a tuple with matching arity;
if non-null, only those tuples in the model are enumerated
that match the seed at positions where the seed is non-null;
the seed is null at exactly one position.Precondition: the given key is enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.
public int countTuples(IInputKey key, Tuple seed)
IQueryRuntimeContext
key
- an input keyseed
- can be null or a tuple with matching arity;
if non-null, only those tuples in the model are counted
that match the seed at positions where the seed is non-null.Precondition: the given key is enumerable, see IQueryMetaContext.isEnumerable(IInputKey)
.
public void ensureEnumerableKey(IInputKey key)
public void ensureValidKey(IInputKey key)
public void illegalInputKey(IInputKey key)
public void illegalEnumerateValues(Tuple seed)
@Deprecated public void ensureIndexed(org.eclipse.emf.ecore.EClass eClass)
ensureIndexed(EClass, IndexingService)
insteadeClass
- public void ensureIndexed(org.eclipse.emf.ecore.EClass eClass, IndexingService service)
@Deprecated public void ensureIndexed(org.eclipse.emf.ecore.EDataType eDataType)
ensureIndexed(EDataType, IndexingService)
insteadeDataType
- public void ensureIndexed(org.eclipse.emf.ecore.EDataType eDataType, IndexingService service)
@Deprecated public void ensureIndexed(org.eclipse.emf.ecore.EStructuralFeature feature)
ensureIndexed(EStructuralFeature, IndexingService)
insteadfeature
- public void ensureIndexed(org.eclipse.emf.ecore.EStructuralFeature feature, IndexingService service)
public void addUpdateListener(IInputKey key, Tuple seed, IQueryRuntimeContextListener listener)
IQueryRuntimeContext
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)
.
public void removeUpdateListener(IInputKey key, Tuple seed, IQueryRuntimeContextListener listener)
IQueryRuntimeContext
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)
.
public java.lang.Object unwrapElement(java.lang.Object internalElement)
IQueryRuntimeContext
internal object -> model element
null must be mapped to null.
public Tuple unwrapTuple(Tuple internalElements)
IQueryRuntimeContext
internal objects -> model elements
null must be mapped to null.
public java.lang.Object wrapElement(java.lang.Object externalElement)
IQueryRuntimeContext
model element -> internal object.
null must be mapped to null.
public Tuple wrapTuple(Tuple externalElements)
IQueryRuntimeContext
model elements -> internal objects
null must be mapped to null.
public void ensureWildcardIndexing(IndexingService service)
IQueryRuntimeContext
IndexingService
.
a previously set wildcard level cannot be lowered, only extended.public void executeAfterTraversal(java.lang.Runnable runnable) throws java.lang.reflect.InvocationTargetException
IQueryRuntimeContext
java.lang.reflect.InvocationTargetException