Class ListReductorPipe<S,T>
- java.lang.Object
-
- org.pipecraft.pipes.sync.inter.reduct.SequenceReductorPipe<S,T>
-
- org.pipecraft.pipes.sync.inter.reduct.ListReductorPipe<S,T>
-
- Type Parameters:
S- The data type of items in the input pipeT- 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classListReductorPipe.GroupSizeLimitPolicy
-
Constructor Summary
Constructors Constructor Description 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.ListReductorPipe(Pipe<S> input, FailableFunction<S,?,PipeException> discriminator, Function<List<S>,T> postProcessor, int groupSizeLimit, ListReductorPipe.GroupSizeLimitPolicy sizeLimitPolicy)Constructor
-
-
-
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 pipediscriminator- The function that maps input pipe values to some discriminator value used for reductionpostProcessor- 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 pipediscriminator- The function that maps input pipe values to some discriminator value used for reductionpostProcessor- A function that accepts a list of values to group (i.e. having the same discriminator value), and aggregates them into an output item.
-
-