Class ListReductorPipe<S,​T>

  • Type Parameters:
    S - The data type of items in the input pipe
    T - The data type of the output items
    All Implemented Interfaces:
    Closeable, AutoCloseable, BasePipe, Pipe<T>

    public class ListReductorPipe<S,​T>
    extends SequenceReductorPipe<S,​T>
    Scans the input pipe and groups sequential items based on some discriminating property. The group is then being reduced into a single item using the caller's provided logic. Since each sequence is internally stored in a list, this class provides protection defined by groupSizeLimit and sizeLimitPolicy.
    Author:
    Eyal Schneider
    • Constructor Detail

      • ListReductorPipe

        public ListReductorPipe​(Pipe<S> input,
                                FailableFunction<S,​?,​PipeException> discriminator,
                                Function<List<S>,​T> postProcessor,
                                int groupSizeLimit,
                                ListReductorPipe.GroupSizeLimitPolicy sizeLimitPolicy)
        Constructor
        Parameters:
        input - The input pipe
        discriminator - The function that maps input pipe values to some discriminator value used for reduction
        postProcessor - A function that accepts a list of values to group (i.e. having the same discriminator value), and aggregates them into an output item.
        groupSizeLimit - The maximum size for a group. Used for avoiding excessive heap usage when collecting items for the reductor. Use 0 for no limit.
        sizeLimitPolicy - Use TRUNCATE for ignoring group items beyond the threshold, and FAIL for throwing an exception when this happens.
      • ListReductorPipe

        public ListReductorPipe​(Pipe<S> input,
                                FailableFunction<S,​?,​PipeException> discriminator,
                                Function<List<S>,​T> postProcessor)
        Constructor Creates a sequence reductor pipe with no protective threshold on group sizes.
        Parameters:
        input - The input pipe
        discriminator - The function that maps input pipe values to some discriminator value used for reduction
        postProcessor - A function that accepts a list of values to group (i.e. having the same discriminator value), and aggregates them into an output item.