org.eclipse.viatra.query.runtime.matchers.memories

## Class DefaultMaskedTupleMemory<Timestamp extends java.lang.Comparable<Timestamp>>

- java.lang.Object
- - org.eclipse.viatra.query.runtime.matchers.memories.MaskedTupleMemory<Timestamp>
  - - org.eclipse.viatra.query.runtime.matchers.memories.DefaultMaskedTupleMemory<Timestamp>

- All Implemented Interfaces:
    Clearable, MaskedResumable<Timestamp>, Resumable<Timestamp>

      public final class DefaultMaskedTupleMemory<Timestamp extends java.lang.Comparable<Timestamp>>
      extends MaskedTupleMemory<Timestamp>

  Since:
    2.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected IMultiLookup<Tuple,Tuple>` | `signatureToTuples` Maps a signature tuple to the bucket of tuples with the given signature.

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.matchers.memories.MaskedTupleMemory

      `mask, owner`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultMaskedTupleMemory(TupleMask mask, CollectionsFactory.MemoryType bucketType, java.lang.Object owner)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(Tuple tuple)` Adds a tuple occurrence to the memory.
    `boolean` | `add(Tuple tuple, Tuple signature)` Adds a tuple occurrence to the memory with the given signature.
    `void` | `clear()` Clear all partial matchings stored in memory
    `java.util.Collection<Tuple>` | `get(ITuple signature)` Retrieves tuples that have the specified signature
    `int` | `getKeysetSize()`
    `java.lang.Iterable<Tuple>` | `getSignatures()` Retrieves a read-only view of exactly those signatures for which at least one tuple is stored
    `int` | `getTotalSize()`
    `java.util.Map<Tuple,Timeline<Timestamp>>` | `getWithTimeline(ITuple signature)` Retrieves the tuples and their associated timelines that have the specified signature.
    `java.util.Iterator<Tuple>` | `iterator()` Iterates over distinct tuples stored in the memory, regardless of their signatures.
    `boolean` | `remove(Tuple tuple)` Removes a tuple occurrence from the memory.
    `boolean` | `remove(Tuple tuple, Tuple signature)` Removes a tuple occurrence from the memory with the given signature.

    - ### Methods inherited from class org.eclipse.viatra.query.runtime.matchers.memories.MaskedTupleMemory

      `addWithTimestamp, addWithTimestamp, create, create, create, getMask, getOrEmpty, getOrEmptyWithTimeline, getOwner, getResumableSignatures, getResumableTimestamp, initializeWith, isPresentAtInfinity, isTimely, raiseDuplicateDeletion, raiseDuplicateInsertion, removeWithTimestamp, removeWithTimestamp, resumeAt, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### signatureToTuples

          protected IMultiLookup<Tuple,Tuple> signatureToTuples

      Maps a signature tuple to the bucket of tuples with the given signature.
      Since:
        2.0

  - ### Constructor Detail

    - #### DefaultMaskedTupleMemory

          public DefaultMaskedTupleMemory(TupleMask mask,
                                          CollectionsFactory.MemoryType bucketType,
                                          java.lang.Object owner)

      Parameters:
        `mask` - The mask used to index the matchings
        `owner` - the object "owning" this memory
        `bucketType` - the kind of tuple collection maintained for each indexer bucket
      Since:
        2.0

  - ### Method Detail

    - #### add

          public boolean add(Tuple tuple)

      Description copied from class: `MaskedTupleMemory`
      Adds a tuple occurrence to the memory.
      Overrides:
        `add` in class `MaskedTupleMemory<Timestamp extends java.lang.Comparable<Timestamp>>`
      Parameters:
        `tuple` - the tuple to be added to the memory
      Returns:
        true if new signature encountered (according to the mask)

    - #### add

          public boolean add(Tuple tuple,
                             Tuple signature)

      Description copied from class: `MaskedTupleMemory`
      Adds a tuple occurrence to the memory with the given signature.
      Overrides:
        `add` in class `MaskedTupleMemory<Timestamp extends java.lang.Comparable<Timestamp>>`
      Parameters:
        `tuple` - the tuple to be added to the memory
        `signature` - precomputed footprint of the tuple according to the mask
      Returns:
        true if new signature encountered (according to the mask)

    - #### remove

          public boolean remove(Tuple tuple)

      Description copied from class: `MaskedTupleMemory`
      Removes a tuple occurrence from the memory.
      Overrides:
        `remove` in class `MaskedTupleMemory<Timestamp extends java.lang.Comparable<Timestamp>>`
      Parameters:
        `tuple` - the tuple to be removed from the memory
      Returns:
        true if this was the the last occurrence of the signature (according to the mask)

    - #### remove

          public boolean remove(Tuple tuple,
                                Tuple signature)

      Description copied from class: `MaskedTupleMemory`
      Removes a tuple occurrence from the memory with the given signature.
      Overrides:
        `remove` in class `MaskedTupleMemory<Timestamp extends java.lang.Comparable<Timestamp>>`
      Parameters:
        `tuple` - the tuple to be removed from the memory
        `signature` - precomputed footprint of the tuple according to the mask
      Returns:
        true if this was the the last occurrence of the signature (according to the mask)

    - #### getWithTimeline

          public java.util.Map<Tuple,Timeline<Timestamp>> getWithTimeline(ITuple signature)

      Description copied from class: `MaskedTupleMemory`
      Retrieves the tuples and their associated timelines that have the specified signature.
      Specified by:
        `getWithTimeline` in class `MaskedTupleMemory<Timestamp extends java.lang.Comparable<Timestamp>>`
      Returns:
        the mappings from tuples to timelines, null if there is no mapping for the signature

    - #### get

          public java.util.Collection<Tuple> get(ITuple signature)

      Description copied from class: `MaskedTupleMemory`
      Retrieves tuples that have the specified signature
      Specified by:
        `get` in class `MaskedTupleMemory<Timestamp extends java.lang.Comparable<Timestamp>>`
      Returns:
        collection of tuples found, null if none

    - #### clear

          public void clear()

      Description copied from interface: `Clearable`
      Clear all partial matchings stored in memory

    - #### getSignatures

          public java.lang.Iterable<Tuple> 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 class `MaskedTupleMemory<Timestamp extends java.lang.Comparable<Timestamp>>`

    - #### iterator

          public java.util.Iterator<Tuple> iterator()

      Description copied from class: `MaskedTupleMemory`
      Iterates over distinct tuples stored in the memory, regardless of their signatures.
      Specified by:
        `iterator` in class `MaskedTupleMemory<Timestamp extends java.lang.Comparable<Timestamp>>`

    - #### getTotalSize

          public int getTotalSize()

      Specified by:
        `getTotalSize` in class `MaskedTupleMemory<Timestamp extends java.lang.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.

    - #### getKeysetSize

          public int getKeysetSize()

      Specified by:
        `getKeysetSize` in class `MaskedTupleMemory<Timestamp extends java.lang.Comparable<Timestamp>>`
      Returns:
        the number of distinct signatures of all stored tuples.