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

## Class ACostEstimate

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

- All Implemented Interfaces:
    `Serializable`
  Direct Known Subclasses:
    `ComputationCostEstimator`, `DistinctCostEstimator`, `HybridCostEstimator`, `MemoryCostEstimator`

      public abstract class ACostEstimate
      extends Object
      implements Serializable

  A cost estimator interface. It is used to estimate the cost at different stages of compression, and used to compare to uncompressed.
  See Also:
    Serialized Form

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `double` | `getCost​(Collection<AColGroup> cgs, int nRows)` | Get the cost of a collection of column groups.
    `abstract double` | `getCost​(AColGroup cg, int nRows)` | Get the cost of a compressed columnGroup.
    `double` | `getCost​(CompressedMatrixBlock cmb)` | Get cost of a compressed matrix block
    `double` | `getCost​(CompressedSizeInfo i)` | Get cost of an entire compression plan
    `double` | `getCost​(CompressedSizeInfoColGroup g)` | Get cost of a single column group estimate.
    `abstract double` | `getCost​(MatrixBlock mb)` | Get the cost of a matrix block.
    `abstract 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 java.lang.Object

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

- - ### Method Detail

    - #### getCost

          public double getCost​(Collection<AColGroup> cgs,
                                int nRows)

      Get the cost of a collection of column groups.
      Parameters:
        `cgs` - A collection of column groups
        `nRows` - The number of rows in the column group
      Returns:
        The summed cost of the groups

    - #### getCost

          public final double getCost​(CompressedSizeInfoColGroup g)

      Get cost of a single column group estimate. If the input is null the cost is positive infinity indicating that it is impossible to compress the null case. If the instruction does not care about the inter column group cost, such as in memory cost or in computation cost of right or left matrix multiplication we simply estimate the cost of individual column groups.
      Parameters:
        `g` - Column group to estimate the cost of
      Returns:
        The Cost of this column group

    - #### getCost

          public double getCost​(CompressedSizeInfo i)

      Get cost of an entire compression plan
      Parameters:
        `i` - The compression plan to get the cost of
      Returns:
        The cost

    - #### getCost

          public double getCost​(CompressedMatrixBlock cmb)

      Get cost of a compressed matrix block
      Parameters:
        `cmb` - The compressed matrix block
      Returns:
        The cost

    - #### getCost

          public abstract double getCost​(MatrixBlock mb)

      Get the cost of a matrix block.
      Parameters:
        `mb` - A MatrixBlock
      Returns:
        The cost subject to the internal cost functions

    - #### getCost

          public abstract double getCost​(AColGroup cg,
                                         int nRows)

      Get the cost of a compressed columnGroup.
      Parameters:
        `cg` - A ColumnGroup
        `nRows` - The number of rows in the column group
      Returns:
        The cost subject to the internal cost functions

    - #### shouldSparsify

          public abstract boolean shouldSparsify()

      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.
      Returns:
        true if yes

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`