public void registerInput(String varName,JavaRDD<String> rddIn,String format,long rlen,long clen,FileFormatProperties props,List<ValueType> schema) throws DMLRuntimeException {
  if (!(DMLScript.rtplatform == RUNTIME_PLATFORM.SPARK || DMLScript.rtplatform == RUNTIME_PLATFORM.HYBRID_SPARK)) {
    throw new DMLRuntimeException("The registerInput functionality only supported for spark runtime. Please use MLContext(sc) instead of default constructor.");
  }
  long nnz=-1;
  if (_variables == null)   _variables=new LocalVariableMap();
  if (_inVarnames == null)   _inVarnames=new ArrayList<String>();
  JavaPairRDD<LongWritable,Text> rddText=rddIn.mapToPair(new ConvertStringToLongTextPair());
  int blksz=ConfigurationManager.getBlocksize();
  MatrixCharacteristics mc=new MatrixCharacteristics(rlen,clen,blksz,blksz,nnz);
  FrameObject fo=null;
  if (format.equals("csv")) {
    CSVFileFormatProperties csvprops=(props != null) ? (CSVFileFormatProperties)props : new CSVFileFormatProperties();
    fo=new FrameObject(OptimizerUtils.getUniqueTempFileName(),new MatrixFormatMetaData(mc,OutputInfo.CSVOutputInfo,InputInfo.CSVInputInfo));
    fo.setFileFormatProperties(csvprops);
  }
 else   if (format.equals("text")) {
    if (rlen == -1 || clen == -1) {
      throw new DMLRuntimeException("The metadata is required in registerInput for format:" + format);
    }
    fo=new FrameObject(null,new MatrixFormatMetaData(mc,OutputInfo.TextCellOutputInfo,InputInfo.TextCellInputInfo));
  }
 else {
    throw new DMLRuntimeException("Incorrect format in registerInput: " + format);
  }
  if (props != null)   fo.setFileFormatProperties(props);
  fo.setRDDHandle(new RDDObject(rddText,varName));
  fo.setSchema("String");
  _variables.put(varName,fo);
  _inVarnames.add(varName);
  checkIfRegisteringInputAllowed();
}

public void registerInput ( String varName , JavaRDD < String > rddIn , String format , long rlen , long clen , FileFormatProperties props , List < ValueType > schema ) throws DMLRuntimeException { if ( ! ( DMLScript . rtplatform == RUNTIME_PLATFORM . SPARK || DMLScript . rtplatform == RUNTIME_PLATFORM . HYBRID_SPARK ) ) { throw new DMLRuntimeException ( "The registerInput functionality only supported for spark runtime. Please use MLContext(sc) instead of default constructor." ) ; } long nnz = - 1 ; if ( _variables == null ) _variables = new LocalVariableMap ( ) ; if ( _inVarnames == null ) _inVarnames = new ArrayList < String > ( ) ; JavaPairRDD < LongWritable , Text > rddText = rddIn . mapToPair ( new ConvertStringToLongTextPair ( ) ) ; int blksz = ConfigurationManager . getBlocksize ( ) ; MatrixCharacteristics mc = new MatrixCharacteristics ( rlen , clen , blksz , blksz , nnz ) ; FrameObject fo = null ; if ( format . equals ( "csv" ) ) { CSVFileFormatProperties csvprops = ( props != null ) ? ( CSVFileFormatProperties ) props : new CSVFileFormatProperties ( ) ; fo = new FrameObject ( OptimizerUtils . getUniqueTempFileName ( ) , new MatrixFormatMetaData ( mc , OutputInfo . CSVOutputInfo , InputInfo . CSVInputInfo ) ) ; fo . setFileFormatProperties ( csvprops ) ; } else if ( format . equals ( "text" ) ) { if ( rlen == - 1 || clen == - 1 ) { throw new DMLRuntimeException ( "The metadata is required in registerInput for format:" + format ) ; } fo = new FrameObject ( null , new MatrixFormatMetaData ( mc , OutputInfo . TextCellOutputInfo , InputInfo . TextCellInputInfo ) ) ; } else { throw new DMLRuntimeException ( "Incorrect format in registerInput: " + format ) ; } if ( props != null ) fo . setFileFormatProperties ( props ) ; fo . setRDDHandle ( new RDDObject ( rddText , varName ) ) ; fo . setSchema ( "String" ) ; _variables . put ( varName , fo ) ; _inVarnames . add ( varName ) ; checkIfRegisteringInputAllowed ( ) ; }
register frame with csv / text as inputs : with dimensions . file properties ( example : delim , fill , . . ) can be specified through props else defaults will be used . < p > marks the variable in the dml script as input variable . note that this expects a " varname = read ( . . . ) " statement in the dml script which through non - mlcontext invocation would have been created by reading a hdfs file .
