Class CollapseRunsSpecBase<T,K,V>

java.lang.Object
org.aksw.commons.util.stream.CollapseRunsSpecBase<T,K,V>
Type Parameters:
T - The upstream (input) item type
K - The key type by which to group items
V - The type of the result of grouping items
Direct Known Subclasses:
CollapseRunsOperationBase, CollapseRunsSpec

public class CollapseRunsSpecBase<T,K,V> extends Object
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 Details

    • getGroupKey

      protected Function<? super T, ? extends K> getGroupKey
      Function to derive a group key from an item in the flow
    • groupKeyCompare

      protected BiPredicate<? super K, ? super K> groupKeyCompare
      Comparison whether two group keys are equal
    • accCtor

      protected BiFunction<? super Long, ? super K, ? extends V> accCtor
      Constructor function for accumulators. Receives item index and group key
    • accAdd

      protected BiFunction<? super V, ? super T, ? extends V> accAdd
      Reduce an item with the accumulator to obtain a new accumulator
  • Constructor Details