Package uk.ac.starlink.table.join
Class CollectionRunner<E>
java.lang.Object
uk.ac.starlink.table.join.CollectionRunner<E>
Harnesses a SplitProcessor to perform parallel processing on
elements of a Java Collection.
This more or less duplicates part of the behaviour of the Java 8
streams framework, but it provides the additional control available
from SplitProcessor
, and also works with a
ProgressIndicator
to provide interruption control
and progress logging.
- Since:
- 21 Sep 2022
- Author:
- Mark Taylor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Interface to define a collection operation for use with this class. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CollectionRunner
<?> Untyped instance using default policy.static final CollectionRunner
<?> Untyped instance for sequential operation. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, using default policy.CollectionRunner
(uk.ac.starlink.util.SplitProcessor<?> processor) Constructs an instance with a given SplitProcessor. -
Method Summary
Modifier and TypeMethodDescription<A> A
collect
(CollectionRunner.ElementCollector<E, A> collector, Collection<E> collection) Performs a collect operation without logging.<A> A
collect
(CollectionRunner.ElementCollector<E, A> collector, Collection<E> collection, ProgressIndicator progger) Performs a collect operation with optional progress logging.static <E,
A> A collectStream
(CollectionRunner.ElementCollector<E, A> collector, Stream<E> stream) Performs a collection operation using the Java 8 streams framework.uk.ac.starlink.util.SplitProcessor
<?> Returns this runner's SplitProcessor.
-
Field Details
-
SEQUENTIAL
Untyped instance for sequential operation. -
DFLT
Untyped instance using default policy.
-
-
Constructor Details
-
CollectionRunner
public CollectionRunner()Default constructor, using default policy. -
CollectionRunner
public CollectionRunner(uk.ac.starlink.util.SplitProcessor<?> processor) Constructs an instance with a given SplitProcessor.- Parameters:
processor
- controls behaviour
-
-
Method Details
-
getSplitProcessor
public uk.ac.starlink.util.SplitProcessor<?> getSplitProcessor()Returns this runner's SplitProcessor.- Returns:
- split processor
-
collect
Performs a collect operation without logging.- Parameters:
collector
- defines behaviourcollection
- data on which to operate- Returns:
- result of collection
-
collect
public <A> A collect(CollectionRunner.ElementCollector<E, A> collector, Collection<E> collection, ProgressIndicator progger) Performs a collect operation with optional progress logging.- Parameters:
collector
- defines behaviourcollection
- data on which to operateprogger
- progress logger- Returns:
- result of collection
-
collectStream
public static <E,A> A collectStream(CollectionRunner.ElementCollector<E, A> collector, Stream<E> stream) Performs a collection operation using the Java 8 streams framework. This does not use any of the implementation code associated with SplitProcessor, it just creates aCollector
based on the suppliedElementCollector
and feeds the stream to it.This method is only intended for testing and comparison purposes; if you actually want to use Java 8 streams, you might as well use the Collector interface directly.
- Parameters:
collector
- collectorstream
- input stream- Returns:
- result of collection operation
-