Interface GroupingReteMemory<V>

Type Parameters:
V - the value type
All Superinterfaces:
DeltaInsertMemory, ReteMemory<Long>
All Known Implementing Classes:
GroupingReteMemoryWrapper

public interface GroupingReteMemory<V> extends ReteMemory<Long>

A map-like storage that holds objects grouped by keys, similar to Map<Long, Set<V>>. Internally, the memory is split into two parts: a main memory and a delta memory for buffering insertions. Upon calling the DeltaInsertMemory.commit() method, the implementation empties the delta memory by moving all the data into the main memory.

  • Method Details

    • insert

      void insert(long key, V value)
      Buffers a new key/value combination into the delta memory.
      Parameters:
      key - the key to be inserted
      value - the value associated with the key
      Throws:
      NullPointerException - if the key or value is null
    • delete

      void delete(long key, V value)
      Deletes the given key and value from both delta and main memories. If the value is the last one stored under this key, the key must be deleted as well.
      Parameters:
      key - the key to be deleted
      value - the value associated with the key
      Throws:
      NullPointerException - if the key or value is null
    • valueIterator

      Iterator<V> valueIterator(MemoryScope scope, long key)
      Returns an iterator over values.
      Parameters:
      scope - the scope of the values (not the keys)
      key - the key identifying the values to iterate over
      Returns:
      an iterator over the values associated with the given key in the specified scope
    • stream

      default Stream<V> stream(MemoryScope scope, long key)
      Provides a default implementation for streaming over stored elements based on the provided key and scope. Implementations are encouraged to override this method to create parallel streams, if possible.
      Parameters:
      scope - The memory scope indicating whether to stream over main or delta storage.
      key - The key identifying the collection of values to stream.
      Returns:
      A stream over elements in the storage of the provided scope.
    • keyIterator

      default Iterator<Long> keyIterator(MemoryScope scope)