Interface MappedBatchPublisher<K,​V>

  • Type Parameters:
    K - type parameter indicating the type of keys to use for data load requests.
    V - type parameter indicating the type of values returned

    @PublicSpi
    @NullMarked
    public interface MappedBatchPublisher<K,​V>
    A function that is invoked for batch loading a stream of data values indicated by the provided list of keys.

    The function must call the provided Subscriber to process the key/value pairs it has retrieved to allow the future returned by DataLoader.load(Object) to complete as soon as the individual value is available (rather than when all values have been retrieved).

    See Also:
    for the non-reactive version
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void load​(java.util.Set<K> keys, org.reactivestreams.Subscriber<java.util.Map.Entry<K,​V>> subscriber)
      Called to batch the provided keys into a stream of map entries of keys and values.
    • Method Detail

      • load

        void load​(java.util.Set<K> keys,
                  org.reactivestreams.Subscriber<java.util.Map.Entry<K,​V>> subscriber)
        Called to batch the provided keys into a stream of map entries of keys and values.

        The idiomatic approach would be to create a reactive Publisher that provides the values given the keys and then subscribe to it with the provided Subscriber.

        Parameters:
        keys - the collection of keys to load
        subscriber - as values arrive you must call the subscriber for each value