Pipe analysisPipe = new Pipe(ANALYZER_PIPE_NAME, splitterPipe.getTails()[0]);
analysisPipe = new Each(analysisPipe, new ParseEmailFunction());
// We'll get output that has ANALYZED_EMAIL_FIELDS in it. We want to group by
// the message-id field, and then do an aggregation on that of the scores.
analysisPipe = new GroupBy(analysisPipe, new Fields(FieldNames.MESSAGE_ID));
analysisPipe = new Every(analysisPipe, new CalcMessageScoreBuffer(), Fields.RESULTS);
// Now we want to sum the scores for each user, which is another grouping/summing.
analysisPipe = new GroupBy(analysisPipe, new Fields(FieldNames.EMAIL_ADDRESS));
analysisPipe = new Every(analysisPipe, new SumScoresBuffer(), Fields.RESULTS);
// Let's filter out anybody with an uninteresting score.
ExpressionFilter filter = new ExpressionFilter(String.format("%s <= 0.0", FieldNames.SUMMED_SCORE), Double.class);
analysisPipe = new Each(analysisPipe, filter);
// And let's sort in reverse order (high to low score)
analysisPipe = new GroupBy(analysisPipe, new Fields(FieldNames.SUMMED_SCORE), true);
// Create the sink taps
BasePath outputPath = platform.makePath(outputDirName);
Tap pageStatusSinkTap = platform.makeTap(platform.makeTextScheme(),
platform.makePath(outputPath, "page-status"), SinkMode.REPLACE);