Package org.apache.sysds.runtime.compress.cost

## Class ComputationCostEstimator

- java.lang.Object
- - org.apache.sysds.runtime.compress.cost.ACostEstimate
  - - org.apache.sysds.runtime.compress.cost.ComputationCostEstimator

All Implemented Interfaces:
  `Serializable`

    public class ComputationCostEstimator
    extends ACostEstimate

See Also:
  Serialized Form

### Constructor Summary

Constructors
`ComputationCostEstimator​(int scans, int decompressions, int overlappingDecompressions, int leftMultiplications, int rightMultiplications, int compressedMultiplication, int dictOps, int indexing, boolean isDensifying)`

### Method Summary

All Methods Instance Methods Concrete Methods
`double` `getCost​(int nRows, int nRowsScanned, int nCols, int nVals, double sparsity)` Get the cost of a column group.
`double` `getCost​(AColGroup cg, int nRows)` Get the cost of a compressed columnGroup.
`double` `getCost​(MatrixBlock mb)` Get the cost of a matrix block.
`boolean` `isDense()`
`boolean` `shouldSparsify()` Ask the cost estimator if it is a good idea to try to sparsify a column group.
`String` `toString()`

### Methods inherited from class org.apache.sysds.runtime.compress.cost.ACostEstimate

`getCost, getCost, getCost, getCost`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### ComputationCostEstimator

    public ComputationCostEstimator​(int scans,
                                    int decompressions,
                                    int overlappingDecompressions,
                                    int leftMultiplications,
                                    int rightMultiplications,
                                    int compressedMultiplication,
                                    int dictOps,
                                    int indexing,
                                    boolean isDensifying)

### Method Detail

#### getCost

    public double getCost​(int nRows,
                          int nRowsScanned,
                          int nCols,
                          int nVals,
                          double sparsity)

Get the cost of a column group.

Parameters:
  `nRows` - The total number of rows
  `nRowsScanned` - Number of rows to process in this specific group
  `nCols` - Number of columns in the column group
  `nVals` - Number of unique tuples contained in the group
  `sparsity` - The sparsity of the unique tuples stored
Returns:
  A cost

#### isDense

    public boolean isDense()

#### getCost

    public double getCost​(MatrixBlock mb)

Description copied from class: `ACostEstimate`
Get the cost of a matrix block.

Specified by:
  `getCost` in class `ACostEstimate`
Parameters:
  `mb` - A MatrixBlock
Returns:
  The cost subject to the internal cost functions

#### getCost

    public double getCost​(AColGroup cg,
                          int nRows)

Description copied from class: `ACostEstimate`
Get the cost of a compressed columnGroup.

Specified by:
  `getCost` in class `ACostEstimate`
Parameters:
  `cg` - A ColumnGroup
  `nRows` - The number of rows in the column group
Returns:
  The cost subject to the internal cost functions

#### shouldSparsify

    public boolean shouldSparsify()

Description copied from class: `ACostEstimate`
Ask the cost estimator if it is a good idea to try to sparsify a column group. It is the same as asking if it is a good idea to make FOR on top of the column group.

Specified by:
  `shouldSparsify` in class `ACostEstimate`
Returns:
  true if yes

#### toString

    public String toString()

Overrides:
  `toString` in class `ACostEstimate`