src/main/java/org/apache/sysds/runtime/compress/BitmapEncoder.java
/**
	 * Extract Bitmap from a single column.
	 * 
	 * It counts the instances of zero, but skips storing the values.
	 * 
	 * @param colIndex     The index of the column
	 * @param rawBlock     The Raw matrix block (that can be transposed)
	 * @param compSettings The Compression settings used, in this instance to know if the raw block is transposed.
	 * @return Bitmap containing the Information of the column.
	 */
Extract Bitmap from a single column.

It counts the instances of zero, but skips storing the values.

@param colIndex     The index of the column
@param rawBlock     The Raw matrix block (that can be transposed)
@param compSettings The Compression settings used, in this instance to know if the raw block is transposed.
@return Bitmap containing the Information of the column.
Extract Bitmap from a single column . It counts the instances of zero but skips storing the values . @param colIndex The index of the column @param rawBlock The Raw matrix block ( that can be transposed ) @param compSettings The Compression settings used in this instance to know if the raw block is transposed . @return Bitmap containing the Information of the column .
private static Bitmap extractBitmap(int colIndex, MatrixBlock rawBlock, CompressionSettings compSettings) {
		DoubleIntListHashMap distinctVals = new DoubleIntListHashMap();
		final int m = compSettings.transposeInput ? rawBlock.getNumColumns() : rawBlock.getNumRows();
		int numZeros = 0;
		if(rawBlock.isInSparseFormat() && compSettings.transposeInput) { 
			SparseBlock a = rawBlock.getSparseBlock();
			if(a != null && !a.isEmpty(colIndex)) {
				int apos = a.pos(colIndex);
				int alen = a.size(colIndex);
				numZeros = m - alen;
				int[] aix = a.indexes(colIndex);
				double[] avals = a.values(colIndex);
				for(int j = apos; j < apos + alen; j++) {
					IntArrayList lstPtr = distinctVals.get(avals[j]);
					if(lstPtr == null) {
						lstPtr = new IntArrayList();
						distinctVals.appendValue(avals[j], lstPtr);
					}
					lstPtr.appendValue(aix[j]);
				}
			}
		}
		else 
		{
			for(int i = 0; i < m; i++) {
				double val = compSettings.transposeInput ? rawBlock.quickGetValue(colIndex, i) : rawBlock
					.quickGetValue(i, colIndex);
				if(val != 0) {
					IntArrayList lstPtr = distinctVals.get(val);
					if(lstPtr == null) {
						lstPtr = new IntArrayList();
						distinctVals.appendValue(val, lstPtr);
					}
					lstPtr.appendValue(i);
				}
				else {
					numZeros++;
				}
			}
		}
		return makeBitmap(distinctVals, numZeros);
	}
private static Bitmap extractBitmap ( int colIndex , MatrixBlock rawBlock , CompressionSettings compSettings ) { DoubleIntListHashMap distinctVals = new DoubleIntListHashMap ( ) ; final int m = compSettings . transposeInput ? rawBlock . getNumColumns ( ) : rawBlock . getNumRows ( ) ; int numZeros = 0 ; if ( rawBlock . isInSparseFormat ( ) && compSettings . transposeInput ) { SparseBlock a = rawBlock . getSparseBlock ( ) ; if ( a != null && ! a . isEmpty ( colIndex ) ) { int apos = a . pos ( colIndex ) ; int alen = a . size ( colIndex ) ; numZeros = m - alen ; int [ ] aix = a . indexes ( colIndex ) ; double [ ] avals = a . values ( colIndex ) ; for ( int j = apos ; j < apos + alen ; j ++ ) { IntArrayList lstPtr = distinctVals . get ( avals [ j ] ) ; if ( lstPtr == null ) { lstPtr = new IntArrayList ( ) ; distinctVals . appendValue ( avals [ j ] , lstPtr ) ; } lstPtr . appendValue ( aix [ j ] ) ; } } } else { for ( int i = 0 ; i < m ; i ++ ) { double val = compSettings . transposeInput ? rawBlock . quickGetValue ( colIndex , i ) : rawBlock . quickGetValue ( i , colIndex ) ; if ( val != 0 ) { IntArrayList lstPtr = distinctVals . get ( val ) ; if ( lstPtr == null ) { lstPtr = new IntArrayList ( ) ; distinctVals . appendValue ( val , lstPtr ) ; } lstPtr . appendValue ( i ) ; } else { numZeros ++ ; } } } return makeBitmap ( distinctVals , numZeros ) ; }
Extract Bitmap from a single column.
Extract Bitmap from a single column .
// probe map for distinct items (for value or value groups) // scan rows and probe/build distinct items // SPARSE and Transposed. // GENERAL CASE