FileDataSource pageWithRankInput = new FileDataSource(new DanglingPageRankInputFormat(),
pageWithRankInputPath, "DanglingPageWithRankInput");
pageWithRankInput.getParameters().setLong(DanglingPageRankInputFormat.NUM_VERTICES_PARAMETER, numVertices);
BulkIteration iteration = new BulkIteration("Page Rank Loop");
iteration.setInput(pageWithRankInput);
FileDataSource adjacencyListInput = new FileDataSource(new ImprovedAdjacencyListInputFormat(),
adjacencyListInputPath, "AdjancencyListInput");
JoinOperator join = JoinOperator.builder(new DotProductMatch(), LongValue.class, 0, 0)
.input1(iteration.getPartialSolution())
.input2(adjacencyListInput)
.name("Join with Edges")
.build();
CoGroupOperator rankAggregation = CoGroupOperator.builder(new DotProductCoGroup(), LongValue.class, 0, 0)
.input1(iteration.getPartialSolution())
.input2(join)
.name("Rank Aggregation")
.build();
rankAggregation.getParameters().setLong(DotProductCoGroup.NUM_VERTICES_PARAMETER, numVertices);
rankAggregation.getParameters().setLong(DotProductCoGroup.NUM_DANGLING_VERTICES_PARAMETER, numDanglingVertices);
iteration.setNextPartialSolution(rankAggregation);
iteration.setMaximumNumberOfIterations(numIterations);
iteration.getAggregators().registerAggregationConvergenceCriterion(DotProductCoGroup.AGGREGATOR_NAME, new PageRankStatsAggregator(),
new DiffL1NormConvergenceCriterion());
FileDataSink out = new FileDataSink(new PageWithRankOutFormat(), outputPath, iteration, "Final Ranks");
Plan p = new Plan(out, "Dangling PageRank");