org.apache.sysds.runtime.compress.colgroup

## Class ColGroupValue

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

All Implemented Interfaces:
  Serializable, Cloneable

Direct Known Subclasses:
  ColGroupDDC, ColGroupOffset, ColGroupSDC, ColGroupSDCSingle, ColGroupSDCSingleZeros, ColGroupSDCZeros

    public abstract class ColGroupValue
    extends ColGroupCompressed
    implements Cloneable

Base class for column groups encoded with value dictionary. This include column groups such as DDC OLE and RLE.

See Also:
  Serialized Form

### Nested Class Summary

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

`AColGroup.CompressionType`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`void` `addMatrixToResult(MatrixBlock tmp, MatrixBlock result, int rl, int ru)`
`static MatrixBlock` `allocatePreAggregate(MatrixBlock m, int numVals, int rl, int ru)`
`static void` `cleanupThreadLocalMemory()`
`boolean` `containsValue(double pattern)` Detect if the column group contains a specific value.
`ColGroupValue` `copy()` Get a copy of this column group.
`AColGroup` `copyAndSet(ADictionary newDictionary)`
`AColGroup` `copyAndSet(double[] newDictionary)`
`AColGroup` `copyAndSet(int[] colIndexes, ADictionary newDictionary)`
`AColGroup` `copyAndSet(int[] colIndexes, double[] newDictionary)`
`void` `decompressToBlock(MatrixBlock target, int rl, int ru, int offT)` Decompress the contents of the column group without counting non zeros
`long` `estimateInMemorySize()` Get the upper bound estimate of in memory allocation for the column group.
`int[]` `getCachedCounts()` Get the cached counts.
`int[]` `getCounts()` Returns the counts of values inside the dictionary.
`abstract int[]` `getCounts(int[] out)`
`int[]` `getCounts(int rl, int ru)` Returns the counts of values inside the MatrixBlock returned in getValuesAsBlock Throws an exception if the getIfCountsType is false.
`abstract int[]` `getCounts(int rl, int ru, int[] out)`
`ADictionary` `getDictionary()`
`long` `getExactSizeOnDisk()` Returns the exact serialized size of column group.
`boolean` `getIfCountsType()`
`long` `getNumberNonZeros(int nRows)` Get the number of nonZeros contained in this column group.
`int` `getNumRows()`
`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)` Multiply with a matrix on the left.
`MatrixBlock` `leftMultByPreAggregateMatrix(MatrixBlock preAgg)`
`MatrixBlock` `leftMultByPreAggregateMatrix(MatrixBlock preAgg, MatrixBlock tmpRes)`
`abstract void` `preAggregate(MatrixBlock m, MatrixBlock preAgg, int rl, int ru)` Pre aggregate for left Multiplication.
`abstract void` `preAggregateDense(MatrixBlock m, MatrixBlock preAgg, int rl, int ru, int vl, int vu)`
`Dictionary` `preAggregateThatIndexStructure(ColGroupValue that, boolean preModify)` Pre aggregate into a dictionary.
`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.
`static void` `setupLeftMultThreadLocalMemory(int len)`
`static void` `setupThreadLocalMemory(int len)`
`String` `toString()`
`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

`binaryRowOp, colSum, countNonZerosPerRow, decompressToBlock, get, getColIndices, getCompType, getNumCols, leftMultByMatrix, scalarOperation, shiftColIndices, sliceColumn, sliceColumns`

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

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

### Method Detail

#### decompressToBlock

    public final 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.

#### getNumValues

    public final 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

#### getValues

    public final 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.

#### getDictionary

    public final ADictionary getDictionary()

#### getValuesAsBlock

    public final 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.

#### getCounts

    public final int[] getCounts()

Returns the counts of values inside the dictionary. If already calculated it will return the previous counts. This produce an overhead in cases where the count is calculated, but the overhead will be limited to number of distinct tuples in the dictionary. The returned counts always contains the number of zeros as well if there are some contained, even if they are not materialized.

Returns:
  the count of each value in the MatrixBlock.

#### getCachedCounts

    public final int[] getCachedCounts()

Get the cached counts. If they are not materialized or the garbage collector have removed them, then null is returned

Returns:
  the counts or null.

#### getCounts

    public final int[] getCounts(int rl,
                                 int ru)

Returns the counts of values inside the MatrixBlock returned in getValuesAsBlock Throws an exception if the getIfCountsType is false. The returned counts always contains the number of zeros as well if there are some contained, even if they are not materialized.

Parameters:
  `rl` - the lower index of the interval of rows queried
  `ru` - the the upper boundary of the interval of rows queried
Returns:
  the count of each value in the MatrixBlock.

#### getIfCountsType

    public boolean getIfCountsType()

#### setupThreadLocalMemory

    public static void setupThreadLocalMemory(int len)

#### setupLeftMultThreadLocalMemory

    public static void setupLeftMultThreadLocalMemory(int len)

#### cleanupThreadLocalMemory

    public static void cleanupThreadLocalMemory()

#### toString

    public String toString()

Overrides:
  `toString` in class `AColGroup`

#### 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.

#### 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

#### getCounts

    public abstract int[] getCounts(int[] out)

#### getCounts

    public abstract int[] getCounts(int rl,
                                    int ru,
                                    int[] out)

#### copyAndSet

    public AColGroup copyAndSet(double[] newDictionary)

#### copyAndSet

    public AColGroup copyAndSet(ADictionary newDictionary)

#### copyAndSet

    public AColGroup copyAndSet(int[] colIndexes,
                                double[] newDictionary)

#### copyAndSet

    public AColGroup copyAndSet(int[] colIndexes,
                                ADictionary newDictionary)

#### copy

    public ColGroupValue 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.

#### allocatePreAggregate

    public static final MatrixBlock allocatePreAggregate(MatrixBlock m,
                                                         int numVals,
                                                         int rl,
                                                         int ru)

#### preAggregate

    public abstract void preAggregate(MatrixBlock m,
                                      MatrixBlock preAgg,
                                      int rl,
                                      int ru)

Pre aggregate for left Multiplication.

Parameters:
  `m` - Matrix to preAggregate
  `preAgg` - Matrix to preAggregate into
  `rl` - Start row
  `ru` - End row

#### preAggregateDense

    public abstract void preAggregateDense(MatrixBlock m,
                                           MatrixBlock preAgg,
                                           int rl,
                                           int ru,
                                           int vl,
                                           int vu)

#### preAggregateThatIndexStructure

    public final Dictionary preAggregateThatIndexStructure(ColGroupValue that,
                                                           boolean preModify)

Pre aggregate into a dictionary. It is assumed that "that" have more distinct values than, "this".

Parameters:
  `that` - the other column group whose indexes are used for aggregation.
  `preModify` - specifies if the matrix in this
Returns:
  A aggregate dictionary

#### leftMultByAColGroup

    public final 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

#### containsValue

    public final 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 final 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.

#### isDense

    public final 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.

#### leftMultByMatrix

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

Multiply with a matrix on the left.

Specified by:
  `leftMultByMatrix` in class `AColGroup`
Parameters:
  `matrix` - matrix to left multiply
  `result` - matrix block result
  `rl` - The row to start the matrix multiplication from
  `ru` - The row to stop the matrix multiplication at.

#### leftMultByPreAggregateMatrix

    public final MatrixBlock leftMultByPreAggregateMatrix(MatrixBlock preAgg)

#### leftMultByPreAggregateMatrix

    public final MatrixBlock leftMultByPreAggregateMatrix(MatrixBlock preAgg,
                                                          MatrixBlock tmpRes)

#### addMatrixToResult

    public void addMatrixToResult(MatrixBlock tmp,
                                  MatrixBlock result,
                                  int rl,
                                  int ru)

#### rightMultByMatrix

    public final 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.

#### estimateInMemorySize

    public long estimateInMemorySize()

Description copied from class: `AColGroup`
Get the upper bound estimate of in memory allocation for the column group.

Overrides:
  `estimateInMemorySize` in class `AColGroup`
Returns:
  an upper bound on the number of bytes used to store this ColGroup in memory.

#### 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.

#### getNumRows

    public final int getNumRows()