org.apache.sysds.runtime.compress.colgroup

## Class ColGroupUncompressed

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

- All Implemented Interfaces:
    Serializable

      public class ColGroupUncompressed
      extends AColGroup

  Column group type for columns that are stored as dense arrays of doubles. Uses a MatrixBlock internally to store the column contents.
  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
    `ColGroupUncompressed(int[] colIndicesList, MatrixBlock rawBlock, boolean transposed)` Main constructor for Uncompressed ColGroup.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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` | `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.
    `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.
    `MatrixBlock` | `getData()` Access for superclass
    `long` | `getExactSizeOnDisk()` Returns the exact serialized size of column group.
    `double` | `getMax()` Short hand method for getting maximum value contained in this column group.
    `double` | `getMin()` Short hand method for getting minimum value contained in this column group.
    `long` | `getNumberNonZeros()` Get the number of nonZeros contained in this column group.
    `int` | `getNumRows()` Get number of rows contained in the ColGroup.
    `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(MatrixBlock ret)` Do a transposed self matrix multiplication on the left side t(x) %*% x.
    `void` | `unaryAggregateOperations(AggregateUnaryOperator op, double[] ret)` Unary Aggregate operator, since aggregate operators require new object output, the output becomes an uncompressed matrix.
    `void` | `unaryAggregateOperations(AggregateUnaryOperator op, double[] result, int rl, int ru)` Unary Aggregate operator, since aggregate operators require new object output, the output becomes an uncompressed matrix.
    `void` | `write(DataOutput out)` Serializes column group to data output.

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

      `decompressColumnToBlockUnSafe, decompressToBlockUnSafe, getColIndices, getNumCols, leftMultByMatrix, shiftColIndices, sliceColumn, sliceColumns`

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

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

- - ### Constructor Detail

    - #### ColGroupUncompressed

          public ColGroupUncompressed(int[] colIndicesList,
                                      MatrixBlock rawBlock,
                                      boolean transposed)

      Main constructor for Uncompressed ColGroup.
      Parameters:
        `colIndicesList` - Indices (relative to the current block) of the columns that this column group represents.
        `rawBlock` - The uncompressed block; uncompressed data must be present at the time that the constructor is called
        `transposed` - Says if the input matrix raw block have been transposed.

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

    - #### getData

          public MatrixBlock getData()

      Access for superclass
      Returns:
        direct pointer to the internal representation of the columns

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

    - #### decompressToBlockSafe

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

    - #### get

          public double get(int r,
                            int c)

      Description copied from class: `AColGroup`
      Get the value at a global row/column position.
      Specified by:
        `get` in class `AColGroup`
      Parameters:
        `r` - row
        `c` - column
      Returns:
        value at the row/column position

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

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

    - #### unaryAggregateOperations

          public void unaryAggregateOperations(AggregateUnaryOperator op,
                                               double[] ret)

      Description copied from class: `AColGroup`
      Unary Aggregate operator, since aggregate operators require new object output, the output becomes an uncompressed matrix.
      Specified by:
        `unaryAggregateOperations` in class `AColGroup`
      Parameters:
        `op` - The operator used
        `ret` - Rhe output matrix block.

    - #### unaryAggregateOperations

          public void unaryAggregateOperations(AggregateUnaryOperator op,
                                               double[] result,
                                               int rl,
                                               int ru)

      Description copied from class: `AColGroup`
      Unary Aggregate operator, since aggregate operators require new object output, the output becomes an uncompressed matrix.
      Specified by:
        `unaryAggregateOperations` in class `AColGroup`
      Parameters:
        `op` - The operator used
        `result` - The output matrix block.
        `rl` - The Starting Row to do aggregation from
        `ru` - The last Row to do aggregation to (not included)

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

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

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `AColGroup`

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

    - #### 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 `AColGroup`
      Returns:
        a double list of values.

    - #### isLossy

          public boolean isLossy()

      Description copied from class: `AColGroup`
      Is Lossy
      Specified by:
        `isLossy` in class `AColGroup`
      Returns:
        returns if the ColGroup is compressed in a lossy manner.

    - #### getMin

          public double getMin()

      Description copied from class: `AColGroup`
      Short hand method for getting minimum value contained in this column group.
      Specified by:
        `getMin` in class `AColGroup`
      Returns:
        The minimum value contained in this ColumnGroup

    - #### getMax

          public double getMax()

      Description copied from class: `AColGroup`
      Short hand method for getting maximum value contained in this column group.
      Specified by:
        `getMax` in class `AColGroup`
      Returns:
        The maximum value contained in this ColumnGroup

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

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

      Description copied from class: `AColGroup`
      Get the number of nonZeros contained in this column group.
      Specified by:
        `getNumberNonZeros` in class `AColGroup`
      Returns:
        The nnz.

    - #### getNumRows

          public int getNumRows()

      Description copied from class: `AColGroup`
      Get number of rows contained in the ColGroup.
      Specified by:
        `getNumRows` in class `AColGroup`
      Returns:
        An integer that is the number of rows.

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

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

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

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

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