Class GafferCollectors
- java.lang.Object
-
- uk.gov.gchq.gaffer.commonutil.stream.GafferCollectors
-
public final class GafferCollectors extends Object
Java 8Collectors for Gaffer, based on theCollectorsclass. Please note that using aCollectorto gather together the items contained in aStreamwill 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 aCollectorthat accumulates the input items into aLimitedInMemorySortedIterable.static <T> Collector<T,?,Set<T>>toLinkedHashSet()Returns aCollectorthat accumulates the input items into aLinkedHashSet.
-
-
-
Method Detail
-
toLinkedHashSet
public static <T> Collector<T,?,Set<T>> toLinkedHashSet()
Returns aCollectorthat accumulates the input items into aLinkedHashSet.- Type Parameters:
T- the type of the input items- Returns:
- a
Collectorwhich 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
Collectorthat accumulates the input items into aLimitedInMemorySortedIterable.The usage of a
LimitedInMemorySortedIterableensures 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- theComparatorto 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
Collectorwhich collects all the input elements into aLimitedInMemorySortedIterable
-
-