Package uk.ac.starlink.ttools.task
Class TableGroup
java.lang.Object
uk.ac.starlink.ttools.task.ConsumerTask
uk.ac.starlink.ttools.task.SingleMapperTask
uk.ac.starlink.ttools.task.TableGroup
- All Implemented Interfaces:
uk.ac.starlink.task.Task
Task for performing aggregation operations on groups of rows of an
input table.
- Since:
- 17 Nov 2022
- Author:
- Mark Taylor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Defines the aggregation that should be done to form an output column. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char
Delimiter character for aggcol parameter entries. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic uk.ac.starlink.table.StarTable
aggregateRows
(uk.ac.starlink.table.StarTable inTable, String[] keyExprs, TableGroup.AggSpec[] aggSpecs, uk.ac.starlink.table.RowRunner runner, boolean isSort, boolean isCache) Does the aggregation work.createProducer
(uk.ac.starlink.task.Environment env) Returns an object which can produce the effective output table which will be consumed by this task.static TableGroup.AggSpec
parseAggSpec
(String aggSpecTxt, char delimChr) Parses an aggregate specification string to an AggSpec.Methods inherited from class uk.ac.starlink.ttools.task.SingleMapperTask
createInputProducer, getInputFilterParameter, getInputTableParameter
Methods inherited from class uk.ac.starlink.ttools.task.ConsumerTask
createExecutable, createProducer, getIdentity, getOutputMode, getParameterList, getParameters, getPurpose
-
Field Details
-
AGGCOL_DELIM
public static final char AGGCOL_DELIMDelimiter character for aggcol parameter entries.- See Also:
-
-
Constructor Details
-
TableGroup
public TableGroup()Constructor.
-
-
Method Details
-
createProducer
public TableProducer createProducer(uk.ac.starlink.task.Environment env) throws uk.ac.starlink.task.TaskException Description copied from class:ConsumerTask
Returns an object which can produce the effective output table which will be consumed by this task. The table produced by the resulting producer can be fed to theConsumerTask.getIdentity(uk.ac.starlink.table.StarTable)
method.- Specified by:
createProducer
in classConsumerTask
- Parameters:
env
- execution environment- Returns:
- table producer
- Throws:
uk.ac.starlink.task.TaskException
-
parseAggSpec
public static TableGroup.AggSpec parseAggSpec(String aggSpecTxt, char delimChr) throws uk.ac.starlink.task.UsageException Parses an aggregate specification string to an AggSpec. The returned value can be passed to theaggregateRows
method. The input string is as documented of the form "<input-expr><delim><aggregator-name>[<delim><output-name>]
". If the input string cannot be so parsed, a UsageException with an informative message is thrown.- Parameters:
aggSpecTxt
- text specifying aggregated outputdelimChr
- delimiter character between the three parts of the expression- Returns:
- parsed specification
- Throws:
uk.ac.starlink.task.UsageException
-
aggregateRows
public static uk.ac.starlink.table.StarTable aggregateRows(uk.ac.starlink.table.StarTable inTable, String[] keyExprs, TableGroup.AggSpec[] aggSpecs, uk.ac.starlink.table.RowRunner runner, boolean isSort, boolean isCache) throws IOException, uk.ac.starlink.task.TaskException Does the aggregation work.- Parameters:
inTable
- input tablekeyExprs
- input table values that define groupingaggSpecs
- specification for output aggregated columnsrunner
- row runnerisSort
- if true, output table is sorted before return (where possible)isCache
- if true, output table is cached before return- Returns:
- output table containing aggregated values
- Throws:
IOException
uk.ac.starlink.task.TaskException
-