Class AColGroup
- java.lang.Object
- 
- org.apache.sysds.runtime.compress.colgroup.AColGroup
 
- 
- All Implemented Interfaces:
- Serializable
 - Direct Known Subclasses:
- AColGroupCompressed,- ColGroupUncompressed
 
 public abstract class AColGroup extends Object implements Serializable Abstract Class that is the lowest class type for the Compression framework. AColGroup store information about a number of columns.- See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classAColGroup.CompressionTypePublic super types of compression ColGroups supported
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract AColGroupbinaryRowOpLeft(BinaryOperator op, double[] v, boolean isRowSafe)Perform a binary row operation.abstract AColGroupbinaryRowOpRight(BinaryOperator op, double[] v, boolean isRowSafe)Perform a binary row operation.abstract CM_COV_ObjectcentralMoment(CMOperator op, int nRows)Central Moment instruction executed on a column group.static double[]colSum(List<AColGroup> groups, double[] res, int nRows)Compute the column sum of the given list of groupsabstract voidcomputeColSums(double[] c, int nRows)Compute the column sumabstract booleancontainsValue(double pattern)Detect if the column group contains a specific value.abstract AColGroupcopy()Get a copy of this column group note this is only a shallow copy.voiddecompressToDenseBlock(DenseBlock db, int rl, int ru)Decompress a range of rows into a dense blockabstract voiddecompressToDenseBlock(DenseBlock db, int rl, int ru, int offR, int offC)Decompress into the DenseBlock.voiddecompressToSparseBlock(SparseBlock sb, int rl, int ru)Decompress a range of rows into a sparse block Note that this is using append, so the sparse column indexes need to be sorted afterwards.abstract voiddecompressToSparseBlock(SparseBlock sb, int rl, int ru, int offR, int offC)Decompress into the SparseBlock.longestimateInMemorySize()Get the upper bound estimate of in memory allocation for the column group.doubleget(int r, int c)Get the value at a global row/column position.int[]getColIndices()Obtain the offsets of the columns in the matrix block that make up the groupabstract AColGroup.CompressionTypegetCompType()Obtain the compression type.abstract doublegetCost(ComputationCostEstimator e, int nRows)Get the computation cost associated with this column group.longgetExactSizeOnDisk()Returns the exact serialized size of column group.abstract doublegetIdx(int r, int colIdx)Get the value at a colGroup specific row/column index position.abstract doublegetMax()Short hand method for getting maximum value contained in this column group.abstract doublegetMin()Short hand method for getting minimum value contained in this column group.abstract longgetNumberNonZeros(int nRows)Get the number of nonZeros contained in this column group.intgetNumCols()Obtain the number of columns in this column group.abstract intgetNumValues()Obtain number of distinct tuples in contained sets of values associated with this column group.abstract voidleftMultByAColGroup(AColGroup lhs, MatrixBlock result)Left side matrix multiplication with a column group that is transposed.abstract voidleftMultByMatrixNoPreAgg(MatrixBlock matrix, MatrixBlock result, int rl, int ru, int cl, int cu)Left multiply with this column group.voidreadFields(DataInput in)Deserialize column group from data input.abstract AColGroupreplace(double pattern, double replace)Make a copy of the column group values, and replace all values that match pattern with replacement value.abstract AColGrouprexpandCols(int max, boolean ignore, boolean cast, int nRows)Expand the column group to multiple columns.abstract AColGrouprightMultByMatrix(MatrixBlock right)Right matrix multiplication with this column group.abstract AColGroupscalarOperation(ScalarOperator op)Perform the specified scalar operation directly on the compressed column group, without decompressing individual cells if possible.voidshiftColIndices(int offset)Shift all column indexes contained by an offset.AColGroupsliceColumn(int col)Slice out a single column from the column group.AColGroupsliceColumns(int cl, int cu)Slice out the columns within the range of cl and cu to remove the dictionary values related to these columns.StringtoString()abstract voidtsmm(MatrixBlock ret, int nRows)Do a transposed self matrix multiplication on the left side t(x) %*% x.abstract voidtsmmAColGroup(AColGroup other, MatrixBlock result)Matrix multiply with this other column group, but: 1.abstract voidunaryAggregateOperations(AggregateUnaryOperator op, double[] c, int nRows, int rl, int ru)Unary Aggregate operator, since aggregate operators require new object output, the output becomes an uncompressed matrix.abstract AColGroupunaryOperation(UnaryOperator op)voidwrite(DataOutput out)Serializes column group to data output.
 
- 
- 
- 
Method Detail- 
getColIndicespublic final int[] getColIndices() Obtain the offsets of the columns in the matrix block that make up the group- Returns:
- offsets of the columns in the matrix block that make up the group
 
 - 
getNumColspublic final int getNumCols() Obtain the number of columns in this column group.- Returns:
- number of columns in this column group
 
 - 
shiftColIndicespublic final void shiftColIndices(int offset) Shift all column indexes contained by an offset. This is used for rbind to combine compressed matrices. Since column indexes are reused between operations, we allocate a new list here to be safe- Parameters:
- offset- The offset to move all columns
 
 - 
estimateInMemorySizepublic long estimateInMemorySize() Get the upper bound estimate of in memory allocation for the column group.- Returns:
- an upper bound on the number of bytes used to store this ColGroup in memory.
 
 - 
decompressToSparseBlockpublic final void decompressToSparseBlock(SparseBlock sb, int rl, int ru) Decompress a range of rows into a sparse block Note that this is using append, so the sparse column indexes need to be sorted afterwards.- Parameters:
- sb- Sparse Target block
- rl- Row to start at
- ru- Row to end at
 
 - 
decompressToDenseBlockpublic final void decompressToDenseBlock(DenseBlock db, int rl, int ru) Decompress a range of rows into a dense block- Parameters:
- db- Sparse Target block
- rl- Row to start at
- ru- Row to end at
 
 - 
writepublic void write(DataOutput out) throws IOException Serializes column group to data output.- Parameters:
- out- data output
- Throws:
- IOException- if IOException occurs
 
 - 
readFieldspublic void readFields(DataInput in) throws IOException Deserialize column group from data input.- Parameters:
- in- data input
- Throws:
- IOException- if IOException occurs
 
 - 
getExactSizeOnDiskpublic long getExactSizeOnDisk() Returns the exact serialized size of column group. This can be used for example for buffer preallocation.- Returns:
- exact serialized size for column group
 
 - 
sliceColumnspublic final AColGroup sliceColumns(int cl, int cu) Slice out the columns within the range of cl and cu to remove the dictionary values related to these columns. If the ColGroup slicing from does not contain any columns within the range null is returned.- Parameters:
- cl- The lower bound of the columns to select
- cu- The upper bound of the columns to select (not inclusive).
- Returns:
- A cloned Column Group, with a copied pointer to the old column groups index structure, but reduced dictionary and _columnIndexes correctly aligned with the expected sliced compressed matrix.
 
 - 
sliceColumnpublic final AColGroup sliceColumn(int col) Slice out a single column from the column group.- Parameters:
- col- The column to slice, the column could potentially not be inside the column group
- Returns:
- A new column group that is a single column, if the column requested is not in this column group null is returned.
 
 - 
colSumpublic static double[] colSum(List<AColGroup> groups, double[] res, int nRows) Compute the column sum of the given list of groups- Parameters:
- groups- The Groups to sum
- res- The result to put the values into
- nRows- The number of rows in the groups
- Returns:
- The given res list, where the sum of the column groups is added
 
 - 
getpublic double get(int r, int c)Get the value at a global row/column position. In general this performs since a binary search of colIndexes is performed for each lookup.- Parameters:
- r- row
- c- column
- Returns:
- value at the row/column position
 
 - 
getIdxpublic abstract double getIdx(int r, int colIdx)Get the value at a colGroup specific row/column index position.- Parameters:
- r- row
- colIdx- column index in the _colIndexes.
- Returns:
- value at the row/column index position
 
 - 
getNumValuespublic abstract int getNumValues() 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.- Returns:
- the number of distinct sets of values associated with the bitmaps in this column group
 
 - 
getCompTypepublic abstract AColGroup.CompressionType getCompType() Obtain the compression type.- Returns:
- How the elements of the column group are compressed.
 
 - 
decompressToDenseBlockpublic abstract void decompressToDenseBlock(DenseBlock db, int rl, int ru, int offR, int offC) Decompress into the DenseBlock. (no NNZ handling)- Parameters:
- db- Target DenseBlock
- rl- Row to start decompression from
- ru- Row to end decompression at
- offR- Row offset into the target to decompress
- offC- Column offset into the target to decompress
 
 - 
decompressToSparseBlockpublic abstract void decompressToSparseBlock(SparseBlock sb, int rl, int ru, int offR, int offC) Decompress into the SparseBlock. (no NNZ handling) Note this method is allowing to calls to append since it is assumed that the sparse column indexes are sorted afterwards- Parameters:
- sb- Target SparseBlock
- rl- Row to start decompression from
- ru- Row to end decompression at
- offR- Row offset into the target to decompress
- offC- Column offset into the target to decompress
 
 - 
rightMultByMatrixpublic abstract AColGroup rightMultByMatrix(MatrixBlock right) Right matrix multiplication with this column group. This method can return null, meaning that the output overlapping group would have been empty.- Parameters:
- right- The MatrixBlock on the right of this matrix multiplication
- Returns:
- The new Column Group or null that is the result of the matrix multiplication.
 
 - 
tsmmpublic abstract void tsmm(MatrixBlock ret, int nRows) 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- Parameters:
- ret- The return matrix block [numColumns x numColumns]
- nRows- The number of rows in the column group
 
 - 
leftMultByMatrixNoPreAggpublic abstract void leftMultByMatrixNoPreAgg(MatrixBlock matrix, MatrixBlock result, int rl, int ru, int cl, int cu) Left multiply with this column group.- 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
- cl- The column to begin the multiplication from on the lhs matrix
- cu- The column to end the multiplication at on the lhs matrix
 
 - 
leftMultByAColGrouppublic abstract void leftMultByAColGroup(AColGroup lhs, MatrixBlock result) Left side matrix multiplication with a column group that is transposed.- 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
 
 - 
tsmmAColGrouppublic abstract void tsmmAColGroup(AColGroup other, MatrixBlock result) 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. It should be guaranteed that the input is not the same as the caller of the method. The second step is achievable by treating the initial multiplied matrix, and adding its values to the correct locations in the output.- Parameters:
- other- The other Column group to multiply with
- result- The result matrix to put the results into
 
 - 
scalarOperationpublic abstract AColGroup scalarOperation(ScalarOperator op) Perform the specified scalar operation directly on the compressed column group, without decompressing individual cells if possible.- Parameters:
- op- operation to perform
- Returns:
- version of this column group with the operation applied
 
 - 
binaryRowOpLeftpublic abstract AColGroup binaryRowOpLeft(BinaryOperator op, double[] v, boolean isRowSafe) Perform a binary row operation.- Parameters:
- op- The operation to execute
- v- The vector of values to apply, should be same length as dictionary length.
- isRowSafe- True if the binary op is applied to an entire zero row and all results are zero
- Returns:
- A updated column group with the new values.
 
 - 
binaryRowOpRightpublic abstract AColGroup binaryRowOpRight(BinaryOperator op, double[] v, boolean isRowSafe) Perform a binary row operation.- Parameters:
- op- The operation to execute
- v- The vector of values to apply, should be same length as dictionary length.
- isRowSafe- True if the binary op is applied to an entire zero row and all results are zero
- Returns:
- A updated column group with the new values.
 
 - 
unaryAggregateOperationspublic abstract void unaryAggregateOperations(AggregateUnaryOperator op, double[] c, int nRows, int rl, int ru) Unary Aggregate operator, since aggregate operators require new object output, the output becomes an uncompressed matrix.- Parameters:
- op- The operator used
- c- The output matrix block
- nRows- The total number of rows in the Column Group
- rl- The Starting Row to do aggregation from
- ru- The last Row to do aggregation to (not included)
 
 - 
getMinpublic abstract double getMin() Short hand method for getting minimum value contained in this column group.- Returns:
- The minimum value contained in this ColumnGroup
 
 - 
getMaxpublic abstract double getMax() Short hand method for getting maximum value contained in this column group.- Returns:
- The maximum value contained in this ColumnGroup
 
 - 
copypublic abstract AColGroup copy() Get a copy of this column group note this is only a shallow copy. Meaning only the object wrapping index structures, column indexes and dictionaries are copied.- Returns:
- Get a copy of this column group.
 
 - 
containsValuepublic abstract boolean containsValue(double pattern) Detect if the column group contains a specific value.- Parameters:
- pattern- The value to look for.
- Returns:
- boolean saying true if the value is contained.
 
 - 
getNumberNonZerospublic abstract long getNumberNonZeros(int nRows) Get the number of nonZeros contained in this column group.- 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.
 
 - 
replacepublic abstract AColGroup replace(double pattern, double replace) Make a copy of the column group values, and replace all values that match pattern with replacement value.- 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.
 
 - 
computeColSumspublic abstract void computeColSums(double[] c, int nRows)Compute the column sum- Parameters:
- c- The array to add the column sum to.
- nRows- The number of rows in the column group.
 
 - 
centralMomentpublic abstract CM_COV_Object centralMoment(CMOperator op, int nRows) Central Moment instruction executed on a column group.- Parameters:
- op- The Operator to use.
- nRows- The number of rows contained in the ColumnGroup.
- Returns:
- A Central Moment object.
 
 - 
rexpandColspublic abstract AColGroup rexpandCols(int max, boolean ignore, boolean cast, int nRows) Expand the column group to multiple columns. (one hot encode the column group)- Parameters:
- max- The number of columns to expand to and cutoff values at.
- ignore- If zero and negative values should be ignored.
- cast- If the double values contained should be cast to whole numbers.
- nRows- The number of rows in the column group.
- Returns:
- A new column group containing max number of columns.
 
 - 
getCostpublic abstract double getCost(ComputationCostEstimator e, int nRows) Get the computation cost associated with this column group.- Parameters:
- e- The computation cost estimator
- nRows- the number of rows in the column group
- Returns:
- The cost of this column group
 
 - 
unaryOperationpublic abstract AColGroup unaryOperation(UnaryOperator op) 
 
- 
 
-