# Collapse reference

The Collapse template collapses multiple sequential modifications per primary key into one. On flush it sends out that single modification.

    $collapse = Triceps::Collapse->new($optName => $optValue, ...);

Creates a new Collapse object. The options are:

    name

  Name of this object. Will be used to create the names of internal objects.

    unit

  The unit where this object belongs.

    data

  The data set description. Each data set has an input label and an output label, and collapses one stream of modifications. Currently only one data set is supported, the options have been structured like this to allow for the future extension. This option's value is a reference to an array (not a hash!) that is itself structured as the nested option-value pairs.

The nested options in data are:

    name

  The name of the data set. Used for the error messages. Put it first, this would let the constructor report nicely the errors in the other data set options.

    rowType

  The row type of the data in this set. Mutually exclusive with fromLabel, one must be used.

    fromLabel

  The source label for the data set, its input will be chained to this label. Mutually exclusive with rowType, one must be used.

    key

  The primary key of the data. A reference to an array of strings with field names, same as for the Hash index type.

    $collapse->flush();

Sends out the collected modifications to the output label(s) and clears the state of the collapse.

    $lb = $collapse->getInputLabel($setName);

Returns the input label of a data set. Confesses if there is no data set with this name.

    $lb = $collapse->getOutputLabel($setName);

Returns the output label of a data set. Confesses if there is no data set with this name.

    @setNames = $collapse->getDatasets();

Returns the names of all the data sets (though since currently only one data set is supported, only one name will be returned).

    $fret = $collapse->fnReturn();

Returns an FnReturn object connected to the output of this collapser. The FnReturn contains a label for each data set, named accordingly. The order of the labels matches the specified order of data sets. The FnReturn is created on the first call of this method and is kept in the collapser object. All the following calls return the same object. See more detail in &xrsp;.

Collapse