private void runParForRepeatedOptTest(boolean reusePartitionedData,boolean update,boolean changedDim,ExecType et,int numExpectedMR){
  RUNTIME_PLATFORM platformOld=rtplatform;
  double memfactorOld=OptimizerUtils.MEM_UTIL_FACTOR;
  boolean reuseOld=ParForProgramBlock.ALLOW_REUSE_PARTITION_VARS;
  String TEST_NAME=update ? TEST_NAME2 : (changedDim ? TEST_NAME3 : TEST_NAME1);
  TestConfiguration config=getTestConfiguration(TEST_NAME);
  config.addVariable("rows",rows);
  config.addVariable("cols",cols);
  String TEST_CACHE_DIR="";
  if (TEST_CACHE_ENABLED) {
    TEST_CACHE_DIR=TEST_NAME + "/";
  }
  loadTestConfiguration(config,TEST_CACHE_DIR);
  try {
    rtplatform=(et == ExecType.MR) ? RUNTIME_PLATFORM.HADOOP : RUNTIME_PLATFORM.HYBRID;
    OptimizerUtils.MEM_UTIL_FACTOR=computeMemoryUtilFactor(70);
    ParForProgramBlock.ALLOW_REUSE_PARTITION_VARS=reusePartitionedData;
    String HOME=SCRIPT_DIR + TEST_DIR;
    fullDMLScriptName=HOME + TEST_NAME + ".dml";
    programArgs=new String[]{"-stats","-args",input("V"),Integer.toString(rows),Integer.toString(cols),output("R"),Integer.toString((update || changedDim) ? 1 : 0)};
    fullRScriptName=HOME + TEST_NAME + ".R";
    rCmd="Rscript" + " " + fullRScriptName + " "+ inputDir()+ " "+ expectedDir()+ " "+ Integer.toString((update || changedDim) ? 1 : 0);
    double[][] V=getRandomMatrix(rows,cols,0,1,sparsity,7);
    writeInputMatrix("V",V,true);
    runTest(true,false,null,-1);
    runRScript(true);
    Assert.assertEquals("Unexpected number of executed MR jobs.",numExpectedMR,Statistics.getNoOfExecutedMRJobs());
    HashMap<CellIndex,Double> dmlfile=readDMLMatrixFromHDFS("R");
    HashMap<CellIndex,Double> rfile=readRMatrixFromFS("R");
    TestUtils.compareMatrices(dmlfile,rfile,eps,"DML","R");
  }
  finally {
    rtplatform=platformOld;
    OptimizerUtils.MEM_UTIL_FACTOR=memfactorOld;
    ParForProgramBlock.ALLOW_REUSE_PARTITION_VARS=reuseOld;
  }
}

private void runParForRepeatedOptTest ( boolean reusePartitionedData , boolean update , boolean changedDim , ExecType et , int numExpectedMR ) { RUNTIME_PLATFORM platformOld = rtplatform ; double memfactorOld = OptimizerUtils . MEM_UTIL_FACTOR ; boolean reuseOld = ParForProgramBlock . ALLOW_REUSE_PARTITION_VARS ; String TEST_NAME = update ? TEST_NAME2 : ( changedDim ? TEST_NAME3 : TEST_NAME1 ) ; TestConfiguration config = getTestConfiguration ( TEST_NAME ) ; config . addVariable ( "rows" , rows ) ; config . addVariable ( "cols" , cols ) ; String TEST_CACHE_DIR = "" ; if ( TEST_CACHE_ENABLED ) { TEST_CACHE_DIR = TEST_NAME + "/" ; } loadTestConfiguration ( config , TEST_CACHE_DIR ) ; try { rtplatform = ( et == ExecType . MR ) ? RUNTIME_PLATFORM . HADOOP : RUNTIME_PLATFORM . HYBRID ; OptimizerUtils . MEM_UTIL_FACTOR = computeMemoryUtilFactor ( 70 ) ; ParForProgramBlock . ALLOW_REUSE_PARTITION_VARS = reusePartitionedData ; String HOME = SCRIPT_DIR + TEST_DIR ; fullDMLScriptName = HOME + TEST_NAME + ".dml" ; programArgs = new String [ ] { "-stats" , "-args" , input ( "V" ) , Integer . toString ( rows ) , Integer . toString ( cols ) , output ( "R" ) , Integer . toString ( ( update || changedDim ) ? 1 : 0 ) } ; fullRScriptName = HOME + TEST_NAME + ".R" ; rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir ( ) + " " + expectedDir ( ) + " " + Integer . toString ( ( update || changedDim ) ? 1 : 0 ) ; double [ ] [ ] V = getRandomMatrix ( rows , cols , 0 , 1 , sparsity , 7 ) ; writeInputMatrix ( "V" , V , true ) ; runTest ( true , false , null , - 1 ) ; runRScript ( true ) ; Assert . assertEquals ( "Unexpected number of executed MR jobs." , numExpectedMR , Statistics . getNoOfExecutedMRJobs ( ) ) ; HashMap < CellIndex , Double > dmlfile = readDMLMatrixFromHDFS ( "R" ) ; HashMap < CellIndex , Double > rfile = readRMatrixFromFS ( "R" ) ; TestUtils . compareMatrices ( dmlfile , rfile , eps , "DML" , "R" ) ; } finally { rtplatform = platformOld ; OptimizerUtils . MEM_UTIL_FACTOR = memfactorOld ; ParForProgramBlock . ALLOW_REUSE_PARTITION_VARS = reuseOld ; } }
update , refers to changing data changed dim , refers to changing dimensions and changing parfor predicate
