Class TimelyDefaultMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
java.lang.Object
tools.refinery.interpreter.matchers.memories.MaskedTupleMemory<Timestamp>
tools.refinery.interpreter.matchers.memories.timely.TimelyDefaultMaskedTupleMemory<Timestamp>
- All Implemented Interfaces:
Clearable
,MaskedResumable<Timestamp>
,Resumable<Timestamp>
public final class TimelyDefaultMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
extends MaskedTupleMemory<Timestamp>
Default timely implementation that covers all cases.
- Since:
- 2.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final boolean
protected final Map
<Tuple, TimelyMemory<Timestamp>> Fields inherited from class tools.refinery.interpreter.matchers.memories.MaskedTupleMemory
mask, owner
-
Constructor Summary
ConstructorsConstructorDescriptionTimelyDefaultMaskedTupleMemory
(TupleMask mask, Object owner, boolean isLazy) -
Method Summary
Modifier and TypeMethodDescriptionaddInternal
(Tuple key, Tuple tuple, Timestamp timestamp) addWithTimestamp
(Tuple tuple, Timestamp timestamp) Adds a tuple occurrence to the memory with the given timestamp.addWithTimestamp
(Tuple tuple, Tuple signature, Timestamp timestamp) Adds a tuple occurrence to the memory with the given signature and timestamp.void
clear()
Clear all partial matchings stored in memoryRetrieves tuples that have the specified signatureprotected Collection
<Tuple> getInternal
(Tuple key) int
Returns the set of signatures for which lazy folding shall be resumed at the next timestamp.Returns the smallest timestamp where lazy folding shall be resumed, or null if there is no more folding to do in this resumable.Retrieves a read-only view of exactly those signatures for which at least one tuple is storedint
getWithTimeline
(ITuple signature) Retrieves the tuples and their associated timelines that have the specified signature.void
initializeWith
(MaskedTupleMemory<Timestamp> other, Timestamp defaultValue) Initializes the contents of this memory based on the contents of another memory.boolean
isPresentAtInfinity
(ITuple signature) Returns true if there is any tuple with the given signature that is present at the timestamp +inf, false otherwise.boolean
boolean
isTimely()
Returns true of this memory is timely, false otherwise.iterator()
Iterates over distinct tuples stored in the memory, regardless of their signatures.protected void
registerFoldingState
(Timestamp timestamp, Tuple key) removeInternal
(Tuple key, Tuple tuple, Timestamp timestamp) removeWithTimestamp
(Tuple tuple, Timestamp timestamp) Removes a tuple occurrence from the memory with the given timestamp.removeWithTimestamp
(Tuple tuple, Tuple signature, Timestamp timestamp) Removes a tuple occurrence from the memory with the given signature and timestamp.When called, the folding of the state shall be resumed at the given timestamp.protected void
unregisterFoldingState
(Timestamp timestamp, Tuple key) Methods inherited from class tools.refinery.interpreter.matchers.memories.MaskedTupleMemory
add, add, create, create, create, getMask, getOrEmpty, getOrEmptyWithTimeline, getOwner, raiseDuplicateDeletion, raiseDuplicateInsertion, remove, remove, toString
-
Field Details
-
foldingStates
-
memoryMap
-
isLazy
protected final boolean isLazy
-
-
Constructor Details
-
TimelyDefaultMaskedTupleMemory
-
-
Method Details
-
getSignatures
Description copied from class:MaskedTupleMemory
Retrieves a read-only view of exactly those signatures for which at least one tuple is stored- Specified by:
getSignatures
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
-
removeWithTimestamp
Description copied from class:MaskedTupleMemory
Removes a tuple occurrence from the memory with the given signature and timestamp.- Overrides:
removeWithTimestamp
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
- Parameters:
tuple
- the tuple to be removed from the memorysignature
- precomputed footprint of the tuple according to the masktimestamp
- the timestamp associated with the tuple- Returns:
- A
Diff
describing how the timeline of the given tuple changed.
-
addWithTimestamp
Description copied from class:MaskedTupleMemory
Adds a tuple occurrence to the memory with the given signature and timestamp.- Overrides:
addWithTimestamp
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
- Parameters:
tuple
- the tuple to be added to the memorysignature
- precomputed footprint of the tuple according to the masktimestamp
- the timestamp associated with the tuple- Returns:
- A
Diff
describing how the timeline of the given tuple changed.
-
get
Description copied from class:MaskedTupleMemory
Retrieves tuples that have the specified signature- Specified by:
get
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
- Returns:
- collection of tuples found, null if none
-
getWithTimeline
Description copied from class:MaskedTupleMemory
Retrieves the tuples and their associated timelines that have the specified signature.- Specified by:
getWithTimeline
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
- Returns:
- the mappings from tuples to timelines, null if there is no mapping for the signature
-
isPresentAtInfinity
Description copied from class:MaskedTupleMemory
Returns true if there is any tuple with the given signature that is present at the timestamp +inf, false otherwise.- Overrides:
isPresentAtInfinity
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
-
getResumableSignatures
Description copied from interface:MaskedResumable
Returns the set of signatures for which lazy folding shall be resumed at the next timestamp.- Specified by:
getResumableSignatures
in interfaceMaskedResumable<Timestamp extends Comparable<Timestamp>>
- Overrides:
getResumableSignatures
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
-
resumeAt
Description copied from interface:MaskedResumable
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 interfaceMaskedResumable<Timestamp extends Comparable<Timestamp>>
- Overrides:
resumeAt
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
-
initializeWith
Description copied from class:MaskedTupleMemory
Initializes the contents of this memory based on the contents of another memory. The default value is associated with each tuple in the timely memories.- Overrides:
initializeWith
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
-
isPresentAtInfinityInteral
-
clear
public void clear()Description copied from interface:Clearable
Clear all partial matchings stored in memory -
getKeysetSize
public int getKeysetSize()- Specified by:
getKeysetSize
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
- Returns:
- the number of distinct signatures of all stored tuples.
-
getTotalSize
public int getTotalSize()- Specified by:
getTotalSize
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
- Returns:
- the total number of distinct tuples stored. Multiple copies of the same tuple, if allowed, are counted as
one.
This is currently not cached but computed on demand. It is therefore not efficient, and shall only be used for debug / profiling purposes.
-
iterator
Description copied from class:MaskedTupleMemory
Iterates over distinct tuples stored in the memory, regardless of their signatures.- Specified by:
iterator
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
-
getInternal
-
getWithTimestampInternal
-
removeInternal
-
addInternal
-
removeWithTimestamp
Description copied from class:MaskedTupleMemory
Removes a tuple occurrence from the memory with the given timestamp.- Overrides:
removeWithTimestamp
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
- Parameters:
tuple
- the tuple to be removed from the memorytimestamp
- the timestamp associated with the tuple- Returns:
- A
Diff
describing how the timeline of the given tuple changed.
-
addWithTimestamp
Description copied from class:MaskedTupleMemory
Adds a tuple occurrence to the memory with the given timestamp.- Overrides:
addWithTimestamp
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
- Parameters:
tuple
- the tuple to be added to the memorytimestamp
- the timestamp associated with the tuple- Returns:
- A
Diff
describing how the timeline of the given tuple changed.
-
isTimely
public boolean isTimely()Description copied from class:MaskedTupleMemory
Returns true of this memory is timely, false otherwise.- Overrides:
isTimely
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
-
registerFoldingState
-
unregisterFoldingState
-
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 interfaceResumable<Timestamp extends Comparable<Timestamp>>
- Overrides:
getResumableTimestamp
in classMaskedTupleMemory<Timestamp extends Comparable<Timestamp>>
-