Class MeteredKeyValueStore<K,​V>

    • Field Detail

      • time

        protected final org.apache.kafka.common.utils.Time time
      • putSensor

        protected org.apache.kafka.common.metrics.Sensor putSensor
      • getSensor

        protected org.apache.kafka.common.metrics.Sensor getSensor
    • Method Detail

      • prepareValueSerdeForStore

        protected Serde<V> prepareValueSerdeForStore​(Serde<V> valueSerde,
                                                     Serde<?> contextKeySerde,
                                                     Serde<?> contextValueSerde)
      • get

        public V get​(K key)
        Description copied from interface: ReadOnlyKeyValueStore
        Get the value corresponding to this key.
        Specified by:
        get in interface ReadOnlyKeyValueStore<K,​V>
        Parameters:
        key - The key to fetch
        Returns:
        The value or null if no value is found.
      • put

        public void put​(K key,
                        V value)
        Description copied from interface: KeyValueStore
        Update the value associated with this key.
        Specified by:
        put in interface KeyValueStore<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 deletes
      • putIfAbsent

        public V putIfAbsent​(K key,
                             V value)
        Description copied from interface: KeyValueStore
        Update the value associated with this key, unless a value is already associated with the key.
        Specified by:
        putIfAbsent in interface KeyValueStore<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 deletes
        Returns:
        The old value or null if there is no such key.
      • putAll

        public void putAll​(List<KeyValue<K,​V>> entries)
        Description copied from interface: KeyValueStore
        Update all the given key/value pairs.
        Specified by:
        putAll in interface KeyValueStore<K,​V>
        Parameters:
        entries - A list of entries to put into the store; if the serialized bytes are also null it is interpreted as deletes
      • delete

        public V delete​(K key)
        Description copied from interface: KeyValueStore
        Delete the value from the store (if there is one).
        Specified by:
        delete in interface KeyValueStore<K,​V>
        Parameters:
        key - The key
        Returns:
        The old value or null if there is no such key.
      • range

        public KeyValueIterator<K,​V> range​(K from,
                                                 K to)
        Description copied from interface: ReadOnlyKeyValueStore
        Get an iterator over a given range of keys. This iterator must be closed after use. The returned iterator must be safe from ConcurrentModificationExceptions and must not return null values. No ordering guarantees are provided.
        Specified by:
        range in interface ReadOnlyKeyValueStore<K,​V>
        Parameters:
        from - The first key that could be in the range
        to - The last key that could be in the range
        Returns:
        The iterator for this range.
      • approximateNumEntries

        public long approximateNumEntries()
        Description copied from interface: ReadOnlyKeyValueStore
        Return an approximate count of key-value mappings in this store. The count is not guaranteed to be exact in order to accommodate stores where an exact count is expensive to calculate.
        Specified by:
        approximateNumEntries in interface ReadOnlyKeyValueStore<K,​V>
        Returns:
        an approximate count of key-value mappings in the store.
      • 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<KeyValueStore<org.apache.kafka.common.utils.Bytes,​byte[]>,​K,​V>
      • outerValue

        protected V outerValue​(byte[] value)
      • keyBytes

        protected org.apache.kafka.common.utils.Bytes keyBytes​(K key)