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
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:
-
Constructor Summary
ConstructorsConstructorDescriptionMapToBit(int unique, int size) A Bit map containing the values of the map inside a long array. -
Method Summary
Modifier and TypeMethodDescriptionappend(AMapToData t) appendN(IMapToDataGroup[] d) voidvoidcopyInt(int[] d, int start, int end) intCount the number of runs inside the map.voiddecompressToRangeNoOff(double[] c, int rl, int ru, double[] values) voiddecompressToRangeOff(double[] c, int rl, int ru, int offR, double[] values) booleanequals(AMapToData e) Indicate if the given encoding is equivalent to this encodingvoidfill(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.longGet the size of this Mapping object on disk.intgetIndex(int n) Get the given index back as a integerlongGet the in memory size of this Mapping object.static longgetInMemorySize(int dataLength) getType()intGet the maximum value that is possible to allocate inside this map.booleanisEmpty()intnextSetBit(int fromIndex) Return the index of the next bit set to one.voidpreAggregateDDC_DDCMultiCol(AMapToData tm, IDictionary td, double[] v, int nCol) voidpreAggregateDDC_DDCSingleCol(AMapToData tm, double[] td, double[] v) voidreplace(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.resize(int unique) Reallocate the map, to a smaller instance if applicable.voidset(int n, int v) Set the index to the value.voidset(int l, int u, int off, AMapToData tm) set a range of values from another map.intsetAndGet(int n, int v) Set the index to the value and get the contained value after.intsize()The size of the Mapping object, signaling how many value cells are stored in this mapping object.slice(int l, int u) Slice out the range from lower to upper from this map toData.toString()voidwrite(DataOutput out) Serialize this object to the DataOutput given.Methods inherited from class org.apache.sysds.runtime.compress.colgroup.mapping.AMapToData
copy, copyInt, countRuns, decompressToRange, equals, getCounts, getMax, getUnique, lmSparseMatrixRow, preAggregateDDC_DDC, preAggregateDDC_RLE, preAggregateDDC_SDCZ, preAggregateDDC_SDCZMultiCol, preAggregateDDC_SDCZSingleCol, preAggregateDense, preAggregateDense, preAggregateRLE_DDC, preAggregateSDCZ_DDC, preAggregateSDCZ_SDCZ, preAggregateSparse, preAggregateSparse, removeEmpty, removeEmpty, set, setUnique, splitReshapeDDC, splitReshapeDDCPushDown, verify
-
Constructor Details
-
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 Details
-
getType
- Specified by:
getTypein classAMapToData
-
getIndex
public int getIndex(int n) Description copied from class:AMapToDataGet the given index back as a integer- Specified by:
getIndexin 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:AMapToDataFill the map with a given value. NOTE! The value should be representable inside the map. This requirement is not checked.- Specified by:
fillin classAMapToData- Parameters:
v- the value to fill
-
getInMemorySize
public long getInMemorySize()Description copied from class:AMapToDataGet the in memory size of this Mapping object.- Specified by:
getInMemorySizein 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:AMapToDataSet the index to the value. NOTE! The value should be representable inside the map. This requirement is not checked.- Specified by:
setin classAMapToData- Parameters:
n- index to set.v- the value to set it to.
-
set
Description copied from class:AMapToDataset a range of values from another map. The given tm must only contain supported values, and it is not verified.- Specified by:
setin classAMapToData- Parameters:
l- lower boundu- upper bound (not inclusive)off- offset to take values from tmtm- the other map to copy values from
-
setAndGet
public int setAndGet(int n, int v) Description copied from class:AMapToDataSet the index to the value and get the contained value after.- Specified by:
setAndGetin 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:AMapToDataThe size of the Mapping object, signaling how many value cells are stored in this mapping object.- Specified by:
sizein classAMapToData- Returns:
- The length of the mapping object.
-
replace
public void replace(int v, int r) Description copied from class:AMapToDataReplace 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:
replacein classAMapToData- Parameters:
v- The value to replacer- The value to put instead
-
getExactSizeOnDisk
public long getExactSizeOnDisk()Description copied from class:AMapToDataGet the size of this Mapping object on disk.- Specified by:
getExactSizeOnDiskin classAMapToData- Returns:
- The on disk size in Bytes.
-
write
Description copied from class:AMapToDataSerialize this object to the DataOutput given.- Specified by:
writein 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:AMapToDataGet the maximum value that is possible to allocate inside this map.- Specified by:
getUpperBoundValuein classAMapToData- Returns:
- The maximum value.
-
getCounts
public int[] getCounts(int[] ret) Description copied from class:AMapToDataGet 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:
getCountsin classAMapToData- Parameters:
ret- The object to return.- Returns:
- The counts
-
preAggregateDDC_DDCSingleCol
-
preAggregateDDC_DDCMultiCol
-
isEmpty
public boolean isEmpty() -
copyInt
public void copyInt(int[] d, int start, int end) - Specified by:
copyIntin classAMapToData
-
copyBit
- Overrides:
copyBitin classAMapToData
-
nextSetBit
public int nextSetBit(int fromIndex) Return the index of the next bit set to one. If no more bits are set to one return -1. The method behaves similarly to and is inspired from java's BitSet. If a negative value is given as input it fails.- Parameters:
fromIndex- The index to start from (inclusive)- Returns:
- The next valid index.
-
resize
Description copied from class:AMapToDataReallocate the map, to a smaller instance if applicable. Note it does not change the length of the array, just the datatype. Note that it returns the input if the input is the smallest representation that fits, otherwise it will return something that is smaller.- Specified by:
resizein classAMapToData- Parameters:
unique- The number of tuples that should be supported in the resulting map- Returns:
- The returned hopefully reduced map.
-
countRuns
public int countRuns()Description copied from class:AMapToDataCount the number of runs inside the map.- Specified by:
countRunsin classAMapToData- Returns:
- The number of runs
-
slice
Description copied from class:AMapToDataSlice out the range from lower to upper from this map toData.- Specified by:
slicein 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
- Specified by:
appendin classAMapToData
-
equals
Description copied from class:AMapToDataIndicate if the given encoding is equivalent to this encoding- Specified by:
equalsin classAMapToData- Parameters:
e- The other encoding to be compared with this- Returns:
- If the encoding is equivalent
-
appendN
- Specified by:
appendNin classAMapToData
-
decompressToRangeOff
public void decompressToRangeOff(double[] c, int rl, int ru, int offR, double[] values) -
decompressToRangeNoOff
public void decompressToRangeNoOff(double[] c, int rl, int ru, double[] values) -
toString
- Overrides:
toStringin classAMapToData
-