Class AMapToData
- java.lang.Object
-
- org.apache.sysds.runtime.compress.colgroup.mapping.AMapToData
-
- All Implemented Interfaces:
Serializable
public abstract class AMapToData extends Object implements Serializable
This Class's job is to link into the dictionary entries for column groups. Column groups - DDC use this to map to map directly to the dictionary - SDC use this in collaboration with the offsets to only point to dictionary entries for non default values.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract AMapToData
append(AMapToData t)
abstract AMapToData
appendN(AMapToDataGroup[] d)
void
copy(AMapToData d)
Copy the values in this map into another mapping object.abstract void
copyBit(BitSet d)
abstract void
copyInt(int[] d)
abstract int
countRuns()
Count the number of runs inside the map.int
countRuns(AOffset off)
Count the number of runs inside the map, but sparse with offsets.abstract void
fill(int v)
Fill the map with a given value.int[]
getCounts()
Get the number of counts of each unique value contained in this map.abstract int[]
getCounts(int[] counts)
Get the number of counts of each unique value contained in this map.abstract long
getExactSizeOnDisk()
Get the size of this Mapping object on disk.abstract int
getIndex(int n)
Get the given index back as a integerabstract long
getInMemorySize()
Get the in memory size of this Mapping object.int
getMax()
abstract MapToFactory.MAP_TYPE
getType()
int
getUnique()
Get the number of unique values inside this map.abstract int
getUpperBoundValue()
Get the maximum value that is possible to allocate inside this map.void
preAggregateDDC_DDC(AMapToData tm, ADictionary td, Dictionary ret, int nCol)
PreAggregate into dictionary with two sides of DDC.void
preAggregateDDC_RLE(int[] ptr, char[] data, ADictionary td, Dictionary ret, int nCol)
void
preAggregateDDC_SDCZ(AMapToData tm, ADictionary td, AOffset tof, Dictionary ret, int nCol)
PreAggregate into SDCZero dictionary from DDC dictionary.void
preAggregateDDC_SDCZMultiCol(AMapToData tm, ADictionary td, AOffset tof, double[] v, int nCol)
void
preAggregateDDC_SDCZSingleCol(AMapToData tm, double[] td, AOffset tof, double[] v)
void
preAggregateDense(MatrixBlock m, double[] preAV, int rl, int ru, int cl, int cu)
Pre aggregate a dense matrix m into pre, subject to only including a row segment and column segment.void
preAggregateDense(MatrixBlock m, double[] preAV, int rl, int ru, int cl, int cu, AOffset indexes)
PreAggregate a Dense Matrix at index offsets.void
preAggregateRLE_DDC(int[] ptr, char[] data, ADictionary td, Dictionary ret, int nCol)
void
preAggregateSDCZ_DDC(AMapToData tm, ADictionary td, AOffset of, Dictionary ret, int nCol)
PreAggregate into DDC dictionary from SDCZero dictionary.void
preAggregateSDCZ_SDCZ(AMapToData tm, ADictionary td, AOffset tof, AOffset of, Dictionary ret, int nCol)
void
preAggregateSparse(SparseBlock sb, double[] preAV, int rl, int ru)
PreAggregate the sparseblock in the range of rows given.void
preAggregateSparse(SparseBlock sb, double[] preAV, int rl, int ru, AOffset indexes)
PreAggregate the SparseBlock in the range of rows given.abstract void
replace(int v, int r)
Replace v with r for all entries, NOTE! It is assumed that you call this correctly: - with two distinct values that is representable inside the given AMapToData.abstract AMapToData
resize(int unique)
abstract void
set(int n, int v)
Set the index to the value.abstract int
setAndGet(int n, int v)
Set the index to the value and get the contained value after.void
setUnique(int nUnique)
Set number of unique values.abstract int
size()
The size of the Mapping object, signaling how many value cells are stored in this mapping object.abstract AMapToData
slice(int l, int u)
Slice out the range from lower to upper from this map toData.String
toString()
abstract void
write(DataOutput out)
Serialize this object to the DataOutput given.
-
-
-
Method Detail
-
getUnique
public final int getUnique()
Get the number of unique values inside this map.- Returns:
- the unique count.
-
setUnique
public final void setUnique(int nUnique)
Set number of unique values. NOTE! The value should be representable inside the map. This requirement is not checked.- Parameters:
nUnique
- the value to set.
-
getIndex
public abstract int getIndex(int n)
Get the given index back as a integer- Parameters:
n
- the index to get- Returns:
- the value represented in that cell as integer
-
set
public abstract void set(int n, int v)
Set the index to the value. NOTE! The value should be representable inside the map. This requirement is not checked.- Parameters:
n
- index to set.v
- the value to set it to.
-
setAndGet
public abstract int setAndGet(int n, int v)
Set the index to the value and get the contained value after.- Parameters:
n
- index to set.v
- the value to set it to.- Returns:
- v as encoded, note this value can be different that the one put in if the map is not able to represent the value
-
fill
public abstract void fill(int v)
Fill the map with a given value. NOTE! The value should be representable inside the map. This requirement is not checked.- Parameters:
v
- the value to fill
-
getUpperBoundValue
public abstract int getUpperBoundValue()
Get the maximum value that is possible to allocate inside this map.- Returns:
- The maximum value.
-
getInMemorySize
public abstract long getInMemorySize()
Get the in memory size of this Mapping object.- Returns:
- The size in Bytes.
-
getExactSizeOnDisk
public abstract long getExactSizeOnDisk()
Get the size of this Mapping object on disk.- Returns:
- The on disk size in Bytes.
-
size
public abstract int size()
The size of the Mapping object, signaling how many value cells are stored in this mapping object.- Returns:
- The length of the mapping object.
-
write
public abstract void write(DataOutput out) throws IOException
Serialize this object to the DataOutput given.- Parameters:
out
- The object to serialize this object into.- Throws:
IOException
- An IO exception if the Serialization fails.
-
replace
public abstract void replace(int v, int r)
Replace v with r for all entries, NOTE! It is assumed that you call this correctly: - with two distinct values that is representable inside the given AMapToData.- Parameters:
v
- The value to replacer
- The value to put instead
-
getType
public abstract MapToFactory.MAP_TYPE getType()
-
preAggregateDense
public final void preAggregateDense(MatrixBlock m, double[] preAV, int rl, int ru, int cl, int cu)
Pre aggregate a dense matrix m into pre, subject to only including a row segment and column segment.- Parameters:
m
- The dense matrix values to preaggregatepreAV
- The preAggregate double array populate with the summed values of mrl
- The row start in mru
- The row end in mcl
- The column start in mcu
- The column end in m
-
preAggregateDense
public final void preAggregateDense(MatrixBlock m, double[] preAV, int rl, int ru, int cl, int cu, AOffset indexes)
PreAggregate a Dense Matrix at index offsets.- Parameters:
m
- The DenseBlock to preAggregatepreAV
- The target double array to put the preAggregate intorl
- The row to start atru
- The row to end at (not inclusive)cl
- The column in m to start fromcu
- The column in m to end at (not inclusive)indexes
- The Offset Indexes to iterate through
-
preAggregateSparse
public final void preAggregateSparse(SparseBlock sb, double[] preAV, int rl, int ru, AOffset indexes)
PreAggregate the SparseBlock in the range of rows given.- Parameters:
sb
- The SparseBlock to preAggregatepreAV
- The target double array to put the preAggregate intorl
- The row to start atru
- The row to end at (not inclusive)indexes
- The Offset Indexes to iterate through
-
preAggregateSparse
public final void preAggregateSparse(SparseBlock sb, double[] preAV, int rl, int ru)
PreAggregate the sparseblock in the range of rows given.- Parameters:
sb
- Sparse block to preAggregate frompreAV
- Pre aggregate targetrl
- row index in sbru
- upper row index in sp (not inclusive)
-
getCounts
public final int[] getCounts()
Get the number of counts of each unique value contained in this map. Note that in the case the mapping is shorter than number of rows the counts sum to the number of mapped values not the number of rows.- Returns:
- The counts
-
getCounts
public abstract int[] getCounts(int[] counts)
Get the number of counts of each unique value contained in this map. Note that in the case the mapping is shorter than number of rows the counts sum to the number of mapped values not the number of rows.- Parameters:
counts
- The object to return.- Returns:
- The counts
-
preAggregateDDC_DDC
public final void preAggregateDDC_DDC(AMapToData tm, ADictionary td, Dictionary ret, int nCol)
PreAggregate into dictionary with two sides of DDC.- Parameters:
tm
- Map of other sidetd
- Dictionary to take values from (other side dictionary)ret
- The output dictionary to aggregate intonCol
- The number of columns
-
preAggregateDDC_SDCZ
public final void preAggregateDDC_SDCZ(AMapToData tm, ADictionary td, AOffset tof, Dictionary ret, int nCol)
PreAggregate into SDCZero dictionary from DDC dictionary.- Parameters:
tm
- Map of other sidetd
- Dictionary to take values from (other side dictionary)tof
- The offset index structure of the SDC sideret
- The output dictionary to aggregate intonCol
- The number of columns in output and td dictionary
-
preAggregateDDC_SDCZSingleCol
public void preAggregateDDC_SDCZSingleCol(AMapToData tm, double[] td, AOffset tof, double[] v)
-
preAggregateDDC_SDCZMultiCol
public void preAggregateDDC_SDCZMultiCol(AMapToData tm, ADictionary td, AOffset tof, double[] v, int nCol)
-
preAggregateSDCZ_DDC
public final void preAggregateSDCZ_DDC(AMapToData tm, ADictionary td, AOffset of, Dictionary ret, int nCol)
PreAggregate into DDC dictionary from SDCZero dictionary.- Parameters:
tm
- Map of other sidetd
- Dictionary to take values from (other side dictionary)of
- Offsets of the SDC to look into DDCret
- The output dictionary to aggregate intonCol
- The number of columns in output and td dictionary
-
preAggregateSDCZ_SDCZ
public final void preAggregateSDCZ_SDCZ(AMapToData tm, ADictionary td, AOffset tof, AOffset of, Dictionary ret, int nCol)
-
preAggregateRLE_DDC
public void preAggregateRLE_DDC(int[] ptr, char[] data, ADictionary td, Dictionary ret, int nCol)
-
preAggregateDDC_RLE
public void preAggregateDDC_RLE(int[] ptr, char[] data, ADictionary td, Dictionary ret, int nCol)
-
copy
public void copy(AMapToData d)
Copy the values in this map into another mapping object. NOTE! All contained vales should be representable inside the map given. This requirement is not checked.- Parameters:
d
- Map to copy all values into.
-
copyInt
public abstract void copyInt(int[] d)
-
copyBit
public abstract void copyBit(BitSet d)
-
getMax
public int getMax()
-
resize
public abstract AMapToData resize(int unique)
-
countRuns
public abstract int countRuns()
Count the number of runs inside the map.- Returns:
- The number of runs
-
countRuns
public int countRuns(AOffset off)
Count the number of runs inside the map, but sparse with offsets.- Parameters:
off
- The sparse offsets to consider counting the runs from.- Returns:
- count of runs.
-
slice
public abstract AMapToData slice(int l, int u)
Slice out the range from lower to upper from this map toData.- Parameters:
l
- Low value to slice fromu
- high value to slice to (not inclusive)- Returns:
- A new map containing only the values from the range.
-
append
public abstract AMapToData append(AMapToData t)
-
appendN
public abstract AMapToData appendN(AMapToDataGroup[] d)
-
-