org.apache.sysds.runtime.compress

## Class CompressedMatrixBlockFactory

- java.lang.Object
- - org.apache.sysds.runtime.compress.CompressedMatrixBlockFactory

    public class CompressedMatrixBlockFactory
    extends Object

Factory pattern to construct a CompressedMatrixBlock.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static org.apache.commons.lang3.tuple.Pair<MatrixBlock,CompressionStatistics>` `compress(MatrixBlock mb)` Default sequential compression with no parallelization
`static org.apache.commons.lang3.tuple.Pair<MatrixBlock,CompressionStatistics>` `compress(MatrixBlock mb, CompressionSettings customSettings)`
`static org.apache.commons.lang3.tuple.Pair<MatrixBlock,CompressionStatistics>` `compress(MatrixBlock mb, int k)`
`static org.apache.commons.lang3.tuple.Pair<MatrixBlock,CompressionStatistics>` `compress(MatrixBlock mb, int k, CompressionSettings compSettings)` The main method for compressing the input matrix.
`static CompressedMatrixBlock` `createConstant(int numRows, int numCols, double value)` Method for constructing a compressed matrix out of an constant input.
`double` `getLastTimePhase()`
`void` `setNextTimePhase(double time)`

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

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

### Method Detail

#### compress

    public static org.apache.commons.lang3.tuple.Pair<MatrixBlock,CompressionStatistics> compress(MatrixBlock mb)

Default sequential compression with no parallelization

Parameters:
  `mb` - The matrixBlock to compress
Returns:
  A Pair of a Matrix Block and Compression Statistics.

#### compress

    public static org.apache.commons.lang3.tuple.Pair<MatrixBlock,CompressionStatistics> compress(MatrixBlock mb,
                                                                                                  CompressionSettings customSettings)

#### compress

    public static org.apache.commons.lang3.tuple.Pair<MatrixBlock,CompressionStatistics> compress(MatrixBlock mb,
                                                                                                  int k)

#### compress

    public static org.apache.commons.lang3.tuple.Pair<MatrixBlock,CompressionStatistics> compress(MatrixBlock mb,
                                                                                                  int k,
                                                                                                  CompressionSettings compSettings)

The main method for compressing the input matrix. SAMPLE-BASED DECISIONS: Decisions such as testing if a column is amenable to bitmap compression or evaluating co-coding potentials are made based on a subset of the rows. For large data sets, sampling might take a significant amount of time. So, we generate only one sample and use it for the entire compression process. Once the compression plan is selected based on sampling, the plan is verified and decisions are overwritten by full estimates.

Parameters:
  `mb` - The matrix block to compress
  `k` - The number of threads used to execute the compression
  `compSettings` - The Compression settings used
Returns:
  A pair of an possibly compressed matrix block and compression statistics.

#### createConstant

    public static CompressedMatrixBlock createConstant(int numRows,
                                                       int numCols,
                                                       double value)

Method for constructing a compressed matrix out of an constant input. Since the input is a constant value it is trivially compressable, therefore we skip the entire compression planning and directly return a compressed constant matrix

Parameters:
  `numRows` - The number of Rows in the matrix
  `numCols` - The number of Columns in the matrix
  `value` - The value contained in the matrix
Returns:
  The Compressed Constant matrix.

#### setNextTimePhase

    public void setNextTimePhase(double time)

#### getLastTimePhase

    public double getLastTimePhase()