Class GafferCollectors
- java.lang.Object
-
- uk.gov.gchq.gaffer.commonutil.stream.GafferCollectors
-
public final class GafferCollectors extends Object
Java 8Collector
s for Gaffer, based on theCollectors
class. Please note that using aCollector
to gather together the items contained in aStream
will result in those items being loaded into memory.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Collector<T,LimitedInMemorySortedIterable<T>,LimitedInMemorySortedIterable<T>>
toLimitedInMemorySortedIterable(Comparator<T> comparator, Integer limit, boolean deduplicate)
Returns aCollector
that accumulates the input items into aLimitedInMemorySortedIterable
.static <T> Collector<T,?,Set<T>>
toLinkedHashSet()
Returns aCollector
that accumulates the input items into aLinkedHashSet
.
-
-
-
Method Detail
-
toLinkedHashSet
public static <T> Collector<T,?,Set<T>> toLinkedHashSet()
Returns aCollector
that accumulates the input items into aLinkedHashSet
.- Type Parameters:
T
- the type of the input items- Returns:
- a
Collector
which collects all the input elements into aLinkedHashSet
-
toLimitedInMemorySortedIterable
public static <T> Collector<T,LimitedInMemorySortedIterable<T>,LimitedInMemorySortedIterable<T>> toLimitedInMemorySortedIterable(Comparator<T> comparator, Integer limit, boolean deduplicate)
Returns a
Collector
that accumulates the input items into aLimitedInMemorySortedIterable
.The usage of a
LimitedInMemorySortedIterable
ensures that only relevant results are stored in memory, as the output is built up incrementally.- Type Parameters:
T
- the type of input items- Parameters:
comparator
- theComparator
to use when comparing itemslimit
- the maximum number of items to collectdeduplicate
- true if the results should be deduplicated based the items hashcode/equals methods- Returns:
- a
Collector
which collects all the input elements into aLimitedInMemorySortedIterable
-
-