(final double[] x, final boolean wantGrad, final boolean wantHessian)
| 276 | } |
| 277 | |
| 278 | @Override |
| 279 | public VEval eval(final double[] x, final boolean wantGrad, final boolean wantHessian) { |
| 280 | try { |
| 281 | final String pathOutName = tmpPrefix + "_MPRedFnOut"; |
| 282 | final Path pathOut = new Path(pathOutName); |
| 283 | final JobStateDescr conf = new JobStateDescr(); |
| 284 | conf.underlying = underlying; |
| 285 | conf.defs = defs; |
| 286 | conf.x = x; |
| 287 | conf.useIntercept = useIntercept; |
| 288 | conf.wantGrad = wantGrad; |
| 289 | conf.wantHessian = wantHessian; |
| 290 | mrConfig.set(MRFIELDNAME,conf.toString()); // prepare config for distribution |
| 291 | // run the job |
| 292 | final Job job = WritableUtils.newJob(mrConfig); |
| 293 | job.setJarByClass(MapRedFn.class); |
| 294 | job.setJobName("MapRedFnStep"); |
| 295 | FileInputFormat.setMaxInputSplitSize(job,4*1024*1024L); |
| 296 | FileInputFormat.setMinInputSplitSize(job,4*1024L); |
| 297 | FileInputFormat.addInputPath(job, pathIn); |
| 298 | FileOutputFormat.setOutputPath(job, pathOut); |
| 299 | job.setMapperClass(SumMapper.class); |
| 300 | job.setCombinerClass(SumReducer.class); |
| 301 | job.setReducerClass(SumReducer.class); |
| 302 | job.setOutputKeyClass(Text.class); |
| 303 | job.setOutputValueClass(DoubleWritable.class); |
| 304 | job.setInputFormatClass(TextInputFormat.class); |
| 305 | job.setOutputFormatClass(TextOutputFormat.class); |
| 306 | job.setNumReduceTasks(1); |
| 307 | final VEval r = new VEval(x,wantGrad,wantHessian); |
| 308 | if(job.waitForCompletion(false)) { |
| 309 | // collect results |
| 310 | final FSDataInputStream fdi = pathOut.getFileSystem(mrConfig).open(new Path(pathOut,"part-r-00000")); |
| 311 | final BufferedReader d = new BufferedReader(new InputStreamReader(fdi)); |
| 312 | SumMapper.addVEvalFromBufferedReader(r,d); |
| 313 | d.close(); |
| 314 | } |
| 315 | // clean up |
| 316 | pathOut.getFileSystem(mrConfig).delete(pathOut,true); |
| 317 | return r; |
| 318 | } catch (Exception ex) { |
| 319 | log.error("caught: " + ex); |
| 320 | throw new RuntimeException(ex); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | } |
nothing calls this directly
no test coverage detected