Class IdentityDictionarySlice
- java.lang.Object
-
- org.apache.sysds.runtime.compress.colgroup.dictionary.ADictionary
-
- org.apache.sysds.runtime.compress.colgroup.dictionary.ACachingMBDictionary
-
- org.apache.sysds.runtime.compress.colgroup.dictionary.AIdentityDictionary
-
- org.apache.sysds.runtime.compress.colgroup.dictionary.IdentityDictionarySlice
-
- All Implemented Interfaces:
Serializable,IDictionary
public class IdentityDictionarySlice extends AIdentityDictionary
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.sysds.runtime.compress.colgroup.dictionary.IDictionary
IDictionary.DictType
-
-
Field Summary
-
Fields inherited from interface org.apache.sysds.runtime.compress.colgroup.dictionary.IDictionary
LOG
-
-
Constructor Summary
Constructors Constructor Description IdentityDictionarySlice(int nRowCol, boolean withEmpty, int l, int u)Create a Identity matrix dictionary slice.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToEntry(double[] v, int fr, int to, int nCol, int rep)Adds the dictionary entry from this dictionary to the v dictionary rep times.voidaggregateCols(double[] c, Builtin fn, IColIndex colIndexes)Aggregates the columns into the target double array provided.double[]aggregateRows(Builtin fn, int nCol)Aggregate all entries in the rows.IDictionaryclone()Returns a deep clone of the dictionary.voidcolSum(double[] c, int[] counts, IColIndex colIndexes)Get the column sum of the values contained in the dictionarystatic IDictionarycreate(int nRowCol, boolean withEmpty, int l, int u)Create a Identity matrix dictionary slice (if other groups are not more applicable).MatrixBlockDictionarycreateMBDict(int nCol)booleanequals(IDictionary o)Indicate if the other dictionary is equal to this.IDictionary.DictTypegetDictType()Get the dictionary type this dictionary is.longgetExactSizeOnDisk()Calculate the space consumption if the dictionary is stored on disk.longgetInMemorySize()Returns the memory usage of the dictionary.static longgetInMemorySize(int numberColumns)MatrixBlockDictionarygetMBDict()longgetNumberNonZeros(int[] counts, int nCol)Calculate the number of non zeros in the dictionary.intgetNumberOfColumns(int nrow)Get the number of columns in this dictionary, provided you know the number of values, or rows.intgetNumberOfValues(int ncol)Get the number of distinct tuples given that the column group has n columnsdoublegetSparsity()Get the sparsity of the dictionary.StringgetString(int colIndexes)Get a string representation of the dictionary, that considers the layout of the data.doublegetValue(int i)Get Specific value contained in the dictionary at index.doublegetValue(int r, int c, int nCol)Get Specific value contain in dictionary at index.double[]getValues()Get all the values contained in the dictionary as a linearized double array.double[]productAllRowsToDouble(int nCol)Method to product all rows to a column vector.double[]productAllRowsToDoubleWithDefault(double[] defaultTuple)Method to product all rows to a column vector with a default value added in the end.static IdentityDictionarySliceread(DataInput in)doublesum(int[] counts, int ncol)Get the sum of the values contained in the dictionarydouble[]sumAllRowsToDouble(int nrColumns)Method used as a pre-aggregate of each tuple in the dictionary, to single double values.double[]sumAllRowsToDoubleSq(int nrColumns)Method used as a pre-aggregate of each tuple in the dictionary, to single double values.double[]sumAllRowsToDoubleWithDefault(double[] defaultTuple)Do exactly the same as the sumAllRowsToDouble but also sum the array given to a extra index in the end of the array.double[]sumAllRowsToDoubleWithReference(double[] reference)Method used as a pre-aggregate of each tuple in the dictionary, to single double values with a reference.doublesumSq(int[] counts, int ncol)Get the square sum of the values contained in the dictionaryStringtoString()voidwrite(DataOutput out)Write the dictionary to a DataOutput.-
Methods inherited from class org.apache.sysds.runtime.compress.colgroup.dictionary.AIdentityDictionary
containsValue, withEmpty
-
Methods inherited from class org.apache.sysds.runtime.compress.colgroup.dictionary.ACachingMBDictionary
getMBDict
-
Methods inherited from class org.apache.sysds.runtime.compress.colgroup.dictionary.ADictionary
addToEntry, addToEntryVectorized, aggregate, aggregateColsWithReference, aggregateRowsWithDefault, aggregateRowsWithReference, aggregateWithReference, append, applyScalarOp, applyScalarOpAndAppend, applyScalarOpWithReference, applyUnaryOp, applyUnaryOpAndAppend, applyUnaryOpWithReference, binOpLeft, binOpLeftAndAppend, binOpLeftWithReference, binOpRight, binOpRight, binOpRightAndAppend, binOpRightWithReference, cbind, centralMoment, centralMoment, centralMomentWithDefault, centralMomentWithDefault, centralMomentWithReference, centralMomentWithReference, colProduct, colProductWithReference, colSumSq, colSumSqWithReference, containsValueWithReference, correctNan, countNNZZeroColumns, equals, equals, getNumberNonZerosWithReference, getRow, MMDict, MMDictDense, MMDictScaling, MMDictScalingDense, MMDictScalingSparse, MMDictSparse, multiplyScalar, preaggValuesFromDense, product, productAllRowsToDoubleWithReference, productWithDefault, productWithReference, putDense, putSparse, reorder, replace, replaceWithReference, rexpandCols, rexpandColsWithReference, rightMMPreAggSparse, scaleTuples, sliceOutColumnRange, subtractTuple, sumAllRowsToDoubleSqWithDefault, sumAllRowsToDoubleSqWithReference, sumSqWithReference, TSMMToUpperTriangle, TSMMToUpperTriangleDense, TSMMToUpperTriangleDenseScaling, TSMMToUpperTriangleScaling, TSMMToUpperTriangleSparse, TSMMToUpperTriangleSparseScaling, TSMMWithScaling
-
-
-
-
Constructor Detail
-
IdentityDictionarySlice
public IdentityDictionarySlice(int nRowCol, boolean withEmpty, int l, int u)Create a Identity matrix dictionary slice. It behaves as if allocated a Sparse Matrix block but exploits that the structure is known to have certain properties.- Parameters:
nRowCol- the number of rows and columns in this identity matrix.withEmpty- If the matrix should contain an empty row in the end.l- the index lower to start atu- the index upper to end at (not inclusive)
-
-
Method Detail
-
create
public static IDictionary create(int nRowCol, boolean withEmpty, int l, int u)
Create a Identity matrix dictionary slice (if other groups are not more applicable). It behaves as if allocated a Sparse Matrix block but exploits that the structure is known to have certain properties.- Parameters:
nRowCol- the number of rows and columns in this identity matrix.withEmpty- If the matrix should contain an empty row in the end.l- the index lower to start atu- the index upper to end at (not inclusive)- Returns:
- a Dictionary instance.
-
getValues
public double[] getValues()
Description copied from interface:IDictionaryGet all the values contained in the dictionary as a linearized double array.- Specified by:
getValuesin interfaceIDictionary- Overrides:
getValuesin classADictionary- Returns:
- linearized double array
-
getValue
public double getValue(int i)
Description copied from interface:IDictionaryGet Specific value contained in the dictionary at index.- Specified by:
getValuein interfaceIDictionary- Overrides:
getValuein classADictionary- Parameters:
i- The index to extract the value from- Returns:
- The value contained at the index
-
getValue
public final double getValue(int r, int c, int nCol)Description copied from interface:IDictionaryGet Specific value contain in dictionary at index.- Specified by:
getValuein interfaceIDictionary- Overrides:
getValuein classADictionary- Parameters:
r- Row targetc- Col targetnCol- nCol in dictionary- Returns:
- value
-
getInMemorySize
public long getInMemorySize()
Description copied from interface:IDictionaryReturns the memory usage of the dictionary.- Returns:
- a long value in number of bytes for the dictionary.
-
getInMemorySize
public static long getInMemorySize(int numberColumns)
-
aggregateRows
public double[] aggregateRows(Builtin fn, int nCol)
Description copied from interface:IDictionaryAggregate all entries in the rows.- Specified by:
aggregateRowsin interfaceIDictionary- Overrides:
aggregateRowsin classADictionary- Parameters:
fn- The aggregate functionnCol- The number of columns contained in the dictionary.- Returns:
- Aggregates for this dictionary tuples.
-
aggregateCols
public void aggregateCols(double[] c, Builtin fn, IColIndex colIndexes)Description copied from interface:IDictionaryAggregates the columns into the target double array provided.- Specified by:
aggregateColsin interfaceIDictionary- Overrides:
aggregateColsin classADictionary- Parameters:
c- The target double array, this contains the full number of columns, therefore the colIndexes for this specific dictionary is needed.fn- The function to apply to individual columnscolIndexes- The mapping to the target columns from the individual columns
-
clone
public IDictionary clone()
Description copied from interface:IDictionaryReturns a deep clone of the dictionary.- Specified by:
clonein interfaceIDictionary- Specified by:
clonein classADictionary- Returns:
- A deep clone
-
getDictType
public IDictionary.DictType getDictType()
Description copied from interface:IDictionaryGet the dictionary type this dictionary is.- Returns:
- The Dictionary type this is.
-
sumAllRowsToDouble
public double[] sumAllRowsToDouble(int nrColumns)
Description copied from interface:IDictionaryMethod used as a pre-aggregate of each tuple in the dictionary, to single double values. Note if the number of columns is one the actual dictionaries values are simply returned.- Specified by:
sumAllRowsToDoublein interfaceIDictionary- Overrides:
sumAllRowsToDoublein classADictionary- Parameters:
nrColumns- The number of columns in the ColGroup to know how to get the values from the dictionary.- Returns:
- a double array containing the row sums from this dictionary.
-
sumAllRowsToDoubleWithDefault
public double[] sumAllRowsToDoubleWithDefault(double[] defaultTuple)
Description copied from interface:IDictionaryDo exactly the same as the sumAllRowsToDouble but also sum the array given to a extra index in the end of the array.- Specified by:
sumAllRowsToDoubleWithDefaultin interfaceIDictionary- Overrides:
sumAllRowsToDoubleWithDefaultin classADictionary- Parameters:
defaultTuple- The default row to sum in the end index returned.- Returns:
- a double array containing the row sums from this dictionary.
-
sumAllRowsToDoubleWithReference
public double[] sumAllRowsToDoubleWithReference(double[] reference)
Description copied from interface:IDictionaryMethod used as a pre-aggregate of each tuple in the dictionary, to single double values with a reference.- Specified by:
sumAllRowsToDoubleWithReferencein interfaceIDictionary- Overrides:
sumAllRowsToDoubleWithReferencein classADictionary- Parameters:
reference- The reference values to add to each cell.- Returns:
- a double array containing the row sums from this dictionary.
-
sumAllRowsToDoubleSq
public double[] sumAllRowsToDoubleSq(int nrColumns)
Description copied from interface:IDictionaryMethod used as a pre-aggregate of each tuple in the dictionary, to single double values. Note if the number of columns is one the actual dictionaries values are simply returned.- Specified by:
sumAllRowsToDoubleSqin interfaceIDictionary- Overrides:
sumAllRowsToDoubleSqin classADictionary- Parameters:
nrColumns- The number of columns in the ColGroup to know how to get the values from the dictionary.- Returns:
- a double array containing the row sums from this dictionary.
-
productAllRowsToDouble
public double[] productAllRowsToDouble(int nCol)
Description copied from interface:IDictionaryMethod to product all rows to a column vector.- Specified by:
productAllRowsToDoublein interfaceIDictionary- Overrides:
productAllRowsToDoublein classAIdentityDictionary- Parameters:
nCol- The number of columns in the ColGroup to know how to get the values from the dictionary.- Returns:
- A row product
-
productAllRowsToDoubleWithDefault
public double[] productAllRowsToDoubleWithDefault(double[] defaultTuple)
Description copied from interface:IDictionaryMethod to product all rows to a column vector with a default value added in the end.- Specified by:
productAllRowsToDoubleWithDefaultin interfaceIDictionary- Overrides:
productAllRowsToDoubleWithDefaultin classAIdentityDictionary- Parameters:
defaultTuple- The default row that aggregate to last cell- Returns:
- A row product
-
colSum
public void colSum(double[] c, int[] counts, IColIndex colIndexes)Description copied from interface:IDictionaryGet the column sum of the values contained in the dictionary- Specified by:
colSumin interfaceIDictionary- Overrides:
colSumin classADictionary- Parameters:
c- The output array allocated to contain all column groups output.counts- The counts of the individual tuples.colIndexes- The columns indexes of the parent column group, this indicate where to put the column sum into the c output.
-
sum
public double sum(int[] counts, int ncol)Description copied from interface:IDictionaryGet the sum of the values contained in the dictionary- Specified by:
sumin interfaceIDictionary- Overrides:
sumin classADictionary- Parameters:
counts- The counts of the individual tuplesncol- The number of columns contained- Returns:
- The sum scaled by the counts provided.
-
sumSq
public double sumSq(int[] counts, int ncol)Description copied from interface:IDictionaryGet the square sum of the values contained in the dictionary- Specified by:
sumSqin interfaceIDictionary- Overrides:
sumSqin classADictionary- Parameters:
counts- The counts of the individual tuplesncol- The number of columns contained- Returns:
- The square sum scaled by the counts provided.
-
getNumberNonZeros
public long getNumberNonZeros(int[] counts, int nCol)Description copied from interface:IDictionaryCalculate the number of non zeros in the dictionary. The number of non zeros should be scaled with the counts given. This gives the exact number of non zero values in the parent column group.- Parameters:
counts- The counts of each dictionary entrynCol- The number of columns in this dictionary- Returns:
- The nonZero count
-
getNumberOfValues
public int getNumberOfValues(int ncol)
Description copied from interface:IDictionaryGet the number of distinct tuples given that the column group has n columns- Parameters:
ncol- The number of Columns in the ColumnGroup.- Returns:
- the number of value tuples contained in the dictionary.
-
getNumberOfColumns
public int getNumberOfColumns(int nrow)
Description copied from interface:IDictionaryGet the number of columns in this dictionary, provided you know the number of values, or rows.- Parameters:
nrow- The number of rows/values known inside this dictionary- Returns:
- The number of columns
-
write
public void write(DataOutput out) throws IOException
Description copied from interface:IDictionaryWrite the dictionary to a DataOutput.- Parameters:
out- the output sink to write the dictionary to.- Throws:
IOException- if the sink fails.
-
read
public static IdentityDictionarySlice read(DataInput in) throws IOException
- Throws:
IOException
-
getExactSizeOnDisk
public long getExactSizeOnDisk()
Description copied from interface:IDictionaryCalculate the space consumption if the dictionary is stored on disk.- Returns:
- the long count of bytes to store the dictionary.
-
getSparsity
public double getSparsity()
Description copied from interface:IDictionaryGet the sparsity of the dictionary.- Specified by:
getSparsityin interfaceIDictionary- Overrides:
getSparsityin classADictionary- Returns:
- a sparsity between 0 and 1
-
addToEntry
public void addToEntry(double[] v, int fr, int to, int nCol, int rep)Description copied from interface:IDictionaryAdds the dictionary entry from this dictionary to the v dictionary rep times.- Specified by:
addToEntryin interfaceIDictionary- Overrides:
addToEntryin classADictionary- Parameters:
v- The target dictionary (dense double array)fr- The from index is the tuple index to copy from.to- The to index is the row index to copy into.nCol- The number of columns in both casesrep- The number of repetitions to apply (simply multiply do not loop)
-
equals
public boolean equals(IDictionary o)
Description copied from interface:IDictionaryIndicate if the other dictionary is equal to this.- Parameters:
o- The other object- Returns:
- If it is equal
-
getMBDict
public MatrixBlockDictionary getMBDict()
- Overrides:
getMBDictin classADictionary
-
createMBDict
public MatrixBlockDictionary createMBDict(int nCol)
- Specified by:
createMBDictin classACachingMBDictionary
-
getString
public String getString(int colIndexes)
Description copied from interface:IDictionaryGet a string representation of the dictionary, that considers the layout of the data.- Parameters:
colIndexes- The number of columns in the dictionary.- Returns:
- A string that is nicer to print.
-
-