Package org.aksw.commons.util.stream
Class CollapseRunsSpecBase<T,K,V>
java.lang.Object
org.aksw.commons.util.stream.CollapseRunsSpecBase<T,K,V>
- Type Parameters:
T- The upstream (input) item typeK- The key type by which to group itemsV- The type of the result of grouping items
- Direct Known Subclasses:
CollapseRunsOperationBase,CollapseRunsSpec
Base class with core attributes for partial reduction of consecutive items
sharing some attribute (referred to as group key).
This class is shared between specification and operation implementations.
The most similar implementation I am aware of is
https://github.com/amaembo/streamex/blob/master/src/main/java/one/util/streamex/CollapseSpliterator.java
There are minor differences in the models though:
- Sequential group by only creates a single accumulator per group and feeds all consecutive items to it.
- StreamEx seems to create multiple accumulators together with a combine function
When accumulating consecutive triples into a graph it does not make much sense having to combine
individual graphs as this is quite an expensive operation due to the unnecessary indexing overhead involved.
(i.e. indexing of triples only to combine them afterwards anyway)
- Author:
- raven
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BiFunction<? super V,? super T, ? extends V> Reduce an item with the accumulator to obtain a new accumulatorprotected BiFunction<? super Long,? super K, ? extends V> Constructor function for accumulators.Function to derive a group key from an item in the flowprotected BiPredicate<? super K,? super K> Comparison whether two group keys are equal -
Constructor Summary
ConstructorsConstructorDescriptionCollapseRunsSpecBase(Function<? super T, ? extends K> getGroupKey, BiPredicate<? super K, ? super K> groupKeyCompare, BiFunction<? super Long, ? super K, ? extends V> accCtor, BiFunction<? super V, ? super T, ? extends V> accAdd) CollapseRunsSpecBase(CollapseRunsSpecBase<T, K, V> other) -
Method Summary
-
Field Details
-
getGroupKey
Function to derive a group key from an item in the flow -
groupKeyCompare
Comparison whether two group keys are equal -
accCtor
Constructor function for accumulators. Receives item index and group key -
accAdd
Reduce an item with the accumulator to obtain a new accumulator
-
-
Constructor Details
-
CollapseRunsSpecBase
-
CollapseRunsSpecBase
public CollapseRunsSpecBase(Function<? super T, ? extends K> getGroupKey, BiPredicate<? super K, ? super K> groupKeyCompare, BiFunction<? super Long, ? super K, ? extends V> accCtor, BiFunction<? super V, ? super T, ? extends V> accAdd)
-