public static Object[] parseDataObject(String in) throws DMLRuntimeException {
  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:
        long value1=Long.parseLong(valString);
      dat=new IntObject(name,value1);
    break;
case DOUBLE:
  double value2=Double.parseDouble(valString);
dat=new DoubleObject(name,value2);
break;
case BOOLEAN:
boolean value3=Boolean.parseBoolean(valString);
dat=new BooleanObject(name,value3);
break;
case STRING:
dat=new StringObject(name,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());
PDataPartitionFormat partFormat=PDataPartitionFormat.valueOf(st.nextToken());
UpdateType inplace=UpdateType.valueOf(st.nextToken());
MatrixCharacteristics mc=new MatrixCharacteristics(rows,cols,brows,bcols,nnz);
MatrixFormatMetaData md=new MatrixFormatMetaData(mc,oin,iin);
mo.setMetaData(md);
mo.setVarName(name);
if (partFormat != PDataPartitionFormat.NONE) mo.setPartitioned(partFormat,-1);
mo.setUpdateType(inplace);
dat=mo;
break;
}
default :
throw new DMLRuntimeException("Unable to parse datatype " + datatype);
}
ret[0]=name;
ret[1]=dat;
return ret;
}

public static Object [ ] parseDataObject ( String in ) throws DMLRuntimeException { 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 : long value1 = Long . parseLong ( valString ) ; dat = new IntObject ( name , value1 ) ; break ; case DOUBLE : double value2 = Double . parseDouble ( valString ) ; dat = new DoubleObject ( name , value2 ) ; break ; case BOOLEAN : boolean value3 = Boolean . parseBoolean ( valString ) ; dat = new BooleanObject ( name , value3 ) ; break ; case STRING : dat = new StringObject ( name , 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 ( ) ) ; PDataPartitionFormat partFormat = PDataPartitionFormat . valueOf ( st . nextToken ( ) ) ; UpdateType inplace = UpdateType . valueOf ( st . nextToken ( ) ) ; MatrixCharacteristics mc = new MatrixCharacteristics ( rows , cols , brows , bcols , nnz ) ; MatrixFormatMetaData md = new MatrixFormatMetaData ( mc , oin , iin ) ; mo . setMetaData ( md ) ; mo . setVarName ( name ) ; if ( partFormat != PDataPartitionFormat . NONE ) mo . setPartitioned ( partFormat , - 1 ) ; mo . setUpdateType ( inplace ) ; dat = mo ; break ; } default : throw new DMLRuntimeException ( "Unable to parse datatype " + datatype ) ; } ret [ 0 ] = name ; ret [ 1 ] = dat ; return ret ; }
note : mrjobconfiguration cannot be used for the general case because program blocks and related symbol tables can be hierarchically structured .
