Class TimelyMemory<Timestamp extends java.lang.Comparable<Timestamp>>

  • All Implemented Interfaces:
    Clearable, Resumable<Timestamp>, UnmaskedResumable<Timestamp>

    public class TimelyMemory<Timestamp extends java.lang.Comparable<Timestamp>>
    extends java.lang.Object
    implements Clearable, UnmaskedResumable<Timestamp>
    A timely memory implementation that incrementally maintains the Timelines of tuples. The memory is capable of lazy folding (see Resumable).
    Since:
    2.3
    • Constructor Detail

      • TimelyMemory

        public TimelyMemory()
      • TimelyMemory

        public TimelyMemory​(boolean isLazy)
    • Method Detail

      • getResumableTimestamp

        public Timestamp getResumableTimestamp()
        Description copied from interface: Resumable
        Returns the smallest timestamp where lazy folding shall be resumed, or null if there is no more folding to do in this resumable.
        Specified by:
        getResumableTimestamp in interface Resumable<Timestamp extends java.lang.Comparable<Timestamp>>
      • addFoldingState

        protected void addFoldingState​(Tuple tuple,
                                       TimelyMemory.FoldingState state,
                                       Timestamp timestamp)
        Registers the given folding state for the specified timestamp and tuple. If there is already a state stored, the two states will be merged together.
      • resumeAt

        public java.util.Map<Tuple,​Diff<Timestamp>> resumeAt​(Timestamp timestamp)
        Description copied from interface: UnmaskedResumable
        When called, the folding of the state shall be resumed at the given timestamp. The resumable is expected to do a folding step at the given timestamp only. Afterwards, folding shall be interrupted, even if there is more folding to do towards higher timestamps.
        Specified by:
        resumeAt in interface UnmaskedResumable<Timestamp extends java.lang.Comparable<Timestamp>>
      • computeDiffsLazy

        protected void computeDiffsLazy​(Direction direction,
                                        int oldCumulative,
                                        int newCumulative,
                                        Timestamp timestamp,
                                        Timestamp nextTimestamp,
                                        Diff<Timestamp> diffs)
        Utility method that computes the timeline diffs in case of lazy memories. The diffs will be inserted into the input parameter. This method computes diffs for entire plateaus that spans from timestamp to nextTimestamp. Compared to the eager version of this method, the lazy version makes use of both the old and the new cumulative values because it can happen that the cumulative is incremented by a value that is larger than 1 (as folding states are merged together). This means that we cant decide whether the cumulative became positive by comparing the new value to 1.
      • updateTimeline

        protected void updateTimeline​(Tuple tuple,
                                      Diff<Timestamp> diff)
        Updates and garbage collects the timeline of the given tuple based on the given timeline diff.
      • getTuplesAtInfinity

        public java.util.Set<Tuple> getTuplesAtInfinity()
        Since:
        2.8
      • getCountAtInfinity

        public int getCountAtInfinity()
        Returns the number of tuples that are present at the moment 'infinity'.
      • isPresentAtInfinity

        public boolean isPresentAtInfinity​(Tuple tuple)
        Returns true if the given tuple is present at the moment 'infinity'.
      • isEmpty

        public boolean isEmpty()
      • size

        public int size()
      • keySet

        public java.util.Set<Tuple> keySet()
      • clear

        public void clear()
        Description copied from interface: Clearable
        Clear all partial matchings stored in memory
        Specified by:
        clear in interface Clearable
      • containsKey

        public boolean containsKey​(ITuple tuple)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object