Class 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
    • Field Detail

      • childTables

        protected java.util.List<IIndexTable> childTables
    • 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 of IIndexTable.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 of IIndexTable.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 interface IIndexTable
        Overrides:
        addUpdateListener in class AbstractIndexTable
        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