Class MapToBit
- java.lang.Object
-
- org.apache.sysds.runtime.compress.colgroup.mapping.AMapToData
-
- org.apache.sysds.runtime.compress.colgroup.mapping.MapToBit
-
- All Implemented Interfaces:
Serializable
public class MapToBit extends AMapToData
A Bit map containing the values of the map inside a long array. By convention inside the indexes are from the right most bit. so for instance index 0 is the left most bit in the first long and index 63 is the leftmost bit in the first long. Similarly 64 is the right most bit in the second long. and so on.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MapToBit(int unique, int size)
A Bit map containing the values of the map inside a long array.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AMapToData
append(AMapToData t)
AMapToData
appendN(IMapToDataGroup[] d)
void
copy(AMapToData d)
Copy the values in this map into another mapping object.void
copyBit(BitSet d)
void
copyInt(int[] d)
int
countRuns()
Count the number of runs inside the map.boolean
equals(AMapToData e)
Indicate if the given encoding is equivalent to this encodingvoid
fill(int v)
Fill the map with a given value.int[]
getCounts(int[] ret)
Get the number of counts of each unique value contained in this map.long
getExactSizeOnDisk()
Get the size of this Mapping object on disk.int
getIndex(int n)
Get the given index back as a integerlong
getInMemorySize()
Get the in memory size of this Mapping object.static long
getInMemorySize(int dataLength)
int
getMaxPossible()
Get the maximum possible value to encode in this encoding.MapToFactory.MAP_TYPE
getType()
int
getUpperBoundValue()
Get the maximum value that is possible to allocate inside this map.boolean
isEmpty()
void
preAggregateDDC_DDCMultiCol(AMapToData tm, IDictionary td, double[] v, int nCol)
void
preAggregateDDC_DDCSingleCol(AMapToData tm, double[] td, double[] v)
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.AMapToData
resize(int unique)
void
set(int n, int v)
Set the index to the value.int
setAndGet(int n, int v)
Set the index to the value and get the contained value after.int
size()
The size of the Mapping object, signaling how many value cells are stored in this mapping object.AMapToData
slice(int l, int u)
Slice out the range from lower to upper from this map toData.String
toString()
void
write(DataOutput out)
Serialize this object to the DataOutput given.-
Methods inherited from class org.apache.sysds.runtime.compress.colgroup.mapping.AMapToData
countRuns, equals, getCounts, getMax, getUnique, preAggregateDDC_DDC, preAggregateDDC_RLE, preAggregateDDC_SDCZ, preAggregateDDC_SDCZMultiCol, preAggregateDDC_SDCZSingleCol, preAggregateDense, preAggregateDense, preAggregateRLE_DDC, preAggregateSDCZ_DDC, preAggregateSDCZ_SDCZ, preAggregateSparse, preAggregateSparse, set, set, setUnique, verify
-
-
-
-
Constructor Detail
-
MapToBit
public MapToBit(int unique, int size)
A Bit map containing the values of the map inside a long array. By convention inside the indexes are from the right most bit. so for instance index 0 is the left most bit in the first long and index 63 is the leftmost bit in the first long. Similarly 64 is the right most bit in the second long. and so on.- Parameters:
unique
- the number of unique values to encode ... is basically always 2 in this casesize
- The size to allocate, as in number of bits to enable encoding not the number of longs to allocate.
-
-
Method Detail
-
getType
public MapToFactory.MAP_TYPE getType()
- Specified by:
getType
in classAMapToData
-
getIndex
public int getIndex(int n)
Description copied from class:AMapToData
Get the given index back as a integer- Specified by:
getIndex
in classAMapToData
- Parameters:
n
- the index to get- Returns:
- the value represented in that cell as integer
-
fill
public void fill(int v)
Description copied from class:AMapToData
Fill the map with a given value. NOTE! The value should be representable inside the map. This requirement is not checked.- Specified by:
fill
in classAMapToData
- Parameters:
v
- the value to fill
-
getInMemorySize
public long getInMemorySize()
Description copied from class:AMapToData
Get the in memory size of this Mapping object.- Specified by:
getInMemorySize
in classAMapToData
- Returns:
- The size in Bytes.
-
getInMemorySize
public static long getInMemorySize(int dataLength)
-
set
public void set(int n, int v)
Description copied from class:AMapToData
Set the index to the value. NOTE! The value should be representable inside the map. This requirement is not checked.- Specified by:
set
in classAMapToData
- Parameters:
n
- index to set.v
- the value to set it to.
-
setAndGet
public int setAndGet(int n, int v)
Description copied from class:AMapToData
Set the index to the value and get the contained value after.- Specified by:
setAndGet
in classAMapToData
- 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
-
size
public int size()
Description copied from class:AMapToData
The size of the Mapping object, signaling how many value cells are stored in this mapping object.- Specified by:
size
in classAMapToData
- Returns:
- The length of the mapping object.
-
replace
public void replace(int v, int r)
Description copied from class:AMapToData
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.- Specified by:
replace
in classAMapToData
- Parameters:
v
- The value to replacer
- The value to put instead
-
getExactSizeOnDisk
public long getExactSizeOnDisk()
Description copied from class:AMapToData
Get the size of this Mapping object on disk.- Specified by:
getExactSizeOnDisk
in classAMapToData
- Returns:
- The on disk size in Bytes.
-
write
public void write(DataOutput out) throws IOException
Description copied from class:AMapToData
Serialize this object to the DataOutput given.- Specified by:
write
in classAMapToData
- Parameters:
out
- The object to serialize this object into.- Throws:
IOException
- An IO exception if the Serialization fails.
-
getUpperBoundValue
public int getUpperBoundValue()
Description copied from class:AMapToData
Get the maximum value that is possible to allocate inside this map.- Specified by:
getUpperBoundValue
in classAMapToData
- Returns:
- The maximum value.
-
getCounts
public int[] getCounts(int[] ret)
Description copied from class:AMapToData
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.- Specified by:
getCounts
in classAMapToData
- Parameters:
ret
- The object to return.- Returns:
- The counts
-
preAggregateDDC_DDCSingleCol
public void preAggregateDDC_DDCSingleCol(AMapToData tm, double[] td, double[] v)
-
preAggregateDDC_DDCMultiCol
public void preAggregateDDC_DDCMultiCol(AMapToData tm, IDictionary td, double[] v, int nCol)
-
isEmpty
public boolean isEmpty()
-
copy
public void copy(AMapToData d)
Description copied from class:AMapToData
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.- Overrides:
copy
in classAMapToData
- Parameters:
d
- Map to copy all values into.
-
copyInt
public void copyInt(int[] d)
- Specified by:
copyInt
in classAMapToData
-
copyBit
public void copyBit(BitSet d)
- Specified by:
copyBit
in classAMapToData
-
resize
public AMapToData resize(int unique)
- Specified by:
resize
in classAMapToData
-
countRuns
public int countRuns()
Description copied from class:AMapToData
Count the number of runs inside the map.- Specified by:
countRuns
in classAMapToData
- Returns:
- The number of runs
-
slice
public AMapToData slice(int l, int u)
Description copied from class:AMapToData
Slice out the range from lower to upper from this map toData.- Specified by:
slice
in classAMapToData
- 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 AMapToData append(AMapToData t)
- Specified by:
append
in classAMapToData
-
equals
public boolean equals(AMapToData e)
Description copied from class:AMapToData
Indicate if the given encoding is equivalent to this encoding- Specified by:
equals
in classAMapToData
- Parameters:
e
- The other encoding to be compared with this- Returns:
- If the encoding is equivalent
-
appendN
public AMapToData appendN(IMapToDataGroup[] d)
- Specified by:
appendN
in classAMapToData
-
getMaxPossible
public int getMaxPossible()
Description copied from class:AMapToData
Get the maximum possible value to encode in this encoding. For instance in a bit you can encode 2 values- Specified by:
getMaxPossible
in classAMapToData
- Returns:
- The maximum number of distinct values to encode
-
toString
public String toString()
- Overrides:
toString
in classAMapToData
-
-