The PivotBatchCalculator class calculates the values for multiple cells in the pivot table in one evaluation step (per batch), instead of evaluating every calculation once per pivot table cell.

## Format

R6Class object.

## Details

Evaluating a set of filters and calculations repetitively for each cell is inefficient and slow. The Batch Calculator executes a much small number of calculations which greatly reduces the CPU time and elapsed time required. See the "Performance" vignette for details.

## Active bindings

batchCount

The number of batches generated for the pivot table.

calculationSummary

A summary of the batch compatibility for each calculation.

batchSummary

A summary of the batches in the pivot table.

## Methods

### Method new()

Create a new PivotBatchCalculator object.

No return value.

### Method checkValidWorkingData()

Run some additional checks to see whether the working data is valid. Typically only used in development builds of the package.

#### Arguments

filters

A PivotFilters object that represents a set of filters to examine.

#### Details

It is not practical to make batch evaluation work where a filter matches more than one value for a variable. One approach might be to add a derived column where a single value represents the multiple values, however the combination of values could partially overlap with combinations of values in other data groups. Also the value that represents the "combined" value could collide with other existing values in the column. In summary: Sequential mode is slower and more flexible. Batch is faster but stricter. Batch mode works for regular pivot tables (i.e. most cases).

#### Returns

TRUE if the filters are batch compatible, FALSE otherwise.

### Method generateBatchesForNamedCalculationEvaluation1()

Generates a new batch or finds a relevant existing batch for a named calculation and single working filters object.

PivotBatchCalculator$generateBatchesForNamedCalculationEvaluation1( dataName = NULL, calculationName = NULL, calculationGroupName = NULL, workingFilters = NULL ) #### Arguments dataName The name of the data frame (as specified in pt$addData()).

calculationName

The name of the calculation.

calculationGroupName

The calculation group of the calculation.

workingFilters

A PivotFilters object that represents the working filters to generate the batch for.

#### Returns

The name of either the batch that was created or the relevant existing batch.

### Method generateBatchesForNamedCalculationEvaluation2()

Generates one or more batches for the named calculations and set of working working data associated with a cell.

#### Returns

One or more batch names of either the batches that were created or the relevant existing batches.

### Method evaluateBatches()

Evaluate each of the batches defined in the batch calculator.

PivotBatchCalculator$evaluateBatches() #### Returns The number of batches that were evaluated. ### Method getSummaryValueFromBatch() Retrieve one calculation value from one batch, typically for the value of one cell in a pivot table. #### Usage PivotBatchCalculator$getSummaryValueFromBatch(
batchName = NULL,
calculationName = NULL,
calculationGroupName = NULL,
workingFilters = NULL
)

#### Arguments

batchName

The name of the batch containing the calculation result.

calculationName

The name of the calculation.

calculationGroupName

The calculation group of the calculation.

workingFilters

A PivotFilters object that represents the working filters to retrieve the value for.

#### Returns

A single calculation value.

### Method clone()

The objects of this class are cloneable with this method.

#### Usage

PivotBatchCalculator\$clone(deep = FALSE)

#### Arguments

deep

Whether to make a deep clone.

## Examples

# This class should only be created by the pivot table.
# It is not intended to be created outside of the pivot table.