SizzleParser.ReInit(new StringReader(source));
TestCodeGeneratingVisitor.typeChecker.visit(SizzleParser.Start(), st);
SizzleParser.ReInit(new StringReader(source));
final String src = codeGenerator.visit(SizzleParser.Start(), st);
SizzleRunner sizzleRunner = null;
try {
sizzleRunner = TestCodeGeneratingVisitor.compiler.compile("sizzle.WordStats", src, null, new Class<?>[] { SizzleRunner.class }).newInstance();
} catch (final CharSequenceCompilerException e) {
for (final Diagnostic<? extends JavaFileObject> d : e.getDiagnostics().getDiagnostics())
System.err.println(d.toString());
throw e;
}
final MapReduceDriver<LongWritable, Text, EmitKey, EmitValue, Text, NullWritable> mapReduceDriver = new MapReduceDriver<LongWritable, Text, EmitKey, EmitValue, Text, NullWritable>();
mapReduceDriver.setMapper(sizzleRunner.getMapper());
// TODO: add the combiner when MAPREDUCE-797 is integrated
mapReduceDriver.setReducer(sizzleRunner.getReducer());
mapReduceDriver.addInput(new LongWritable(0), new Text("To be, or not to be: that is the question:"));
mapReduceDriver.addInput(new LongWritable(0), new Text("Whether 'tis nobler in the mind to suffer"));
mapReduceDriver.addInput(new LongWritable(0), new Text("The slings and arrows of outrageous fortune,"));
mapReduceDriver.addInput(new LongWritable(0), new Text("Or to take arms against a sea of troubles,"));
mapReduceDriver.addOutput(new Text("longest[] = outrageous weight 10.0"), NullWritable.get());