public abstract class MaskedTupleMemory extends java.lang.Object implements Clearable, java.lang.Iterable<Tuple>
TODO experiment with memory-saving alternatives,
e.g. if the mask has width 1,
#signatureToTuples
can be keyed by the unary values instead of tuples.
Modifier and Type | Field and Description |
---|---|
protected TupleMask |
mask
The mask by which the tuples are indexed.
|
protected java.lang.Object |
owner
The object "owning" this memory.
|
Modifier | Constructor and Description |
---|---|
protected |
MaskedTupleMemory(TupleMask mask,
java.lang.Object owner) |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
add(Tuple tuple)
Adds a tuple occurrence to the memory
|
abstract boolean |
add(Tuple tuple,
Tuple signature)
Adds a tuple occurrence to the memory, with given signature
|
static MaskedTupleMemory |
create(TupleMask mask,
CollectionsFactory.MemoryType bucketType,
java.lang.Object owner)
Creates a new memory for the given owner that indexes tuples according to the given mask.
|
abstract java.util.Collection<Tuple> |
get(ITuple signature)
Retrieves tuples that have the specified signature
|
abstract int |
getKeysetSize() |
TupleMask |
getMask()
The mask according to which tuples are projected and indexed.
|
java.util.Collection<Tuple> |
getOrEmpty(ITuple signature)
Retrieves tuples that have the specified signature
|
java.lang.Object |
getOwner()
The node owning this memory.
|
abstract java.lang.Iterable<Tuple> |
getSignatures()
Retrieves a read-only view of exactly those signatures for which at least one tuple is stored
|
abstract int |
getTotalSize() |
abstract java.util.Iterator<Tuple> |
iterator()
Iterates over distinct tuples stored in the memory, regardless of their signatures.
|
protected java.lang.IllegalStateException |
raiseDuplicateDeletion(Tuple tuple) |
protected java.lang.IllegalStateException |
raiseDuplicateInsertion(Tuple tuple) |
abstract boolean |
remove(Tuple tuple)
Removes a tuple occurrence from the memory
|
abstract boolean |
remove(Tuple tuple,
Tuple signature)
Removes a tuple occurrence from the memory, with given signature
|
java.lang.String |
toString() |
protected TupleMask mask
protected java.lang.Object owner
protected MaskedTupleMemory(TupleMask mask, java.lang.Object owner)
public static MaskedTupleMemory create(TupleMask mask, CollectionsFactory.MemoryType bucketType, java.lang.Object owner)
public java.lang.Object getOwner()
public TupleMask getMask()
public abstract int getKeysetSize()
public abstract int getTotalSize()
This is currently not cached but computed on demand. It is therefore not efficient, and shall only be used for debug / profiling purposes.
public abstract java.util.Iterator<Tuple> iterator()
iterator
in interface java.lang.Iterable<Tuple>
public abstract java.lang.Iterable<Tuple> getSignatures()
public abstract java.util.Collection<Tuple> get(ITuple signature)
public java.util.Collection<Tuple> getOrEmpty(ITuple signature)
public abstract boolean remove(Tuple tuple, Tuple signature)
tuple
- old tuple removed from the memorysignature
- precomputed footprint of the tuple according to the maskpublic abstract boolean remove(Tuple tuple)
tuple
- old tuple removed from the memorypublic abstract boolean add(Tuple tuple, Tuple signature)
tuple
- new tuple added to the memorysignature
- precomputed footprint of the tuple according to the maskpublic abstract boolean add(Tuple tuple)
tuple
- new tuple added to the memoryprotected java.lang.IllegalStateException raiseDuplicateInsertion(Tuple tuple)
protected java.lang.IllegalStateException raiseDuplicateDeletion(Tuple tuple)
public java.lang.String toString()
toString
in class java.lang.Object