Interface SessionStore<K,​AGG>

  • Type Parameters:
    K - type of the record keys
    AGG - type of the aggregated values
    All Superinterfaces:
    ReadOnlySessionStore<K,​AGG>, StateStore
    All Known Implementing Classes:
    InMemorySessionStore, MeteredSessionStore, RocksDBSessionStore

    public interface SessionStore<K,​AGG>
    extends StateStore, ReadOnlySessionStore<K,​AGG>
    Interface for storing the aggregated values of sessions.

    The key is internally represented as Windowed<K> that comprises the plain key and the Window that represents window start- and end-timestamp.

    If two sessions are merged, a new session with new start- and end-timestamp must be inserted into the store while the two old sessions must be deleted.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      AGG fetchSession​(K key, long startTime, long endTime)
      Get the value of key from a single session.
      KeyValueIterator<Windowed<K>,​AGG> findSessions​(K key, long earliestSessionEndTime, long latestSessionStartTime)
      Fetch any sessions with the matching key and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime This iterator must be closed after use.
      KeyValueIterator<Windowed<K>,​AGG> findSessions​(K keyFrom, K keyTo, long earliestSessionEndTime, long latestSessionStartTime)
      Fetch any sessions in the given range of keys and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime This iterator must be closed after use.
      void put​(Windowed<K> sessionKey, AGG aggregate)
      Write the aggregated value for the provided key to the store
      void remove​(Windowed<K> sessionKey)
      Remove the session aggregated with provided Windowed key from the store
    • Method Detail

      • findSessions

        KeyValueIterator<Windowed<K>,​AGG> findSessions​(K key,
                                                             long earliestSessionEndTime,
                                                             long latestSessionStartTime)
        Fetch any sessions with the matching key and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime This iterator must be closed after use.
        Parameters:
        key - the key to return sessions for
        earliestSessionEndTime - the end timestamp of the earliest session to search for
        latestSessionStartTime - the end timestamp of the latest session to search for
        Returns:
        iterator of sessions with the matching key and aggregated values
        Throws:
        NullPointerException - If null is used for key.
      • findSessions

        KeyValueIterator<Windowed<K>,​AGG> findSessions​(K keyFrom,
                                                             K keyTo,
                                                             long earliestSessionEndTime,
                                                             long latestSessionStartTime)
        Fetch any sessions in the given range of keys and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime This iterator must be closed after use.
        Parameters:
        keyFrom - The first key that could be in the range
        keyTo - The last key that could be in the range
        earliestSessionEndTime - the end timestamp of the earliest session to search for
        latestSessionStartTime - the end timestamp of the latest session to search for
        Returns:
        iterator of sessions with the matching keys and aggregated values
        Throws:
        NullPointerException - If null is used for any key.
      • fetchSession

        AGG fetchSession​(K key,
                         long startTime,
                         long endTime)
        Get the value of key from a single session.
        Parameters:
        key - the key to fetch
        startTime - start timestamp of the session
        endTime - end timestamp of the session
        Returns:
        The value or null if no session associated with the key can be found
        Throws:
        NullPointerException - If null is used for any key.
      • remove

        void remove​(Windowed<K> sessionKey)
        Remove the session aggregated with provided Windowed key from the store
        Parameters:
        sessionKey - key of the session to remove
        Throws:
        NullPointerException - If null is used for sessionKey.
      • put

        void put​(Windowed<K> sessionKey,
                 AGG aggregate)
        Write the aggregated value for the provided key to the store
        Parameters:
        sessionKey - key of the session to write
        aggregate - the aggregated value for the session, it can be null; if the serialized bytes are also null it is interpreted as deletes
        Throws:
        NullPointerException - If null is used for sessionKey.