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:
    ColGroupConst, 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
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addMatrixToResult(MatrixBlock tmp, MatrixBlock result, int rl, int ru)`
    `void` | `addMinMax(double[] ret)`
    `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` | `decompressToBlockSafe(MatrixBlock target, int rl, int ru, int offT)` Decompress the contents of this column group into the specified full matrix block while managing the number of non zeros.
    `void` | `decompressToBlockUnSafe(MatrixBlock target, int rl, int ru, int offT)` Decompress the contents of the columngroup unsafely, meaning that it does not count nonzero values.
    `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()` 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)` 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` | `tsmm(MatrixBlock ret)` Do a transposed self matrix multiplication on the left side t(x) %*% x.
    `void` | `write(DataOutput out)` Serializes column group to data output.

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

      `getMax, getMin, getNumRows, unaryAggregateOperations, unaryAggregateOperations`

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

      `binaryRowOp, countNonZerosPerRow, decompressColumnToBlockUnSafe, decompressToBlockUnSafe, 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

    - #### decompressToBlockSafe

          public final void decompressToBlockSafe(MatrixBlock target,
                                                  int rl,
                                                  int ru,
                                                  int offT)

      Description copied from class: `AColGroup`
      Decompress the contents of this column group into the specified full matrix block while managing the number of non zeros.
      Specified by:
        `decompressToBlockSafe` 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

    - #### decompressToBlockUnSafe

          public final void decompressToBlockUnSafe(MatrixBlock target,
                                                    int rl,
                                                    int ru,
                                                    int offT)

      Description copied from class: `AColGroup`
      Decompress the contents of the columngroup unsafely, meaning that it does not count nonzero values.
      Specified by:
        `decompressToBlockUnSafe` 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

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

    - #### addMinMax

          public final void addMinMax(double[] ret)

      Specified by:
        `addMinMax` in class `ColGroupCompressed`

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

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

    - #### tsmm

          public final void tsmm(MatrixBlock ret)

      Description copied from class: `AColGroup`
      Do a transposed self matrix multiplication on the left side t(x) %*% x. but only with this column group. This gives better performance since there is no need to iterate through all the rows of the matrix, but the execution can be limited to its number of distinct values. Note it only calculate the upper triangle
      Specified by:
        `tsmm` in class `AColGroup`
      Parameters:
        `ret` - The return matrix block [numColumns x numColumns]

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

      Description copied from class: `AColGroup`
      Get the number of nonZeros contained in this column group.
      Specified by:
        `getNumberNonZeros` in class `AColGroup`
      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 `ColGroupCompressed`
      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.

Copyright © 2021 The Apache Software Foundation. All rights reserved.