Class MultiKeyLatestItemSequentialProcessor<KeyType,​ItemType>

  • Type Parameters:
    KeyType - The type of the key to be processed.
    ItemType - The type of item to be processed.

    public class MultiKeyLatestItemSequentialProcessor<KeyType,​ItemType>
    extends java.lang.Object
    Provides a way to run a function on Key Value Pairs but guarantees that the function is only invoked for one item at a time per key. If multiple 'updates' to a particular key are provided while the processor is running, only the most recent is passed to the function. This allows it to 'skip' updates for keys that are not the most recent value.
    • Constructor Detail

      • MultiKeyLatestItemSequentialProcessor

        public MultiKeyLatestItemSequentialProcessor​(java.util.function.BiConsumer<KeyType,​ItemType> processFunction,
                                                     java.util.concurrent.Executor executor)
    • Method Detail

      • updateItem

        public void updateItem​(KeyType key,
                               ItemType newItem)
        Updates the item and triggers it to be processed.
        Parameters:
        key - The key of the item to be processed (Cannot be null)
        newItem - The item to be processed. (Cannot be null)