org.apache.sysds.runtime.compress.colgroup

## Class ColGroupConst

- java.lang.Object
- - org.apache.sysds.runtime.compress.colgroup.AColGroup
  - - org.apache.sysds.runtime.compress.colgroup.ColGroupCompressed
    - - org.apache.sysds.runtime.compress.colgroup.ColGroupConst

All Implemented Interfaces:
  Serializable

    public class ColGroupConst
    extends ColGroupCompressed

See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.sysds.runtime.compress.colgroup.AColGroup

`AColGroup.CompressionType`

### Constructor Summary

Constructors
Constructor and Description
`ColGroupConst(int[] colIndices, ADictionary dict)` Constructs an Constant Colum Group, that contains only one tuple, with the given value.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addToCommon(double[] constV)` Take the values in this constant column group and add to the given constV.
`AColGroup` `binaryRowOp(BinaryOperator op, double[] v, boolean sparseSafe, boolean left)` Perform a binary row operation.
`boolean` `containsValue(double pattern)` Detect if the column group contains a specific value.
`AColGroup` `copy()` Get a copy of this column group.
`void` `countNonZerosPerRow(int[] rnnz, int rl, int ru)` Count the number of non-zeros per row
`void` `decompressToBlock(MatrixBlock target, int rl, int ru, int offT)` Decompress the contents of the column group without counting non zeros
`double` `get(int r, int c)` Get the value at a global row/column position.
`org.apache.sysds.runtime.compress.colgroup.AColGroup.ColGroupType` `getColGroupType()` Internally get the specific type of ColGroup, this could be extracted from the object but that does not allow for nice switches in the code.
`AColGroup.CompressionType` `getCompType()` Obtain the compression type.
`long` `getExactSizeOnDisk()` Returns the exact serialized size of column group.
`long` `getNumberNonZeros(int nRows)` Get the number of nonZeros contained in this column group.
`int` `getNumValues()` Obtain number of distinct tuples in contained sets of values associated with this column group.
`double[]` `getValues()` Get all the values in the colGroup.
`MatrixBlock` `getValuesAsBlock()` Returns the ColGroup as a MatrixBlock.
`boolean` `isDense()` Is dense, signals that the entire column group is allocated an processed.
`boolean` `isLossy()` Is Lossy
`void` `leftMultByAColGroup(AColGroup lhs, MatrixBlock result)` Left side matrix multiplication with a column group that is transposed.
`void` `leftMultByMatrix(MatrixBlock matrix, MatrixBlock result, int rl, int ru)` Left multiply with this column group.
`void` `readFields(DataInput in)` Deserialize column group from data input.
`AColGroup` `replace(double pattern, double replace)` Make a copy of the column group values, and replace all values that match pattern with replacement value.
`AColGroup` `rightMultByMatrix(MatrixBlock right)` Right matrix multiplication with this column group.
`AColGroup` `scalarOperation(ScalarOperator op)` Perform the specified scalar operation directly on the compressed column group, without decompressing individual cells if possible.
`String` `toString()`
`void` `tsmm(double[] result, int numColumns, int nRows)`
`void` `tsmmAColGroup(AColGroup other, MatrixBlock result)` Matrix multiply with this other column group, but: 1.
`void` `write(DataOutput out)` Serializes column group to data output.

### Methods inherited from class org.apache.sysds.runtime.compress.colgroup.ColGroupCompressed

`computeColSums, getMax, getMin, tsmm, unaryAggregateOperations`

### Methods inherited from class org.apache.sysds.runtime.compress.colgroup.AColGroup

`colSum, decompressToBlock, estimateInMemorySize, getColIndices, getNumCols, leftMultByMatrix, shiftColIndices, sliceColumn, sliceColumns`

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

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

### Constructor Detail

#### ColGroupConst

    public ColGroupConst(int[] colIndices,
                         ADictionary dict)

Constructs an Constant Colum Group, that contains only one tuple, with the given value.

Parameters:
  `colIndices` - The Colum indexes for the column group.
  `dict` - The dictionary containing one tuple for the entire compression.

### Method Detail

#### getCompType

    public AColGroup.CompressionType getCompType()

Description copied from class: `AColGroup`
Obtain the compression type.

Specified by:
  `getCompType` in class `AColGroup`
Returns:
  How the elements of the column group are compressed.

#### getColGroupType

    public org.apache.sysds.runtime.compress.colgroup.AColGroup.ColGroupType getColGroupType()

Description copied from class: `AColGroup`
Internally get the specific type of ColGroup, this could be extracted from the object but that does not allow for nice switches in the code.

Returns:
  ColGroupType of the object.

#### decompressToBlock

    public void decompressToBlock(MatrixBlock target,
                                  int rl,
                                  int ru,
                                  int offT)

Description copied from class: `AColGroup`
Decompress the contents of the column group without counting non zeros

Specified by:
  `decompressToBlock` in class `AColGroup`
Parameters:
  `target` - a matrix block where the columns covered by this column group have not yet been filled in.
  `rl` - row lower
  `ru` - row upper
  `offT` - Offset into target to assign from, this allows us to decompress into smaller matrices.

#### get

    public double get(int r,
                      int c)

Description copied from class: `AColGroup`
Get the value at a global row/column position. In general this performs poorly compared to a normal lookup in a dense or sparse matrix.

Specified by:
  `get` in class `AColGroup`
Parameters:
  `r` - row
  `c` - column
Returns:
  value at the row/column position

#### scalarOperation

    public AColGroup scalarOperation(ScalarOperator op)

Description copied from class: `AColGroup`
Perform the specified scalar operation directly on the compressed column group, without decompressing individual cells if possible.

Specified by:
  `scalarOperation` in class `AColGroup`
Parameters:
  `op` - operation to perform
Returns:
  version of this column group with the operation applied

#### binaryRowOp

    public AColGroup binaryRowOp(BinaryOperator op,
                                 double[] v,
                                 boolean sparseSafe,
                                 boolean left)

Description copied from class: `AColGroup`
Perform a binary row operation.

Specified by:
  `binaryRowOp` in class `AColGroup`
Parameters:
  `op` - The operation to execute
  `v` - The vector of values to apply, should be same length as dictionary length.
  `sparseSafe` - True if the operation return 0 on all instances of values in v -- op(v[?], 0)
  `left` - Specifies if the operation is executed on the left or right side of the values contained
Returns:
  A updated column group with the new values.

#### countNonZerosPerRow

    public void countNonZerosPerRow(int[] rnnz,
                                    int rl,
                                    int ru)

Description copied from class: `AColGroup`
Count the number of non-zeros per row

Specified by:
  `countNonZerosPerRow` in class `AColGroup`
Parameters:
  `rnnz` - non-zeros per row
  `rl` - row lower bound, inclusive
  `ru` - row upper bound, exclusive

#### addToCommon

    public void addToCommon(double[] constV)

Take the values in this constant column group and add to the given constV. This allows us to completely ignore this column group for future calculations.

Parameters:
  `constV` - The output columns.

#### getValues

    public double[] getValues()

Description copied from class: `AColGroup`
Get all the values in the colGroup. Note that this is only the stored values not the way they are stored. Making the output a list of values used in that colGroup not the actual full column.

Specified by:
  `getValues` in class `ColGroupCompressed`
Returns:
  a double list of values.

#### isLossy

    public final boolean isLossy()

Description copied from class: `AColGroup`
Is Lossy

Specified by:
  `isLossy` in class `ColGroupCompressed`
Returns:
  returns if the ColGroup is compressed in a lossy manner.

#### getNumValues

    public int getNumValues()

Description copied from class: `AColGroup`
Obtain number of distinct tuples in contained sets of values associated with this column group. If the column group is uncompressed the number or rows is returned.

Specified by:
  `getNumValues` in class `AColGroup`
Returns:
  the number of distinct sets of values associated with the bitmaps in this column group

#### getValuesAsBlock

    public MatrixBlock getValuesAsBlock()

Description copied from class: `AColGroup`
Returns the ColGroup as a MatrixBlock. Used as a fall back solution in case a operation is not supported. Use in connection to getIfCountsType to get if the values are repeated.

Specified by:
  `getValuesAsBlock` in class `AColGroup`
Returns:
  Matrix Block of the contained Values. Possibly contained in groups.

#### rightMultByMatrix

    public AColGroup rightMultByMatrix(MatrixBlock right)

Description copied from class: `AColGroup`
Right matrix multiplication with this column group.

Specified by:
  `rightMultByMatrix` in class `AColGroup`
Parameters:
  `right` - The matrixBlock on the right of this matrix multiplication
Returns:
  The new Column Group that is the result of the matrix multiplication.

#### tsmm

    public void tsmm(double[] result,
                     int numColumns,
                     int nRows)

#### leftMultByMatrix

    public void leftMultByMatrix(MatrixBlock matrix,
                                 MatrixBlock result,
                                 int rl,
                                 int ru)

Description copied from class: `AColGroup`
Left multiply with this column group.

Specified by:
  `leftMultByMatrix` in class `AColGroup`
Parameters:
  `matrix` - The matrix to multiply with on the left
  `result` - The result to output the values into, always dense for the purpose of the column groups parallelizing
  `rl` - The row to begin the multiplication from on the lhs matrix
  `ru` - The row to end the multiplication at on the lhs matrix

#### leftMultByAColGroup

    public void leftMultByAColGroup(AColGroup lhs,
                                    MatrixBlock result)

Description copied from class: `AColGroup`
Left side matrix multiplication with a column group that is transposed.

Specified by:
  `leftMultByAColGroup` in class `AColGroup`
Parameters:
  `lhs` - The left hand side Column group to multiply with, the left hand side should be considered transposed.
  `result` - The result matrix to insert the result of the multiplication into

#### tsmmAColGroup

    public void tsmmAColGroup(AColGroup other,
                              MatrixBlock result)

Description copied from class: `AColGroup`
Matrix multiply with this other column group, but: 1. Only output upper triangle values. 2. Multiply both ways with "this" being on the left and on the right. The second step is achievable by treating the initial multiplied matrix, and adding its values to the correct locations in the output.

Specified by:
  `tsmmAColGroup` in class `AColGroup`
Parameters:
  `other` - The other Column group to multiply with
  `result` - The result matrix to put the results into

#### isDense

    public boolean isDense()

Description copied from class: `AColGroup`
Is dense, signals that the entire column group is allocated an processed. This is useful in Row wise min and max for instance, to avoid having to scan through each row to look for empty rows. an example where it is true is DDC, Const and Uncompressed. examples where false is OLE and RLE.

Specified by:
  `isDense` in class `AColGroup`
Returns:
  returns if the colGroup is allocated in a dense fashion.

#### copy

    public AColGroup copy()

Description copied from class: `AColGroup`
Get a copy of this column group. Depending on which column group is copied it is a deep or shallow copy. If the primitives for the underlying column groups is Immutable then only shallow copies is performed.

Specified by:
  `copy` in class `AColGroup`
Returns:
  Get a copy of this column group.

#### containsValue

    public boolean containsValue(double pattern)

Description copied from class: `AColGroup`
Detect if the column group contains a specific value.

Specified by:
  `containsValue` in class `AColGroup`
Parameters:
  `pattern` - The value to look for.
Returns:
  boolean saying true if the value is contained.

#### getNumberNonZeros

    public long getNumberNonZeros(int nRows)

Description copied from class: `AColGroup`
Get the number of nonZeros contained in this column group.

Specified by:
  `getNumberNonZeros` in class `AColGroup`
Parameters:
  `nRows` - The number of rows in the column group, this is used for groups that does not contain information about how many rows they have.
Returns:
  The nnz.

#### replace

    public AColGroup replace(double pattern,
                             double replace)

Description copied from class: `AColGroup`
Make a copy of the column group values, and replace all values that match pattern with replacement value.

Specified by:
  `replace` in class `AColGroup`
Parameters:
  `pattern` - The value to look for
  `replace` - The value to replace the other value with
Returns:
  A new Column Group, reusing the index structure but with new values.

#### readFields

    public void readFields(DataInput in)
                    throws IOException

Description copied from class: `AColGroup`
Deserialize column group from data input.

Overrides:
  `readFields` in class `AColGroup`
Parameters:
  `in` - data input
Throws:
  `IOException` - if IOException occurs

#### write

    public void write(DataOutput out)
               throws IOException

Description copied from class: `AColGroup`
Serializes column group to data output.

Overrides:
  `write` in class `AColGroup`
Parameters:
  `out` - data output
Throws:
  `IOException` - if IOException occurs

#### getExactSizeOnDisk

    public long getExactSizeOnDisk()

Description copied from class: `AColGroup`
Returns the exact serialized size of column group. This can be used for example for buffer preallocation.

Overrides:
  `getExactSizeOnDisk` in class `AColGroup`
Returns:
  exact serialized size for column group

#### toString

    public String toString()

Overrides:
  `toString` in class `AColGroup`