Class TableGroup

All Implemented Interfaces:
uk.ac.starlink.task.Task

public class TableGroup extends SingleMapperTask
Task for performing aggregation operations on groups of rows of an input table.
Since:
17 Nov 2022
Author:
Mark Taylor
  • Field Details

    • AGGCOL_DELIM

      public static final char AGGCOL_DELIM
      Delimiter 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 the ConsumerTask.getIdentity(uk.ac.starlink.table.StarTable) method.
      Specified by:
      createProducer in class ConsumerTask
      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 the aggregateRows 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 output
      delimChr - 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 table
      keyExprs - input table values that define grouping
      aggSpecs - specification for output aggregated columns
      runner - row runner
      isSort - 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