本文整理汇总了Java中org.apache.giraph.conf.GiraphConfiguration.setCombinerClass方法的典型用法代码示例。如果您正苦于以下问题:Java GiraphConfiguration.setCombinerClass方法的具体用法?Java GiraphConfiguration.setCombinerClass怎么用?Java GiraphConfiguration.setCombinerClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.giraph.conf.GiraphConfiguration
的用法示例。
在下文中一共展示了GiraphConfiguration.setCombinerClass方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareConfiguration
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Override
protected void prepareConfiguration(GiraphConfiguration conf,
CommandLine cmd) {
conf.setVertexClass(ShortestPathsVertex.class);
if (EDGES_CLASS.getOptionIntValue(cmd, 1) == 1) {
conf.setOutEdgesClass(ArrayListEdges.class);
} else {
conf.setOutEdgesClass(HashMapEdges.class);
}
LOG.info("Using class " + GiraphConstants.VERTEX_CLASS.get(conf));
conf.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
if (!NO_COMBINER.optionTurnedOn(cmd)) {
conf.setCombinerClass(MinimumDoubleCombiner.class);
}
conf.setLong(PseudoRandomInputFormatConstants.AGGREGATE_VERTICES,
BenchmarkOption.VERTICES.getOptionLongValue(cmd));
conf.setLong(PseudoRandomInputFormatConstants.EDGES_PER_VERTEX,
BenchmarkOption.EDGES_PER_VERTEX.getOptionLongValue(cmd));
}
示例2: prepareConfiguration
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Override
protected void prepareConfiguration(GiraphConfiguration conf,
CommandLine cmd) {
conf.setVertexClass(PageRankVertex.class);
conf.setOutEdgesClass(IntNullArrayEdges.class);
conf.setCombinerClass(FloatSumCombiner.class);
conf.setVertexInputFormatClass(
PseudoRandomIntNullVertexInputFormat.class);
conf.setInt(PseudoRandomInputFormatConstants.AGGREGATE_VERTICES,
BenchmarkOption.VERTICES.getOptionIntValue(cmd));
conf.setInt(PseudoRandomInputFormatConstants.EDGES_PER_VERTEX,
BenchmarkOption.EDGES_PER_VERTEX.getOptionIntValue(cmd));
conf.setInt(PageRankVertex.SUPERSTEP_COUNT,
BenchmarkOption.SUPERSTEPS.getOptionIntValue(cmd));
conf.setFloat(PseudoRandomInputFormatConstants.LOCAL_EDGES_MIN_RATIO,
BenchmarkOption.LOCAL_EDGES_MIN_RATIO.getOptionFloatValue(cmd,
PseudoRandomInputFormatConstants.LOCAL_EDGES_MIN_RATIO_DEFAULT));
}
示例3: testBspCombiner
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* Run a sample BSP job locally with combiner and checkout output value.
*
* @throws IOException
* @throws ClassNotFoundException
* @throws InterruptedException
*/
@Test
public void testBspCombiner()
throws IOException, InterruptedException, ClassNotFoundException {
GiraphConfiguration conf = new GiraphConfiguration();
conf.setComputationClass(SimpleCombinerComputation.class);
conf.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
conf.setCombinerClass(SimpleSumCombiner.class);
GiraphJob job = prepareJob(getCallingMethodName(), conf);
assertTrue(job.run(true));
}
示例4: prepareConfiguration
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
@Override
protected void prepareConfiguration(GiraphConfiguration conf,
CommandLine cmd) {
if (BenchmarkOption.JYTHON.optionTurnedOn(cmd)) {
GiraphTypes types = new GiraphTypes();
types.inferFrom(PageRankComputation.class);
String script;
DeployType deployType;
if (BenchmarkOption.SCRIPT_PATH.optionTurnedOn(cmd)) {
deployType = DeployType.DISTRIBUTED_CACHE;
String path = BenchmarkOption.SCRIPT_PATH.getOptionValue(cmd);
Path hadoopPath = new Path(path);
Path remotePath = DistributedCacheUtils.copyAndAdd(hadoopPath, conf);
script = remotePath.toString();
} else {
deployType = DeployType.RESOURCE;
script = ReflectionUtils.getPackagePath(this) + "/page-rank.py";
}
ScriptLoader.setScriptsToLoad(conf, script, deployType, Language.JYTHON);
types.writeIfUnset(conf);
JythonUtils.init(conf, "PageRank");
} else {
conf.setComputationClass(PageRankComputation.class);
}
conf.setOutEdgesClass(IntNullArrayEdges.class);
conf.setCombinerClass(FloatSumCombiner.class);
conf.setVertexInputFormatClass(
PseudoRandomIntNullVertexInputFormat.class);
conf.setInt(PseudoRandomInputFormatConstants.AGGREGATE_VERTICES,
BenchmarkOption.VERTICES.getOptionIntValue(cmd));
conf.setInt(PseudoRandomInputFormatConstants.EDGES_PER_VERTEX,
BenchmarkOption.EDGES_PER_VERTEX.getOptionIntValue(cmd));
conf.setInt(PageRankComputation.SUPERSTEP_COUNT,
BenchmarkOption.SUPERSTEPS.getOptionIntValue(cmd));
conf.setFloat(PseudoRandomInputFormatConstants.LOCAL_EDGES_MIN_RATIO,
BenchmarkOption.LOCAL_EDGES_MIN_RATIO.getOptionFloatValue(cmd,
PseudoRandomInputFormatConstants.LOCAL_EDGES_MIN_RATIO_DEFAULT));
}
示例5: testBspCombiner
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* Run a sample BSP job locally with combiner and checkout output value.
*
* @throws IOException
* @throws ClassNotFoundException
* @throws InterruptedException
*/
@Test
public void testBspCombiner()
throws IOException, InterruptedException, ClassNotFoundException {
GiraphConfiguration conf = new GiraphConfiguration();
conf.setVertexClass(SimpleCombinerVertex.class);
conf.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
conf.setCombinerClass(SimpleSumCombiner.class);
GiraphJob job = prepareJob(getCallingMethodName(), conf);
assertTrue(job.run(true));
}
示例6: testToyData
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* A local integration test on toy data
*/
@Test
public void testToyData() throws Exception {
GiraphConfiguration conf = new GiraphConfiguration();
conf.setComputationClass(ConnectedComponentsComputation.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setCombinerClass(MinimumIntCombiner.class);
TestGraph<IntWritable, IntWritable, NullWritable> graph =
new TestGraph<IntWritable, IntWritable, NullWritable>(conf);
// a small graph with three components
graph.addVertex(new IntWritable(1), new IntWritable(1), makeEdges(2, 3))
.addVertex(new IntWritable(2), new IntWritable(2), makeEdges(1, 4, 5))
.addVertex(new IntWritable(3), new IntWritable(3), makeEdges(1, 4))
.addVertex(new IntWritable(4), new IntWritable(4),
makeEdges(2, 3, 5, 13))
.addVertex(new IntWritable(5), new IntWritable(5),
makeEdges(2, 4, 12, 13))
.addVertex(new IntWritable(12), new IntWritable(12), makeEdges(5, 13))
.addVertex(new IntWritable(13), new IntWritable(13), makeEdges(4, 5, 12))
.addVertex(new IntWritable(6), new IntWritable(6), makeEdges(7, 8))
.addVertex(new IntWritable(7), new IntWritable(7), makeEdges(6, 10, 11))
.addVertex(new IntWritable(8), new IntWritable(8), makeEdges(6, 10))
.addVertex(new IntWritable(10), new IntWritable(10), makeEdges(7, 8, 11))
.addVertex(new IntWritable(11), new IntWritable(11), makeEdges(7, 10))
.addVertex(new IntWritable(9), new IntWritable(9));
// run internally
TestGraph<IntWritable, IntWritable, NullWritable> results =
InternalVertexRunner.run(conf, graph);
SetMultimap<Integer, Integer> components = parseResults(results);
Set<Integer> componentIDs = components.keySet();
assertEquals(3, componentIDs.size());
assertTrue(componentIDs.contains(1));
assertTrue(componentIDs.contains(6));
assertTrue(componentIDs.contains(9));
Set<Integer> componentOne = components.get(1);
assertEquals(7, componentOne.size());
assertTrue(componentOne.contains(1));
assertTrue(componentOne.contains(2));
assertTrue(componentOne.contains(3));
assertTrue(componentOne.contains(4));
assertTrue(componentOne.contains(5));
assertTrue(componentOne.contains(12));
assertTrue(componentOne.contains(13));
Set<Integer> componentTwo = components.get(6);
assertEquals(5, componentTwo.size());
assertTrue(componentTwo.contains(6));
assertTrue(componentTwo.contains(7));
assertTrue(componentTwo.contains(8));
assertTrue(componentTwo.contains(10));
assertTrue(componentTwo.contains(11));
Set<Integer> componentThree = components.get(9);
assertEquals(1, componentThree.size());
assertTrue(componentThree.contains(9));
}
示例7: testToyData
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* A local integration test on toy data
*/
@Test
public void testToyData() throws Exception {
// a small graph with three components
String[] graph = new String[] {
"1 2 3",
"2 1 4 5",
"3 1 4",
"4 2 3 5 13",
"5 2 4 12 13",
"12 5 13",
"13 4 5 12",
"6 7 8",
"7 6 10 11",
"8 6 10",
"10 7 8 11",
"11 7 10",
"9" };
// run internally
// fail the first port binding attempt
GiraphConfiguration conf = new GiraphConfiguration();
GiraphConstants.FAIL_FIRST_IPC_PORT_BIND_ATTEMPT.set(conf, true);
conf.setComputationClass(ConnectedComponentsComputation.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setCombinerClass(MinimumIntCombiner.class);
conf.setVertexInputFormatClass(IntIntNullTextInputFormat.class);
conf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
Iterable<String> results = InternalVertexRunner.run(conf, graph);
SetMultimap<Integer,Integer> components = parseResults(results);
Set<Integer> componentIDs = components.keySet();
assertEquals(3, componentIDs.size());
assertTrue(componentIDs.contains(1));
assertTrue(componentIDs.contains(6));
assertTrue(componentIDs.contains(9));
Set<Integer> componentOne = components.get(1);
assertEquals(7, componentOne.size());
assertTrue(componentOne.contains(1));
assertTrue(componentOne.contains(2));
assertTrue(componentOne.contains(3));
assertTrue(componentOne.contains(4));
assertTrue(componentOne.contains(5));
assertTrue(componentOne.contains(12));
assertTrue(componentOne.contains(13));
Set<Integer> componentTwo = components.get(6);
assertEquals(5, componentTwo.size());
assertTrue(componentTwo.contains(6));
assertTrue(componentTwo.contains(7));
assertTrue(componentTwo.contains(8));
assertTrue(componentTwo.contains(10));
assertTrue(componentTwo.contains(11));
Set<Integer> componentThree = components.get(9);
assertEquals(1, componentThree.size());
assertTrue(componentThree.contains(9));
}
示例8: testToyData
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* A local integration test on toy data
*/
@Test
public void testToyData() throws Exception {
// a small graph with three components
String[] graph = new String[] {
"1 2 3",
"2 1 4 5",
"3 1 4",
"4 2 3 5 13",
"5 2 4 12 13",
"12 5 13",
"13 4 5 12",
"6 7 8",
"7 6 10 11",
"8 6 10",
"10 7 8 11",
"11 7 10",
"9" };
GiraphConfiguration conf = new GiraphConfiguration();
conf.setComputationClass(ConnectedComponentsComputation.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setCombinerClass(MinimumIntCombiner.class);
conf.setVertexInputFormatClass(IntIntNullTextInputFormat.class);
conf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
// run internally
Iterable<String> results = InternalVertexRunner.run(conf, graph);
SetMultimap<Integer,Integer> components = parseResults(results);
Set<Integer> componentIDs = components.keySet();
assertEquals(3, componentIDs.size());
assertTrue(componentIDs.contains(1));
assertTrue(componentIDs.contains(6));
assertTrue(componentIDs.contains(9));
Set<Integer> componentOne = components.get(1);
assertEquals(7, componentOne.size());
assertTrue(componentOne.contains(1));
assertTrue(componentOne.contains(2));
assertTrue(componentOne.contains(3));
assertTrue(componentOne.contains(4));
assertTrue(componentOne.contains(5));
assertTrue(componentOne.contains(12));
assertTrue(componentOne.contains(13));
Set<Integer> componentTwo = components.get(6);
assertEquals(5, componentTwo.size());
assertTrue(componentTwo.contains(6));
assertTrue(componentTwo.contains(7));
assertTrue(componentTwo.contains(8));
assertTrue(componentTwo.contains(10));
assertTrue(componentTwo.contains(11));
Set<Integer> componentThree = components.get(9);
assertEquals(1, componentThree.size());
assertTrue(componentThree.contains(9));
}
示例9: testToyData
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* A local integration test on toy data
*/
@Test
public void testToyData() throws Exception {
GiraphConfiguration conf = new GiraphConfiguration();
conf.setVertexClass(ConnectedComponentsVertex.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setCombinerClass(MinimumIntCombiner.class);
TestGraph<IntWritable, IntWritable, NullWritable, IntWritable> graph =
new TestGraph<IntWritable, IntWritable, NullWritable, IntWritable> (conf);
// a small graph with three components
graph.addVertex(new IntWritable(1), new IntWritable(1), makeEdges(2, 3))
.addVertex(new IntWritable(2), new IntWritable(2), makeEdges(1, 4, 5))
.addVertex(new IntWritable(3), new IntWritable(3), makeEdges(1, 4))
.addVertex(new IntWritable(4), new IntWritable(4),
makeEdges(2, 3, 5, 13))
.addVertex(new IntWritable(5), new IntWritable(5),
makeEdges(2, 4, 12, 13))
.addVertex(new IntWritable(12), new IntWritable(12), makeEdges(5, 13))
.addVertex(new IntWritable(13), new IntWritable(13), makeEdges(4, 5, 12))
.addVertex(new IntWritable(6), new IntWritable(6), makeEdges(7, 8))
.addVertex(new IntWritable(7), new IntWritable(7), makeEdges(6, 10, 11))
.addVertex(new IntWritable(8), new IntWritable(8), makeEdges(6, 10))
.addVertex(new IntWritable(10), new IntWritable(10), makeEdges(7, 8, 11))
.addVertex(new IntWritable(11), new IntWritable(11), makeEdges(7, 10))
.addVertex(new IntWritable(9), new IntWritable(9));
// run internally
TestGraph<IntWritable, IntWritable, NullWritable, IntWritable> results =
InternalVertexRunner.run(conf, graph);
SetMultimap<Integer,Integer> components = parseResults(results);
Set<Integer> componentIDs = components.keySet();
assertEquals(3, componentIDs.size());
assertTrue(componentIDs.contains(1));
assertTrue(componentIDs.contains(6));
assertTrue(componentIDs.contains(9));
Set<Integer> componentOne = components.get(1);
assertEquals(7, componentOne.size());
assertTrue(componentOne.contains(1));
assertTrue(componentOne.contains(2));
assertTrue(componentOne.contains(3));
assertTrue(componentOne.contains(4));
assertTrue(componentOne.contains(5));
assertTrue(componentOne.contains(12));
assertTrue(componentOne.contains(13));
Set<Integer> componentTwo = components.get(6);
assertEquals(5, componentTwo.size());
assertTrue(componentTwo.contains(6));
assertTrue(componentTwo.contains(7));
assertTrue(componentTwo.contains(8));
assertTrue(componentTwo.contains(10));
assertTrue(componentTwo.contains(11));
Set<Integer> componentThree = components.get(9);
assertEquals(1, componentThree.size());
assertTrue(componentThree.contains(9));
}
示例10: prepareConfiguration
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* Set vertex edges, input format, partitioner classes and related parameters
* based on command-line arguments.
*
* @param cmd Command line arguments
* @param configuration Giraph job configuration
*/
protected void prepareConfiguration(GiraphConfiguration configuration,
CommandLine cmd) {
configuration.setVertexClass(WeightedPageRankVertex.class);
int edgesClassOption = EDGES_CLASS.getOptionIntValue(cmd, 1);
switch (edgesClassOption) {
case 0:
configuration.setOutEdgesClass(LongDoubleArrayEdges.class);
break;
case 1:
configuration.setOutEdgesClass(ByteArrayEdges.class);
break;
case 2:
configuration.setOutEdgesClass(ByteArrayEdges.class);
configuration.useUnsafeSerialization(true);
break;
case 3:
configuration.setOutEdgesClass(ArrayListEdges.class);
break;
case 4:
configuration.setOutEdgesClass(HashMapEdges.class);
break;
default:
LOG.info("Unknown OutEdges class, " +
"defaulting to LongDoubleArrayEdges");
configuration.setOutEdgesClass(LongDoubleArrayEdges.class);
}
LOG.info("Using edges class " +
GiraphConstants.VERTEX_EDGES_CLASS.get(configuration));
if (COMBINER_TYPE.getOptionIntValue(cmd, 1) == 1) {
configuration.setCombinerClass(DoubleSumCombiner.class);
}
if (EDGE_INPUT.optionTurnedOn(cmd)) {
configuration.setEdgeInputFormatClass(PseudoRandomEdgeInputFormat.class);
} else {
configuration.setVertexInputFormatClass(
PseudoRandomVertexInputFormat.class);
}
configuration.setLong(
PseudoRandomInputFormatConstants.AGGREGATE_VERTICES,
BenchmarkOption.VERTICES.getOptionLongValue(cmd));
configuration.setLong(
PseudoRandomInputFormatConstants.EDGES_PER_VERTEX,
BenchmarkOption.EDGES_PER_VERTEX.getOptionLongValue(cmd));
configuration.setFloat(
PseudoRandomInputFormatConstants.LOCAL_EDGES_MIN_RATIO,
BenchmarkOption.LOCAL_EDGES_MIN_RATIO.getOptionFloatValue(cmd,
PseudoRandomInputFormatConstants.LOCAL_EDGES_MIN_RATIO_DEFAULT));
if (OUTPUT_FORMAT.getOptionIntValue(cmd, -1) == 0) {
LOG.info("Using vertex output format class " +
JsonBase64VertexOutputFormat.class.getName());
configuration.setVertexOutputFormatClass(
JsonBase64VertexOutputFormat.class);
}
if (PARTITIONER.getOptionIntValue(cmd, 0) == 1) {
configuration.setGraphPartitionerFactoryClass(
SimpleLongRangePartitionerFactory.class);
}
configuration.setInt(WeightedPageRankVertex.SUPERSTEP_COUNT,
BenchmarkOption.SUPERSTEPS.getOptionIntValue(cmd));
}
示例11: testToyData
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* A local integration test on toy data
*/
@Test
public void testToyData() throws Exception {
// a small graph with three components
String[] graph = new String[] {
"1 2 3",
"2 1 4 5",
"3 1 4",
"4 2 3 5 13",
"5 2 4 12 13",
"12 5 13",
"13 4 5 12",
"6 7 8",
"7 6 10 11",
"8 6 10",
"10 7 8 11",
"11 7 10",
"9" };
GiraphConfiguration conf = new GiraphConfiguration();
conf.setVertexClass(ConnectedComponentsVertex.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setCombinerClass(MinimumIntCombiner.class);
conf.setVertexInputFormatClass(IntIntNullTextInputFormat.class);
conf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
// run internally
Iterable<String> results = InternalVertexRunner.run(conf, graph);
SetMultimap<Integer,Integer> components = parseResults(results);
Set<Integer> componentIDs = components.keySet();
assertEquals(3, componentIDs.size());
assertTrue(componentIDs.contains(1));
assertTrue(componentIDs.contains(6));
assertTrue(componentIDs.contains(9));
Set<Integer> componentOne = components.get(1);
assertEquals(7, componentOne.size());
assertTrue(componentOne.contains(1));
assertTrue(componentOne.contains(2));
assertTrue(componentOne.contains(3));
assertTrue(componentOne.contains(4));
assertTrue(componentOne.contains(5));
assertTrue(componentOne.contains(12));
assertTrue(componentOne.contains(13));
Set<Integer> componentTwo = components.get(6);
assertEquals(5, componentTwo.size());
assertTrue(componentTwo.contains(6));
assertTrue(componentTwo.contains(7));
assertTrue(componentTwo.contains(8));
assertTrue(componentTwo.contains(10));
assertTrue(componentTwo.contains(11));
Set<Integer> componentThree = components.get(9);
assertEquals(1, componentThree.size());
assertTrue(componentThree.contains(9));
}
示例12: testToyData
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* A local integration test on toy data
*/
@Test
public void testToyData() throws Exception {
// a small graph with three components
String[] graph = new String[] {
"1 2 3",
"2 1 4 5",
"3 1 4",
"4 2 3 5 13",
"5 2 4 12 13",
"12 5 13",
"13 4 5 12",
"6 7 8",
"7 6 10 11",
"8 6 10",
"10 7 8 11",
"11 7 10",
"9" };
// run internally
// fail the first port binding attempt
GiraphConfiguration conf = new GiraphConfiguration();
GiraphConstants.FAIL_FIRST_IPC_PORT_BIND_ATTEMPT.set(conf, true);
conf.setVertexClass(ConnectedComponentsVertex.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setCombinerClass(MinimumIntCombiner.class);
conf.setVertexInputFormatClass(IntIntNullTextInputFormat.class);
conf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
Iterable<String> results = InternalVertexRunner.run(conf, graph);
SetMultimap<Integer,Integer> components = parseResults(results);
Set<Integer> componentIDs = components.keySet();
assertEquals(3, componentIDs.size());
assertTrue(componentIDs.contains(1));
assertTrue(componentIDs.contains(6));
assertTrue(componentIDs.contains(9));
Set<Integer> componentOne = components.get(1);
assertEquals(7, componentOne.size());
assertTrue(componentOne.contains(1));
assertTrue(componentOne.contains(2));
assertTrue(componentOne.contains(3));
assertTrue(componentOne.contains(4));
assertTrue(componentOne.contains(5));
assertTrue(componentOne.contains(12));
assertTrue(componentOne.contains(13));
Set<Integer> componentTwo = components.get(6);
assertEquals(5, componentTwo.size());
assertTrue(componentTwo.contains(6));
assertTrue(componentTwo.contains(7));
assertTrue(componentTwo.contains(8));
assertTrue(componentTwo.contains(10));
assertTrue(componentTwo.contains(11));
Set<Integer> componentThree = components.get(9);
assertEquals(1, componentThree.size());
assertTrue(componentThree.contains(9));
}