use of org.apache.sysml.runtime.matrix.data.OutputInfo in project incubator-systemml by apache.
the class MatrixObject method writeBlobToHDFS.
/**
* Writes in-memory matrix to HDFS in a specified format.
*/
@Override
protected void writeBlobToHDFS(String fname, String ofmt, int rep, FileFormatProperties fprop) throws IOException, DMLRuntimeException {
long begin = 0;
if (LOG.isTraceEnabled()) {
LOG.trace(" Writing matrix to HDFS... " + hashCode() + " Path: " + fname + ", Format: " + (ofmt != null ? ofmt : "inferred from metadata"));
begin = System.currentTimeMillis();
}
MetaDataFormat iimd = (MetaDataFormat) _metaData;
if (_data != null) {
// Get the dimension information from the metadata stored within MatrixObject
MatrixCharacteristics mc = iimd.getMatrixCharacteristics();
// Write the matrix to HDFS in requested format
OutputInfo oinfo = (ofmt != null ? OutputInfo.stringToOutputInfo(ofmt) : InputInfo.getMatchingOutputInfo(iimd.getInputInfo()));
// note: this is only required if singlenode (due to binarycell default)
if (oinfo == OutputInfo.BinaryBlockOutputInfo && DMLScript.rtplatform == RUNTIME_PLATFORM.SINGLE_NODE && (mc.getRowsPerBlock() != ConfigurationManager.getBlocksize() || mc.getColsPerBlock() != ConfigurationManager.getBlocksize())) {
DataConverter.writeMatrixToHDFS(_data, fname, oinfo, new MatrixCharacteristics(mc.getRows(), mc.getCols(), ConfigurationManager.getBlocksize(), ConfigurationManager.getBlocksize(), mc.getNonZeros()), rep, fprop);
} else {
DataConverter.writeMatrixToHDFS(_data, fname, oinfo, mc, rep, fprop);
}
if (LOG.isTraceEnabled())
LOG.trace("Writing matrix to HDFS (" + fname + ") - COMPLETED... " + (System.currentTimeMillis() - begin) + " msec.");
} else if (LOG.isTraceEnabled()) {
LOG.trace("Writing matrix to HDFS (" + fname + ") - NOTHING TO WRITE (_data == null).");
}
if (DMLScript.STATISTICS)
CacheStatistics.incrementHDFSWrites();
}
use of org.apache.sysml.runtime.matrix.data.OutputInfo in project incubator-systemml by apache.
the class DataPartitionerRemoteReducer method configure.
public void configure(JobConf job) {
String fnameNew = MRJobConfiguration.getPartitioningFilename(job);
OutputInfo oi = MRJobConfiguration.getPartitioningOutputInfo(job);
if (oi == OutputInfo.TextCellOutputInfo)
_reducer = new DataPartitionerReducerTextcell(job, fnameNew);
else if (oi == OutputInfo.BinaryCellOutputInfo)
_reducer = new DataPartitionerReducerBinarycell(job, fnameNew);
else if (oi == OutputInfo.BinaryBlockOutputInfo)
_reducer = new DataPartitionerReducerBinaryblock(job, fnameNew);
else
throw new RuntimeException("Unable to configure reducer with unknown output info: " + oi.toString());
}
use of org.apache.sysml.runtime.matrix.data.OutputInfo in project incubator-systemml by apache.
the class ProgramConverter method parseDataObject.
/**
* NOTE: MRJobConfiguration cannot be used for the general case because program blocks and
* related symbol tables can be hierarchically structured.
*
* @param in data object as string
* @return array of objects
*/
public static Object[] parseDataObject(String in) {
Object[] ret = new Object[2];
StringTokenizer st = new StringTokenizer(in, DATA_FIELD_DELIM);
String name = st.nextToken();
DataType datatype = DataType.valueOf(st.nextToken());
ValueType valuetype = ValueType.valueOf(st.nextToken());
String valString = st.hasMoreTokens() ? st.nextToken() : "";
Data dat = null;
switch(datatype) {
case SCALAR:
{
switch(valuetype) {
case INT:
dat = new IntObject(Long.parseLong(valString));
break;
case DOUBLE:
dat = new DoubleObject(Double.parseDouble(valString));
break;
case BOOLEAN:
dat = new BooleanObject(Boolean.parseBoolean(valString));
break;
case STRING:
dat = new StringObject(valString);
break;
default:
throw new DMLRuntimeException("Unable to parse valuetype " + valuetype);
}
break;
}
case MATRIX:
{
MatrixObject mo = new MatrixObject(valuetype, valString);
long rows = Long.parseLong(st.nextToken());
long cols = Long.parseLong(st.nextToken());
int brows = Integer.parseInt(st.nextToken());
int bcols = Integer.parseInt(st.nextToken());
long nnz = Long.parseLong(st.nextToken());
InputInfo iin = InputInfo.stringToInputInfo(st.nextToken());
OutputInfo oin = OutputInfo.stringToOutputInfo(st.nextToken());
PartitionFormat partFormat = PartitionFormat.valueOf(st.nextToken());
UpdateType inplace = UpdateType.valueOf(st.nextToken());
MatrixCharacteristics mc = new MatrixCharacteristics(rows, cols, brows, bcols, nnz);
MetaDataFormat md = new MetaDataFormat(mc, oin, iin);
mo.setMetaData(md);
if (partFormat._dpf != PDataPartitionFormat.NONE)
mo.setPartitioned(partFormat._dpf, partFormat._N);
mo.setUpdateType(inplace);
dat = mo;
break;
}
default:
throw new DMLRuntimeException("Unable to parse datatype " + datatype);
}
ret[0] = name;
ret[1] = dat;
return ret;
}
use of org.apache.sysml.runtime.matrix.data.OutputInfo in project incubator-systemml by apache.
the class ResultMergeLocalFile method createNewMatrixObject.
private MatrixObject createNewMatrixObject(MatrixObject output, ArrayList<MatrixObject> inMO) {
MetaDataFormat metadata = (MetaDataFormat) _output.getMetaData();
MatrixObject moNew = new MatrixObject(_output.getValueType(), _outputFName);
// create deep copy of metadata obj
MatrixCharacteristics mcOld = metadata.getMatrixCharacteristics();
OutputInfo oiOld = metadata.getOutputInfo();
InputInfo iiOld = metadata.getInputInfo();
MatrixCharacteristics mc = new MatrixCharacteristics(mcOld);
mc.setNonZeros(_isAccum ? -1 : computeNonZeros(output, inMO));
MetaDataFormat meta = new MetaDataFormat(mc, oiOld, iiOld);
moNew.setMetaData(meta);
return moNew;
}
use of org.apache.sysml.runtime.matrix.data.OutputInfo in project incubator-systemml by apache.
the class ResultMergeLocalFile method merge.
private void merge(String fnameNew, MatrixObject outMo, ArrayList<MatrixObject> inMO) {
OutputInfo oi = ((MetaDataFormat) outMo.getMetaData()).getOutputInfo();
// if nnz exist or unknown (-1)
boolean withCompare = (outMo.getNnz() != 0);
if (oi == OutputInfo.TextCellOutputInfo) {
if (withCompare)
mergeTextCellWithComp(fnameNew, outMo, inMO);
else
mergeTextCellWithoutComp(fnameNew, outMo, inMO);
} else if (oi == OutputInfo.BinaryCellOutputInfo) {
if (withCompare)
mergeBinaryCellWithComp(fnameNew, outMo, inMO);
else
mergeBinaryCellWithoutComp(fnameNew, outMo, inMO);
} else if (oi == OutputInfo.BinaryBlockOutputInfo) {
if (withCompare)
mergeBinaryBlockWithComp(fnameNew, outMo, inMO);
else
mergeBinaryBlockWithoutComp(fnameNew, outMo, inMO);
}
}
Aggregations