Class DisjointUnionTable
- java.lang.Object
-
- org.eclipse.viatra.query.runtime.matchers.scopes.tables.AbstractIndexTable
-
- org.eclipse.viatra.query.runtime.matchers.scopes.tables.DisjointUnionTable
-
- All Implemented Interfaces:
IIndexTable
public class DisjointUnionTable extends AbstractIndexTable
Disjoint union of the provided child tables. Used e.g. to present a transitive instance table as a view composed from direct instance tables.EXPERIMENTAL. This class or interface has been added as part of a work in progress. There is no guarantee that this API will work or that it will remain the same.
- Since:
- 2.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.viatra.query.runtime.matchers.scopes.tables.AbstractIndexTable
AbstractIndexTable.ColumnBoundListeners, AbstractIndexTable.GenericBoundListeners, AbstractIndexTable.IListenersWithSameMask, AbstractIndexTable.UniversalListeners
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<IIndexTable>
childTables
-
Fields inherited from class org.eclipse.viatra.query.runtime.matchers.scopes.tables.AbstractIndexTable
emitNotifications, emptyMask, emptyTuple, listenerGroups, tableContext
-
-
Constructor Summary
Constructors Constructor Description DisjointUnionTable(IInputKey inputKey, ITableContext tableContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChildTable(IIndexTable child)
Precondition: the new child currently is, and will forever stay, disjoint from any other child tables.void
addUpdateListener(Tuple seed, IQueryRuntimeContextListener listener)
Subscribes for updates in the table, optionally seeded with the given tuple.boolean
containsTuple(ITuple seed)
Simpler form ofIIndexTable.enumerateTuples(TupleMask, ITuple)
in the case where all values of the tuples are bound by the seed.int
countTuples(TupleMask seedMask, ITuple seed)
Returns the number of tuples, optionally seeded with the given tuple.java.util.Optional<java.lang.Long>
estimateProjectionSize(TupleMask groupMask, Accuracy requiredAccuracy)
Gives an estimate of the number of different groups the tuples of the table are projected into by the given mask (e.g.java.util.List<IIndexTable>
getChildTables()
void
removeUpdateListener(Tuple seed, IQueryRuntimeContextListener listener)
Unsubscribes from updates in the table, optionally seeded with the given tuple.java.util.stream.Stream<? extends Tuple>
streamTuples(TupleMask seedMask, ITuple seed)
Returns the tuples, optionally seeded with the given tuple.java.util.stream.Stream<? extends java.lang.Object>
streamValues(TupleMask seedMask, ITuple seed)
Simpler form ofIIndexTable.enumerateTuples(TupleMask, ITuple)
in the case where all values of the tuples are bound by the seed except for one.-
Methods inherited from class org.eclipse.viatra.query.runtime.matchers.scopes.tables.AbstractIndexTable
deliverChangeNotifications, getInputKey, getListenerGroup, logError, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.viatra.query.runtime.matchers.scopes.tables.IIndexTable
enumerateTuples, enumerateValues
-
-
-
-
Field Detail
-
childTables
protected java.util.List<IIndexTable> childTables
-
-
Constructor Detail
-
DisjointUnionTable
public DisjointUnionTable(IInputKey inputKey, ITableContext tableContext)
-
-
Method Detail
-
getChildTables
public java.util.List<IIndexTable> getChildTables()
-
addChildTable
public void addChildTable(IIndexTable child)
Precondition: the new child currently is, and will forever stay, disjoint from any other child tables.
-
countTuples
public int countTuples(TupleMask seedMask, ITuple seed)
Description copied from interface:IIndexTable
Returns the number of tuples, optionally seeded with the given tuple.Selects the tuples in the table, optionally seeded with the given tuple, and then returns their number.
- Parameters:
seedMask
- 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 row set to be considered, in the same order as given in parameterSeedMask, so that for each considered row tuple, projectedParameterSeed.equals(parameterSeedMask.transform(row)) should hold. Must not be null.- Returns:
- the number of tuples in the table for the given key and seed
-
estimateProjectionSize
public java.util.Optional<java.lang.Long> estimateProjectionSize(TupleMask groupMask, Accuracy requiredAccuracy)
Description copied from interface:IIndexTable
Gives an estimate of the number of different groups the tuples of the table are projected into by the given mask (e.g. for an identity mask, this means the full relation size). The estimate must meet the required accuracy.Derived tables may return
Optional.empty()
if it would be costly to provide an answer up to the required precision. Direct storage tables are expected to always be able to give an exact count.PRE:
TupleMask.isNonrepeating()
must hold for the group mask.
-
streamTuples
public java.util.stream.Stream<? extends Tuple> streamTuples(TupleMask seedMask, ITuple seed)
Description copied from interface:IIndexTable
Returns the tuples, optionally seeded with the given tuple.- Parameters:
seedMask
- 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 row set to be considered, in the same order as given in parameterSeedMask, so that for each considered row tuple, projectedParameterSeed.equals(parameterSeedMask.transform(row)) should hold. Must not be null.- Returns:
- the tuples in the table for the given key and seed
-
streamValues
public java.util.stream.Stream<? extends java.lang.Object> streamValues(TupleMask seedMask, ITuple seed)
Description copied from interface:IIndexTable
Simpler form ofIIndexTable.enumerateTuples(TupleMask, ITuple)
in the case where all values of the tuples are bound by the seed except for one.Selects the tuples in the table, optionally seeded with the given tuple, and then returns the single value from each tuple which is not bound by the seed mask.
- Parameters:
seedMask
- 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 row set to be considered, in the same order as given in parameterSeedMask, so that for each considered row tuple, projectedParameterSeed.equals(parameterSeedMask.transform(row)) should hold. Must not be null.- Returns:
- the objects in the table for the given key and seed
-
containsTuple
public boolean containsTuple(ITuple seed)
Description copied from interface:IIndexTable
Simpler form ofIIndexTable.enumerateTuples(TupleMask, ITuple)
in the case where all values of the tuples are bound by the seed.Returns whether the given tuple is in the table identified by the input key.
- Parameters:
seed
- a row tuple of fixed values whose presence in the table is queried- Returns:
- true iff there is a row tuple contained in the table that corresponds to the given seed
-
addUpdateListener
public void addUpdateListener(Tuple seed, IQueryRuntimeContextListener listener)
Description copied from interface:IIndexTable
Subscribes for updates in the table, optionally seeded with the given tuple.This should be called after initializing a result cache by an enumeration method.
- Specified by:
addUpdateListener
in interfaceIIndexTable
- Overrides:
addUpdateListener
in classAbstractIndexTable
- Parameters:
seed
- can be null or a tuple with matching arity; if non-null, notifications will delivered only about those updates of the table that match the seed at positions where the seed is non-null.listener
- will be notified of future changes
-
removeUpdateListener
public void removeUpdateListener(Tuple seed, IQueryRuntimeContextListener listener)
Description copied from interface:IIndexTable
Unsubscribes from updates in the table, optionally seeded with the given tuple.- Specified by:
removeUpdateListener
in interfaceIIndexTable
- Overrides:
removeUpdateListener
in classAbstractIndexTable
- Parameters:
seed
- can be null or a tuple with matching arity; seeIIndexTable.addUpdateListener(Tuple, IQueryRuntimeContextListener)
for definition.listener
- will no longer be notified of future changes
-
-