This project has retired. For details please refer to its
Attic page.
PageRankBenchmark xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.giraph.benchmark;
20
21 import org.apache.commons.cli.CommandLine;
22 import org.apache.giraph.combiner.FloatSumMessageCombiner;
23 import org.apache.giraph.conf.GiraphConfiguration;
24 import org.apache.giraph.conf.GiraphTypes;
25 import org.apache.giraph.edge.IntNullArrayEdges;
26 import org.apache.giraph.graph.Language;
27 import org.apache.giraph.io.formats.PseudoRandomInputFormatConstants;
28 import org.apache.giraph.io.formats.PseudoRandomIntNullVertexInputFormat;
29 import org.apache.giraph.scripting.DeployType;
30 import org.apache.giraph.scripting.ScriptLoader;
31 import org.apache.giraph.jython.JythonUtils;
32 import org.apache.giraph.utils.DistributedCacheUtils;
33 import org.apache.giraph.utils.ReflectionUtils;
34 import org.apache.hadoop.fs.Path;
35 import org.apache.hadoop.util.ToolRunner;
36
37 import com.google.common.collect.Sets;
38
39 import java.util.Set;
40
41
42
43
44 public class PageRankBenchmark extends GiraphBenchmark {
45 @Override
46 public Set<BenchmarkOption> getBenchmarkOptions() {
47 return Sets.newHashSet(BenchmarkOption.VERTICES,
48 BenchmarkOption.EDGES_PER_VERTEX, BenchmarkOption.SUPERSTEPS,
49 BenchmarkOption.LOCAL_EDGES_MIN_RATIO, BenchmarkOption.JYTHON,
50 BenchmarkOption.SCRIPT_PATH);
51 }
52
53 @Override
54 protected void prepareConfiguration(GiraphConfiguration conf,
55 CommandLine cmd) {
56 if (BenchmarkOption.JYTHON.optionTurnedOn(cmd)) {
57 GiraphTypes types = new GiraphTypes();
58 types.inferFrom(PageRankComputation.class);
59
60 String script;
61 DeployType deployType;
62 if (BenchmarkOption.SCRIPT_PATH.optionTurnedOn(cmd)) {
63 deployType = DeployType.DISTRIBUTED_CACHE;
64 String path = BenchmarkOption.SCRIPT_PATH.getOptionValue(cmd);
65 Path hadoopPath = new Path(path);
66 Path remotePath = DistributedCacheUtils.copyAndAdd(hadoopPath, conf);
67 script = remotePath.toString();
68 } else {
69 deployType = DeployType.RESOURCE;
70 script = ReflectionUtils.getPackagePath(this) + "/page-rank.py";
71 }
72 ScriptLoader.setScriptsToLoad(conf, script, deployType, Language.JYTHON);
73 types.writeIfUnset(conf);
74 JythonUtils.init(conf, "PageRank");
75 } else {
76 conf.setComputationClass(PageRankComputation.class);
77 }
78 conf.setOutEdgesClass(IntNullArrayEdges.class);
79 conf.setMessageCombinerClass(FloatSumMessageCombiner.class);
80 conf.setVertexInputFormatClass(
81 PseudoRandomIntNullVertexInputFormat.class);
82
83 conf.setInt(PseudoRandomInputFormatConstants.AGGREGATE_VERTICES,
84 BenchmarkOption.VERTICES.getOptionIntValue(cmd));
85 conf.setInt(PseudoRandomInputFormatConstants.EDGES_PER_VERTEX,
86 BenchmarkOption.EDGES_PER_VERTEX.getOptionIntValue(cmd));
87 conf.setInt(PageRankComputation.SUPERSTEP_COUNT,
88 BenchmarkOption.SUPERSTEPS.getOptionIntValue(cmd));
89 conf.setFloat(PseudoRandomInputFormatConstants.LOCAL_EDGES_MIN_RATIO,
90 BenchmarkOption.LOCAL_EDGES_MIN_RATIO.getOptionFloatValue(cmd,
91 PseudoRandomInputFormatConstants.LOCAL_EDGES_MIN_RATIO_DEFAULT));
92 }
93
94
95
96
97
98
99
100 public static void main(final String[] args) throws Exception {
101 System.exit(ToolRunner.run(new PageRankBenchmark(), args));
102 }
103 }