Class FeatureExporter<S>
Object
FeatureExporter<S>
- Type Parameters:
S
- a source-of-rows that is duplicated for each new thread (to prevent any concurrency issues)
Shared-state for an
ExportFeatures
task.- Author:
- Owen Feehan
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFeatureExporter
(FeatureOutputMetadata outputMetadata, Supplier<S> featureSource, Optional<InputGrouper> grouper, FeatureExporterContext context) Creates the shared state. -
Method Summary
Modifier and TypeMethodDescriptionvoid
closeAndWriteOutputs
(Optional<NamedFeatureStore<FeatureInputResults>> featuresAggregate, boolean includeGroups, Function<InputOutputContext, FeatureCSVWriterFactory> csvWriterCreator, InputOutputContext context) Writes all the results that have been collected as a CSV file, and closes open I/O handles and memory structures.static <T extends FeatureInput>
FeatureExporter<FeatureList<T>> create
(List<NamedBean<FeatureListProvider<T>>> features, LabelHeaders metadataHeaders, FeatureOutputNames outputNames, Optional<InputGrouper> grouper, FeatureExporterContext context) Alternative static constructor that creates a shared-state from a list of namedFeatureListProvider
s.static <T extends FeatureInput>
FeatureExporter<FeatureTableCalculator<T>> create
(FeatureOutputNames outputNames, FeatureTableCalculator<T> features, LabelHeaders identifierHeaders, Optional<InputGrouper> grouper, FeatureExporterContext context) Alternative static constructor that creates a shared-state from aNamedFeatureStore
.static <T extends FeatureInput>
FeatureExporter<FeatureList<T>> create
(NamedFeatureStore<T> featureStore, LabelHeaders metadataHeaders, FeatureOutputNames outputNames, Optional<InputGrouper> grouper, FeatureExporterContext context) Alternative static constructor that creates a shared-state from aNamedFeatureStore
.createCalculationContext
(Optional<String> groupName, ExecutionTimeRecorder executionTimeRecorder, InputOutputContext ioContext) Creates aFeatureCalculationContext
for calculating features to later use this exporter.The names of the features to be exported.When defined, assigns each input to a group.Saved store feature calculation results, and writes associated thumbnails.
-
Field Details
-
OUTPUT_THUMBNAILS
The output-name for writing thumbnails.- See Also:
-
-
Constructor Details
-
FeatureExporter
public FeatureExporter(FeatureOutputMetadata outputMetadata, Supplier<S> featureSource, Optional<InputGrouper> grouper, FeatureExporterContext context) throws OutputWriteFailedException Creates the shared state.- Parameters:
outputMetadata
- headers and output-name for the feature CSV file that is written.featureSource
- source of rows in the feature-table (called independently for each thread).grouper
- when defined, assigns each input to a group.context
- context for exporting features.- Throws:
OutputWriteFailedException
- if there's an error during output writing
-
-
Method Details
-
create
public static <T extends FeatureInput> FeatureExporter<FeatureList<T>> create(List<NamedBean<FeatureListProvider<T>>> features, LabelHeaders metadataHeaders, FeatureOutputNames outputNames, Optional<InputGrouper> grouper, FeatureExporterContext context) throws CreateException Alternative static constructor that creates a shared-state from a list of namedFeatureListProvider
s.- Type Parameters:
T
- feature input-type in store- Parameters:
features
- a list of beans to create the features.metadataHeaders
- headers to describe any metadata.outputNames
- customizable output names used byLabelledResultsCollector
.grouper
- when defined, assigns each input to a group.context
- context.- Returns:
- a newly created
FeatureExporter
. - Throws:
CreateException
- if it cannot be successfully created.
-
create
public static <T extends FeatureInput> FeatureExporter<FeatureList<T>> create(NamedFeatureStore<T> featureStore, LabelHeaders metadataHeaders, FeatureOutputNames outputNames, Optional<InputGrouper> grouper, FeatureExporterContext context) throws CreateException Alternative static constructor that creates a shared-state from aNamedFeatureStore
.- Type Parameters:
T
- feature input-type in store- Parameters:
featureStore
- a list of beans to create the features.metadataHeaders
- headers to describe any metadata.outputNames
- customizable output names used byLabelledResultsCollector
.grouper
- when defined, assigns each input to a group.context
- context.- Returns:
- a newly created
FeatureExporter
. - Throws:
CreateException
- if it cannot be successfully created.
-
create
public static <T extends FeatureInput> FeatureExporter<FeatureTableCalculator<T>> create(FeatureOutputNames outputNames, FeatureTableCalculator<T> features, LabelHeaders identifierHeaders, Optional<InputGrouper> grouper, FeatureExporterContext context) throws CreateException Alternative static constructor that creates a shared-state from aNamedFeatureStore
.- Type Parameters:
T
- feature input-type in store- Parameters:
outputNames
- the names of the feature outputs.features
- a table calculator for features.identifierHeaders
- headers to describe the identifier metadata before the feature values.grouper
- when defined, assigns each input to a group.context
- context.- Returns:
- a newly created
FeatureExporter
. - Throws:
CreateException
- if it cannot be successfully created.
-
createCalculationContext
public FeatureCalculationContext<S> createCalculationContext(Optional<String> groupName, ExecutionTimeRecorder executionTimeRecorder, InputOutputContext ioContext) Creates aFeatureCalculationContext
for calculating features to later use this exporter.- Parameters:
groupName
- the group to associate with the feature-results when outputted.executionTimeRecorder
- records execution-times.ioContext
- IO-context.- Returns:
- a newly created context.
-
closeAndWriteOutputs
public void closeAndWriteOutputs(Optional<NamedFeatureStore<FeatureInputResults>> featuresAggregate, boolean includeGroups, Function<InputOutputContext, FeatureCSVWriterFactory> csvWriterCreator, InputOutputContext context) throws OutputWriteFailedExceptionWrites all the results that have been collected as a CSV file, and closes open I/O handles and memory structures.- Parameters:
featuresAggregate
- features that can be used for generating additional "aggregated" exports.includeGroups
- iff true a group-column is included in the CSV file and the group exports occur, otherwise not.csvWriterCreator
- creates a CSV writer for a particular IO-context.context
- IO-context.- Throws:
OutputWriteFailedException
- if any output cannot be written, or there is an error closing open I/O.
-
getFeatureNames
The names of the features to be exported. -
getResults
Saved store feature calculation results, and writes associated thumbnails. -
getGrouper
When defined, assigns each input to a group.
-