public class TimelyMemory<Timestamp extends java.lang.Comparable<Timestamp>> extends java.lang.Object implements Clearable, UnmaskedResumable<Timestamp>
Timeline
s of tuples. The memory is capable of
lazy folding (see Resumable
).Modifier and Type | Class and Description |
---|---|
protected static class |
TimelyMemory.CumulativeCounter |
protected static class |
TimelyMemory.FoldingState |
protected static class |
TimelyMemory.SignChange |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<Tuple,java.util.TreeMap<Timestamp,TimelyMemory.CumulativeCounter>> |
counters |
protected Diff<Timestamp> |
EMPTY_DIFF |
java.util.TreeMap<Timestamp,java.util.Map<Tuple,TimelyMemory.FoldingState>> |
foldingState |
protected boolean |
isLazy |
protected java.util.Set<Tuple> |
presentAtInfinity |
protected java.util.Map<Tuple,Timeline<Timestamp>> |
timelines |
Constructor and Description |
---|
TimelyMemory() |
TimelyMemory(boolean isLazy) |
Modifier and Type | Method and Description |
---|---|
protected void |
addFoldingState(Tuple tuple,
TimelyMemory.FoldingState state,
Timestamp timestamp)
Registers the given folding state for the specified timestamp and tuple.
|
java.util.Map<Tuple,Timeline<Timestamp>> |
asMap() |
void |
clear()
Clear all partial matchings stored in memory
|
protected TimelyMemory.SignChange |
computeDiffsEager(Direction direction,
TimelyMemory.CumulativeCounter counter,
TimelyMemory.SignChange signChangeAtPrevious,
Timestamp timestamp,
Diff<Timestamp> diffs)
Utility method that computes the timeline diffs in case of eager memories.
|
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.
|
boolean |
containsKey(ITuple tuple) |
protected Diff<Timestamp> |
doFoldingStep(Tuple tuple,
TimelyMemory.FoldingState state,
Timestamp timestamp) |
protected void |
gcCounters(TimelyMemory.CumulativeCounter counter,
Tuple tuple,
Timestamp timestamp)
Garbage collects the counter of the given tuple and timestamp if the new diff is zero.
|
Timeline<Timestamp> |
get(ITuple tuple) |
int |
getCountAtInfinity()
Returns the number of tuples that are present at the moment 'infinity'.
|
protected TimelyMemory.CumulativeCounter |
getCounter(Tuple tuple,
Timestamp timestamp)
On-demand initializes and returns the counter for the given tuple and timestamp.
|
Timestamp |
getResumableTimestamp()
Returns the smallest timestamp where lazy folding shall be resumed, or null if there is no more folding to do in this
resumable.
|
java.util.Set<Tuple> |
getResumableTuples()
Returns the set of tuples for which lazy folding shall be resumed at the next timestamp.
|
java.util.Set<Tuple> |
getTuplesAtInfinity() |
boolean |
isEmpty() |
boolean |
isPresentAtInfinity(Tuple tuple)
Returns true if the given tuple is present at the moment 'infinity'.
|
java.util.Set<Tuple> |
keySet() |
Diff<Timestamp> |
put(Tuple tuple,
Timestamp timestamp) |
protected Diff<Timestamp> |
putEager(Tuple tuple,
Timestamp timestamp) |
protected Diff<Timestamp> |
putLazy(Tuple tuple,
Timestamp timestamp) |
Diff<Timestamp> |
remove(Tuple tuple,
Timestamp timestamp) |
protected Diff<Timestamp> |
removeEager(Tuple tuple,
Timestamp timestamp) |
protected Diff<Timestamp> |
removeLazy(Tuple tuple,
Timestamp timestamp) |
java.util.Map<Tuple,Diff<Timestamp>> |
resumeAt(Timestamp timestamp)
When called, the folding of the state shall be resumed at the given timestamp.
|
int |
size() |
java.lang.String |
toString() |
protected void |
updateTimeline(Tuple tuple,
Diff<Timestamp> diff)
Updates and garbage collects the timeline of the given tuple based on the given timeline diff.
|
protected final java.util.Map<Tuple,java.util.TreeMap<Timestamp extends java.lang.Comparable<Timestamp>,TimelyMemory.CumulativeCounter>> counters
protected final java.util.Map<Tuple,Timeline<Timestamp extends java.lang.Comparable<Timestamp>>> timelines
public final java.util.TreeMap<Timestamp extends java.lang.Comparable<Timestamp>,java.util.Map<Tuple,TimelyMemory.FoldingState>> foldingState
protected final java.util.Set<Tuple> presentAtInfinity
protected final boolean isLazy
public TimelyMemory()
public TimelyMemory(boolean isLazy)
public java.util.Set<Tuple> getResumableTuples()
UnmaskedResumable
getResumableTuples
in interface UnmaskedResumable<Timestamp extends java.lang.Comparable<Timestamp>>
public Timestamp getResumableTimestamp()
Resumable
getResumableTimestamp
in interface Resumable<Timestamp extends java.lang.Comparable<Timestamp>>
protected void addFoldingState(Tuple tuple, TimelyMemory.FoldingState state, Timestamp timestamp)
public java.util.Map<Tuple,Diff<Timestamp>> resumeAt(Timestamp timestamp)
UnmaskedResumable
resumeAt
in interface UnmaskedResumable<Timestamp extends java.lang.Comparable<Timestamp>>
protected Diff<Timestamp> doFoldingStep(Tuple tuple, TimelyMemory.FoldingState state, Timestamp timestamp)
protected TimelyMemory.CumulativeCounter getCounter(Tuple tuple, Timestamp timestamp)
protected void gcCounters(TimelyMemory.CumulativeCounter counter, Tuple tuple, Timestamp timestamp)
protected void computeDiffsLazy(Direction direction, int oldCumulative, int newCumulative, Timestamp timestamp, Timestamp nextTimestamp, Diff<Timestamp> diffs)
protected TimelyMemory.SignChange computeDiffsEager(Direction direction, TimelyMemory.CumulativeCounter counter, TimelyMemory.SignChange signChangeAtPrevious, Timestamp timestamp, Diff<Timestamp> diffs)
TimelyMemory.SignChange
that describes how the sign has changed at the given timestamp.protected void updateTimeline(Tuple tuple, Diff<Timestamp> diff)
public java.util.Set<Tuple> getTuplesAtInfinity()
public int getCountAtInfinity()
public boolean isPresentAtInfinity(Tuple tuple)
public boolean isEmpty()
public int size()
public java.util.Set<Tuple> keySet()
public void clear()
Clearable
public boolean containsKey(ITuple tuple)
public java.lang.String toString()
toString
in class java.lang.Object