Class MeteredWindowStore<K,​V>

    • Method Detail

      • prepareValueSerde

        protected Serde<V> prepareValueSerde​(Serde<V> valueSerde,
                                             Serde<?> contextKeySerde,
                                             Serde<?> contextValueSerde)
      • put

        @Deprecated
        public void put​(K key,
                        V value)
        Deprecated.
        Description copied from interface: WindowStore
        Use the current record timestamp as the windowStartTimestamp and delegate to WindowStore.put(Object, Object, long).

        It's highly recommended to use WindowStore.put(Object, Object, long) instead, as the record timestamp is unlikely to be the correct windowStartTimestamp in general.

        Specified by:
        put in interface WindowStore<K,​V>
        Parameters:
        key - The key to associate the value to
        value - The value to update, it can be null; if the serialized bytes are also null it is interpreted as delete
      • put

        public void put​(K key,
                        V value,
                        long windowStartTimestamp)
        Description copied from interface: WindowStore
        Put a key-value pair into the window with given window start timestamp

        If serialized value bytes are null it is interpreted as delete. Note that deletes will be ignored in the case of an underlying store that retains duplicates.

        Specified by:
        put in interface WindowStore<K,​V>
        Parameters:
        key - The key to associate the value to
        value - The value; can be null
        windowStartTimestamp - The timestamp of the beginning of the window to put the key/value into
      • fetch

        public V fetch​(K key,
                       long timestamp)
        Description copied from interface: ReadOnlyWindowStore
        Get the value of key from a window.
        Specified by:
        fetch in interface ReadOnlyWindowStore<K,​V>
        Parameters:
        key - the key to fetch
        timestamp - start timestamp (inclusive) of the window
        Returns:
        The value or null if no value is found in the window
      • fetch

        public WindowStoreIterator<V> fetch​(K key,
                                            long timeFrom,
                                            long timeTo)
        Description copied from interface: WindowStore
        Get all the key-value pairs with the given key and the time range from all the existing windows.

        This iterator must be closed after use.

        The time range is inclusive and applies to the starting timestamp of the window. For example, if we have the following windows:

         +-------------------------------+
         |  key  | start time | end time |
         +-------+------------+----------+
         |   A   |     10     |    20    |
         +-------+------------+----------+
         |   A   |     15     |    25    |
         +-------+------------+----------+
         |   A   |     20     |    30    |
         +-------+------------+----------+
         |   A   |     25     |    35    |
         +--------------------------------
         
        And we call store.fetch("A", 10, 20) then the results will contain the first three windows from the table above, i.e., all those where 10 <= start time <= 20.

        For each key, the iterator guarantees ordering of windows, starting from the oldest/earliest available window to the newest/latest window.

        Specified by:
        fetch in interface ReadOnlyWindowStore<K,​V>
        Specified by:
        fetch in interface WindowStore<K,​V>
        Parameters:
        key - the key to fetch
        timeFrom - time range start (inclusive)
        timeTo - time range end (inclusive)
        Returns:
        an iterator over key-value pairs <timestamp, value>
      • fetch

        public KeyValueIterator<Windowed<K>,​V> fetch​(K from,
                                                           K to,
                                                           long timeFrom,
                                                           long timeTo)
        Description copied from interface: WindowStore
        Get all the key-value pairs in the given key range and time range from all the existing windows.

        This iterator must be closed after use.

        Specified by:
        fetch in interface ReadOnlyWindowStore<K,​V>
        Specified by:
        fetch in interface WindowStore<K,​V>
        Parameters:
        from - the first key in the range
        to - the last key in the range
        timeFrom - time range start (inclusive)
        timeTo - time range end (inclusive)
        Returns:
        an iterator over windowed key-value pairs <Windowed<K>, value>
      • fetchAll

        public KeyValueIterator<Windowed<K>,​V> fetchAll​(long timeFrom,
                                                              long timeTo)
        Description copied from interface: WindowStore
        Gets all the key-value pairs that belong to the windows within in the given time range.
        Specified by:
        fetchAll in interface ReadOnlyWindowStore<K,​V>
        Specified by:
        fetchAll in interface WindowStore<K,​V>
        Parameters:
        timeFrom - the beginning of the time slot from which to search (inclusive)
        timeTo - the end of the time slot from which to search (inclusive)
        Returns:
        an iterator over windowed key-value pairs <Windowed<K>, value>
      • close

        public void close()
        Description copied from interface: StateStore
        Close the storage engine. Note that this function needs to be idempotent since it may be called several times on the same state store.

        Users only need to implement this function but should NEVER need to call this api explicitly as it will be called by the library automatically when necessary

        Specified by:
        close in interface StateStore
        Overrides:
        close in class WrappedStateStore<WindowStore<org.apache.kafka.common.utils.Bytes,​byte[]>,​Windowed<K>,​V>