Class AggBuilder<I, E, O, ACC extends Accumulator<I,E,O>, AGG extends ParallelAggregator<I,E,O,ACC>>
java.lang.Object
org.aksw.commons.collector.core.AggBuilder<I,E,O,ACC,AGG>
- Type Parameters:
I- The current aggregator's input typeO- The current aggregator's output typeACC- The current aggregator's accumulator typeAGG- The current aggregator's own type
public class AggBuilder<I, E, O, ACC extends Accumulator<I,E,O>, AGG extends ParallelAggregator<I,E,O,ACC>>
extends Object
Builder for parallel aggregators.
Static 'from' methods start the builder chain.
All methods that perform modifications return a new independent builder object.
Because type expressions can become complex there are three getters that return the
wrapped aggregator either fully typed, as a parallel aggregator or as a simple aggregator:
,
,
.
invalid reference
#getFullyTyped()
invalid reference
#getAsParallelAggregator()
invalid reference
#getAsAggregator()
- Author:
- raven
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,E> ParallelAggregator <T, E, List<T>, Accumulator<T, E, List<T>>> static <T, E, C extends Collection<T>>
ParallelAggregator<T, E, C, Accumulator<T, E, C>> collectionSupplier(SerializableSupplier<? extends C> colSupplier) static <I,E> ParallelAggregator <I, E, Long, Accumulator<I, E, Long>> counting()static <I, E, O, ACC extends Accumulator<I,E, O>, AGG extends ParallelAggregator<I, E, O, ACC>>
AggErrorHandler<I, E, O, ACC, AGG> errorHandler(AGG state) Wraps another aggregator such that if accumulation fails with an exception an error counter is increased.static <I, E, O, ACC extends Accumulator<I,E, O>, AGG extends ParallelAggregator<I, E, O, ACC>>
AggErrorHandler<I, E, O, ACC, AGG> errorHandler(AGG state, boolean accDespiteError, SerializableConsumer<? super Throwable> errorCallback, SerializableFunction<AggErrorHandler.AccError<I, E, O, ACC>, O> errorValueExtractor) Wraps another aggregator such that if accumulation fails with an exception an error counter is increased.static <I,E> ParallelAggregator <I, E, I, Accumulator<I, E, I>> fold(SerializableSupplier<I> zeroElementSupplier, SerializableBinaryOperator<I> plusOperator) static <T,E, A, R> AggFromCollector <T, E, R, A> fromCollector(SerializableCollector<T, A, R> collector) static <T,E, R, A> AggFromCollector <T, E, R, A> fromCollector(SerializableSupplier<A> supplier, SerializableBiConsumer<A, T> accumulator, SerializableBinaryOperator<A> combiner, SerializableFunction<A, R> finisher) static <T,E, R, A> AggFromCollector <T, E, R, A> fromCollector(SerializableSupplier<A> supplier, SerializableBiConsumer<A, T> accumulator, SerializableBinaryOperator<A> combiner, SerializableFunction<A, R> finisher, Set<Collector.Characteristics> characteristics) static <T,E> ParallelAggregator <T, E, Set<T>, Accumulator<T, E, Set<T>>> static <I,E, O1, O2>
ParallelAggregator<I, E, Map.Entry<O1, O2>, ?> inputBroadcast(ParallelAggregator<I, E, O1, ?> agg1, ParallelAggregator<I, E, O2, ?> agg2) An aggregator that broadcasts its input to two sub-aggregators that accept the same input.static <I,E, K, O> AggInputBroadcastMap <I, E, K, O> inputBroadcastMap(Map<K, ParallelAggregator<I, E, O, ?>> subAggMap) An aggregator that broadcasts its input to multiple sub-aggregators that accept the same inputstatic <I, E, O, ACC extends Accumulator<I,E, O>, AGG extends ParallelAggregator<I, E, O, ACC>>
AggInputFilter<I, E, O, ACC, AGG> inputFilter(SerializablePredicate<? super I> inputFilter, AGG state) Pass on input to sub-acc if the predicate evaluates to truestatic <I, E, J, O, ACC extends Accumulator<J,E, O>, AGG extends ParallelAggregator<J, E, O, ACC>>
AggInputFlatMap<I, E, J, O, ACC, AGG> inputFlatMap(SerializableFunction<I, ? extends Iterator<? extends J>> inputTransform, AGG state) static <I, E, J, O, ACC extends Accumulator<J,E, O>, AGG extends ParallelAggregator<J, E, O, ACC>>
AggInputFlatMap<I, E, J, O, ACC, AGG> inputFlatMap2(SerializableBiFunction<? super I, E, ? extends Iterator<? extends J>> inputTransform, AGG state) static <I, E, K, J, O, ACC extends Accumulator<J,E, O>, AGG extends ParallelAggregator<J, E, O, ACC>>
AggInputSplit<I, E, K, J, O, ACC, AGG> inputSplit(Set<K> fixedKeys, boolean considerNewKeys, SerializableFunction<? super I, ? extends Set<? extends K>> keyMapper, SerializableBiFunction<? super I, ? super K, ? extends J> valueMapper, AGG state) static <I, E, K, J, O, ACC extends Accumulator<J,E, O>, AGG extends ParallelAggregator<J, E, O, ACC>>
AggInputSplit<I, E, K, J, O, ACC, AGG> inputSplit(SerializableFunction<? super I, ? extends Set<? extends K>> keyMapper, SerializableBiFunction<? super I, ? super K, ? extends J> valueMapper, AGG state) InputSplit: Create the same accumulator type for each split of the inputstatic <I, E, K, O, ACC extends Accumulator<I,E, O>, AGG extends ParallelAggregator<I, E, O, ACC>>
AggInputSplit<I, E, K, I, O, ACC, AGG> inputSplit(SerializableFunction<? super I, ? extends K> keyMapper, AGG state) Simple input split: Partition input by a key derived from itstatic <I, E, J, O, ACC extends Accumulator<J,E, O>, AGG extends ParallelAggregator<J, E, O, ACC>>
AggInputTransform<I, E, J, O, ACC, AGG> inputTransform(SerializableFunction<? super I, ? extends J> inputTransform, AGG state) static <I, E, J, O, ACC extends Accumulator<J,E, O>, AGG extends ParallelAggregator<J, E, O, ACC>>
AggInputTransform<I, E, J, O, ACC, AGG> inputTransform2(SerializableBiFunction<? super I, E, ? extends J> inputTransform, AGG state) input transform with support for the environment argument.static <K,V, E> ParallelAggregator <Map.Entry<K, V>, E, SetOverMap<K, V>, Accumulator<Map.Entry<K, V>, E, SetOverMap<K, V>>> mapSupplier(SerializableSupplier<? extends Map<K, V>> mapSupplier) We provide the SetOverMap collection type which transparently gives access to the underlying map This way we can reuse the collection machinery for accumulation and still type-safely extract the map eventuallystatic <E> ParallelAggregator<Integer, E, Integer, Accumulator<Integer, E, Integer>> static <E> ParallelAggregator<Long, E, Long, Accumulator<Long, E, Long>> maxLong()static <T, E, C extends Collection<T>>
ParallelAggregator<T, E, C, Accumulator<T, E, C>> naturalAccumulator(SerializableSupplier<? extends Accumulator<T, E, C>> accSupplier) static <I, E, O, P, ACC extends Accumulator<I,E, O>, AGG extends ParallelAggregator<I, E, O, ACC>>
AggOutputTransform<I, E, O, P, ACC, AGG> outputTransform(AGG state, SerializableFunction<? super O, ? extends P> outputTransform) static <T,E> ParallelAggregator <T, E, Set<T>, Accumulator<T, E, Set<T>>> setSupplier(SerializableSupplier<? extends Set<T>> setSupplier) static <T,E> AggFromCollector <T, E, SerializableDoubleSummaryStatistics, SerializableDoubleSummaryStatistics> summarizingDouble(SerializableToDoubleFunction<T> mapper) static <T,E> AggFromCollector <T, E, SerializableIntSummaryStatistics, SerializableIntSummaryStatistics> summarizingInt(SerializableToIntFunction<T> mapper) static <T,E> AggFromCollector <T, E, SerializableLongSummaryStatistics, SerializableLongSummaryStatistics> summarizingLong(SerializableToLongFunction<T> mapper)
-
Constructor Details
-
AggBuilder
public AggBuilder()
-
-
Method Details
-
inputFilter
public static <I, E, O, ACC extends Accumulator<I,E, AggInputFilter<I,O>, AGG extends ParallelAggregator<I, E, O, ACC>> E, inputFilterO, ACC, AGG> (SerializablePredicate<? super I> inputFilter, AGG state) Pass on input to sub-acc if the predicate evaluates to true -
inputSplit
public static <I, E, K, J, O, ACC extends Accumulator<J,E, AggInputSplit<I,O>, AGG extends ParallelAggregator<J, E, O, ACC>> E, inputSplitK, J, O, ACC, AGG> (SerializableFunction<? super I, ? extends Set<? extends K>> keyMapper, SerializableBiFunction<? super I, ? super K, ? extends J> valueMapper, AGG state) InputSplit: Create the same accumulator type for each split of the input -
inputSplit
public static <I, E, K, J, O, ACC extends Accumulator<J,E, AggInputSplit<I,O>, AGG extends ParallelAggregator<J, E, O, ACC>> E, inputSplitK, J, O, ACC, AGG> (Set<K> fixedKeys, boolean considerNewKeys, SerializableFunction<? super I, ? extends Set<? extends K>> keyMapper, SerializableBiFunction<? super I, ? super K, ? extends J> valueMapper, AGG state) -
inputSplit
public static <I, E, K, O, ACC extends Accumulator<I,E, AggInputSplit<I,O>, AGG extends ParallelAggregator<I, E, O, ACC>> E, inputSplitK, I, O, ACC, AGG> (SerializableFunction<? super I, ? extends K> keyMapper, AGG state) Simple input split: Partition input by a key derived from it -
inputTransform
public static <I, E, J, O, ACC extends Accumulator<J,E, AggInputTransform<I,O>, AGG extends ParallelAggregator<J, E, O, ACC>> E, inputTransformJ, O, ACC, AGG> (SerializableFunction<? super I, ? extends J> inputTransform, AGG state) -
inputTransform2
public static <I, E, J, O, ACC extends Accumulator<J,E, AggInputTransform<I,O>, AGG extends ParallelAggregator<J, E, O, ACC>> E, inputTransform2J, O, ACC, AGG> (SerializableBiFunction<? super I, E, ? extends J> inputTransform, AGG state) input transform with support for the environment argument. -
errorHandler
public static <I, E, O, ACC extends Accumulator<I,E, AggErrorHandler<I,O>, AGG extends ParallelAggregator<I, E, O, ACC>> E, errorHandlerO, ACC, AGG> (AGG state) Wraps another aggregator such that if accumulation fails with an exception an error counter is increased. If the error counter is non zero then the accumulated value will always be null -
errorHandler
public static <I, E, O, ACC extends Accumulator<I,E, AggErrorHandler<I,O>, AGG extends ParallelAggregator<I, E, O, ACC>> E, errorHandlerO, ACC, AGG> (AGG state, boolean accDespiteError, SerializableConsumer<? super Throwable> errorCallback, SerializableFunction<AggErrorHandler.AccError<I, E, O, ACC>, O> errorValueExtractor) Wraps another aggregator such that if accumulation fails with an exception an error counter is increased. If the error counter is non zero then a custom policy for extracting a final value from the accumulator state can be specified -
inputFlatMap
public static <I, E, J, O, ACC extends Accumulator<J,E, AggInputFlatMap<I,O>, AGG extends ParallelAggregator<J, E, O, ACC>> E, inputFlatMapJ, O, ACC, AGG> (SerializableFunction<I, ? extends Iterator<? extends J>> inputTransform, AGG state) -
inputFlatMap2
public static <I, E, J, O, ACC extends Accumulator<J,E, AggInputFlatMap<I,O>, AGG extends ParallelAggregator<J, E, O, ACC>> E, inputFlatMap2J, O, ACC, AGG> (SerializableBiFunction<? super I, E, ? extends Iterator<? extends J>> inputTransform, AGG state) -
outputTransform
public static <I, E, O, P, ACC extends Accumulator<I,E, AggOutputTransform<I,O>, AGG extends ParallelAggregator<I, E, O, ACC>> E, outputTransformO, P, ACC, AGG> (AGG state, SerializableFunction<? super O, ? extends P> outputTransform) -
hashSetSupplier
-
arrayListSupplier
-
setSupplier
public static <T,E> ParallelAggregator<T, E, Set<T>, Accumulator<T,E, setSupplierSet<T>>> (SerializableSupplier<? extends Set<T>> setSupplier) -
mapSupplier
public static <K,V, ParallelAggregator<Map.Entry<K,E> V>, E, SetOverMap<K, mapSupplierV>, Accumulator<Map.Entry<K, V>, E, SetOverMap<K, V>>> (SerializableSupplier<? extends Map<K, V>> mapSupplier) We provide the SetOverMap collection type which transparently gives access to the underlying map This way we can reuse the collection machinery for accumulation and still type-safely extract the map eventually -
collectionSupplier
public static <T, E, C extends Collection<T>> ParallelAggregator<T, E, C, Accumulator<T,E, collectionSupplierC>> (SerializableSupplier<? extends C> colSupplier) -
naturalAccumulator
public static <T, E, C extends Collection<T>> ParallelAggregator<T, E, C, Accumulator<T,E, naturalAccumulatorC>> (SerializableSupplier<? extends Accumulator<T, E, C>> accSupplier) -
counting
-
inputBroadcast
public static <I,E, ParallelAggregator<I, E, Map.Entry<O1,O1, O2> O2>, ?> inputBroadcast(ParallelAggregator<I, E, O1, ?> agg1, ParallelAggregator<I, E, O2, ?> agg2) An aggregator that broadcasts its input to two sub-aggregators that accept the same input. -
inputBroadcastMap
public static <I,E, AggInputBroadcastMap<I,K, O> E, inputBroadcastMapK, O> (Map<K, ParallelAggregator<I, E, O, ?>> subAggMap) An aggregator that broadcasts its input to multiple sub-aggregators that accept the same input -
fold
public static <I,E> ParallelAggregator<I, E, I, Accumulator<I,E, foldI>> (SerializableSupplier<I> zeroElementSupplier, SerializableBinaryOperator<I> plusOperator) -
fromCollector
public static <T,E, AggFromCollector<T,R, A> E, fromCollectorR, A> (SerializableSupplier<A> supplier, SerializableBiConsumer<A, T> accumulator, SerializableBinaryOperator<A> combiner, SerializableFunction<A, R> finisher) -
fromCollector
public static <T,E, AggFromCollector<T,R, A> E, fromCollectorR, A> (SerializableSupplier<A> supplier, SerializableBiConsumer<A, T> accumulator, SerializableBinaryOperator<A> combiner, SerializableFunction<A, R> finisher, Set<Collector.Characteristics> characteristics) -
fromCollector
public static <T,E, AggFromCollector<T,A, R> E, fromCollectorR, A> (SerializableCollector<T, A, R> collector) -
maxLong
-
maxInteger
public static <E> ParallelAggregator<Integer, E, Integer, Accumulator<Integer,E, maxInteger()Integer>> -
summarizingInt
public static <T,E> AggFromCollector<T, E, SerializableIntSummaryStatistics, SerializableIntSummaryStatistics> summarizingInt(SerializableToIntFunction<T> mapper) -
summarizingLong
public static <T,E> AggFromCollector<T, E, SerializableLongSummaryStatistics, SerializableLongSummaryStatistics> summarizingLong(SerializableToLongFunction<T> mapper) -
summarizingDouble
public static <T,E> AggFromCollector<T, E, SerializableDoubleSummaryStatistics, SerializableDoubleSummaryStatistics> summarizingDouble(SerializableToDoubleFunction<T> mapper)
-