use of org.apache.sysml.runtime.controlprogram.parfor.util.PairWritableCell in project incubator-systemml by apache.
the class RemoteDPParWorkerReducer method collectBinaryCellInput.
/**
* Collects a matrixblock partition from a given input iterator over
* binary cells.
*
* Note it reuses the instance attribute _partition - multiple calls
* will overwrite the result.
*
* @param valueList iterable writables
* @return matrix block
* @throws IOException if IOException occurs
*/
private MatrixBlock collectBinaryCellInput(Iterator<Writable> valueList) throws IOException {
//reset reuse block, keep configured representation
if (_tSparseCol)
_partition.reset(_clen, _rlen);
else
_partition.reset(_rlen, _clen);
switch(_dpf) {
case ROW_WISE:
while (valueList.hasNext()) {
PairWritableCell pairValue = (PairWritableCell) valueList.next();
if (pairValue.indexes.getColumnIndex() < 0)
//cells used to ensure empty partitions
continue;
_partition.quickSetValue(0, (int) pairValue.indexes.getColumnIndex() - 1, pairValue.cell.getValue());
}
break;
case COLUMN_WISE:
while (valueList.hasNext()) {
PairWritableCell pairValue = (PairWritableCell) valueList.next();
if (pairValue.indexes.getRowIndex() < 0)
//cells used to ensure empty partitions
continue;
if (_tSparseCol)
_partition.appendValue(0, (int) pairValue.indexes.getRowIndex() - 1, pairValue.cell.getValue());
else
_partition.quickSetValue((int) pairValue.indexes.getRowIndex() - 1, 0, pairValue.cell.getValue());
}
break;
default:
throw new IOException("Partition format not yet supported in fused partition-execute: " + _dpf);
}
//final partition cleanup
cleanupCollectedMatrixPartition(_tSparseCol);
return _partition;
}
use of org.apache.sysml.runtime.controlprogram.parfor.util.PairWritableCell in project incubator-systemml by apache.
the class RemoteDPParForSparkWorker method collectBinaryCellInput.
/**
* Collects a matrixblock partition from a given input iterator over
* binary cells.
*
* Note it reuses the instance attribute _partition - multiple calls
* will overwrite the result.
*
* @param valueList iterable writables
* @return matrix block
* @throws IOException if IOException occurs
*/
private MatrixBlock collectBinaryCellInput(Iterable<Writable> valueList) throws IOException {
MatrixBlock partition = null;
//reset reuse block, keep configured representation
if (_tSparseCol)
partition = new MatrixBlock(_clen, _rlen, true);
else
partition = new MatrixBlock(_rlen, _clen, false);
switch(_dpf) {
case ROW_WISE:
while (valueList.iterator().hasNext()) {
PairWritableCell pairValue = (PairWritableCell) valueList.iterator().next();
if (pairValue.indexes.getColumnIndex() < 0)
//cells used to ensure empty partitions
continue;
partition.quickSetValue(0, (int) pairValue.indexes.getColumnIndex() - 1, pairValue.cell.getValue());
}
break;
case COLUMN_WISE:
while (valueList.iterator().hasNext()) {
PairWritableCell pairValue = (PairWritableCell) valueList.iterator().next();
if (pairValue.indexes.getRowIndex() < 0)
//cells used to ensure empty partitions
continue;
if (_tSparseCol)
partition.appendValue(0, (int) pairValue.indexes.getRowIndex() - 1, pairValue.cell.getValue());
else
partition.quickSetValue((int) pairValue.indexes.getRowIndex() - 1, 0, pairValue.cell.getValue());
}
break;
default:
throw new IOException("Partition format not yet supported in fused partition-execute: " + _dpf);
}
//post-processing: cleanups if required
try {
if (partition.isInSparseFormat() && _tSparseCol)
partition.sortSparseRows();
partition.recomputeNonZeros();
partition.examSparsity();
} catch (DMLRuntimeException ex) {
throw new IOException(ex);
}
return partition;
}
Aggregations