本文整理汇总了Java中org.apache.giraph.conf.GiraphConfiguration.setFloat方法的典型用法代码示例。如果您正苦于以下问题:Java GiraphConfiguration.setFloat方法的具体用法?Java GiraphConfiguration.setFloat怎么用?Java GiraphConfiguration.setFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.giraph.conf.GiraphConfiguration
的用法示例。
在下文中一共展示了GiraphConfiguration.setFloat方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: computeResults
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
private Map<Integer, Integer> computeResults(String[] graph,
int partitionCount, int maxIterations, float capacityTreshold,
int maxStabilization, long seed) throws Exception {
GiraphConfiguration conf = getConfiguration();
conf.setInt(ARPComputation.NUMBER_OF_PARTITIONS, partitionCount);
conf.setInt(ARPComputation.NUMBER_OF_ITERATIONS, maxIterations);
conf.setFloat(ARPComputation.CAPACITY_THRESHOLD, capacityTreshold);
conf.setInt(ARPComputation.NUMBER_OF_STABLE_ITERATIONS, maxStabilization);
conf.setLong(ARPComputation.SEED, seed);
Iterable<String> results = InternalVertexRunner.run(conf, graph);
return parseResults(results);
}
示例3: testToyData
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* A local integration test on toy data
*/
@Test
public void testToyData() throws Exception {
// A small graph
String[] graph = new String[] {
"1 4 2 3",
"2 1",
"4 3 2",
"5 2 4"
};
GiraphConfiguration conf = new GiraphConfiguration();
conf.setInt(RandomWalkWithRestartComputation.MAX_SUPERSTEPS, 50);
conf.setFloat(
RandomWalkWithRestartComputation.TELEPORTATION_PROBABILITY, 0.15f);
conf.setComputationClass(PageRankComputation.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setVertexInputFormatClass(LongDoubleNullTextInputFormat.class);
conf.setVertexOutputFormatClass(
VertexWithDoubleValueNullEdgeTextOutputFormat.class);
conf.setWorkerContextClass(RandomWalkWorkerContext.class);
conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
// Run internally
Iterable<String> results = InternalVertexRunner.run(conf, graph);
Map<Long, Double> steadyStateProbabilities =
RandomWalkTestUtils.parseSteadyStateProbabilities(results);
assertEquals(0.28159076008518047, steadyStateProbabilities.get(1l),
RandomWalkTestUtils.EPSILON);
assertEquals(0.2514648601529863, steadyStateProbabilities.get(2l),
RandomWalkTestUtils.EPSILON);
assertEquals(0.22262961972286327, steadyStateProbabilities.get(3l),
RandomWalkTestUtils.EPSILON);
assertEquals(0.17646783276703806, steadyStateProbabilities.get(4l),
RandomWalkTestUtils.EPSILON);
assertEquals(0.06784692727193153, steadyStateProbabilities.get(5l),
RandomWalkTestUtils.EPSILON);
}
示例4: testToyData
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* A local integration test on toy data
*/
@Test
public void testToyData() throws Exception {
// A small graph
String[] graph = new String[] { "12 34 56", "34 78", "56 34 78", "78 34" };
GiraphConfiguration conf = new GiraphConfiguration();
conf.setInt(RandomWalkWithRestartComputation.SOURCE_VERTEX, 12);
conf.setInt(RandomWalkWithRestartComputation.MAX_SUPERSTEPS, 30);
conf.setFloat(
RandomWalkWithRestartComputation.TELEPORTATION_PROBABILITY, 0.25f);
conf.setComputationClass(RandomWalkWithRestartComputation.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setVertexInputFormatClass(LongDoubleDoubleTextInputFormat.class);
conf.setVertexOutputFormatClass(
VertexWithDoubleValueDoubleEdgeTextOutputFormat.class);
conf.setWorkerContextClass(RandomWalkWorkerContext.class);
conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
// Run internally
Iterable<String> results = InternalVertexRunner.run(conf, graph);
Map<Long, Double> steadyStateProbabilities =
RandomWalkTestUtils.parseSteadyStateProbabilities(results);
// values computed with external software
// 0.25, 0.354872, 0.09375, 0.301377
assertEquals(0.25, steadyStateProbabilities.get(12L), RandomWalkTestUtils.EPSILON);
assertEquals(0.354872, steadyStateProbabilities.get(34L),
RandomWalkTestUtils.EPSILON);
assertEquals(0.09375, steadyStateProbabilities.get(56L), RandomWalkTestUtils.EPSILON);
assertEquals(0.301377, steadyStateProbabilities.get(78L),
RandomWalkTestUtils.EPSILON);
}
示例5: testWeightedGraph
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* A local integration test on toy data
*/
@Test
public void testWeightedGraph() throws Exception {
// A small graph
String[] graph =
new String[] { "12 34:0.1 56:0.9", "34 78:0.9 56:0.1",
"56 12:0.1 34:0.8 78:0.1", "78 34:1.0" };
GiraphConfiguration conf = new GiraphConfiguration();
conf.setInt(RandomWalkWithRestartComputation.SOURCE_VERTEX, 12);
conf.setInt(RandomWalkWithRestartComputation.MAX_SUPERSTEPS, 30);
conf.setFloat(
RandomWalkWithRestartComputation.TELEPORTATION_PROBABILITY, 0.15f);
conf.setComputationClass(RandomWalkWithRestartComputation.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setVertexInputFormatClass(
NormalizingLongDoubleDoubleTextInputFormat.class);
conf.setVertexOutputFormatClass(
VertexWithDoubleValueDoubleEdgeTextOutputFormat.class);
conf.setWorkerContextClass(RandomWalkWorkerContext.class);
conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
// Run internally
Iterable<String> results = InternalVertexRunner.run(conf, graph);
Map<Long, Double> steadyStateProbabilities =
RandomWalkTestUtils.parseSteadyStateProbabilities(results);
// values computed with external software
// 0.163365, 0.378932, 0.156886, 0.300816
assertEquals(0.163365, steadyStateProbabilities.get(12L),
RandomWalkTestUtils.EPSILON);
assertEquals(0.378932, steadyStateProbabilities.get(34L),
RandomWalkTestUtils.EPSILON);
assertEquals(0.156886, steadyStateProbabilities.get(56L),
RandomWalkTestUtils.EPSILON);
assertEquals(0.300816, steadyStateProbabilities.get(78L),
RandomWalkTestUtils.EPSILON);
}
示例6: 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));
}
示例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
String[] graph = new String[] {
"1 4 2 3",
"2 1",
"4 3 2",
"5 2 4"
};
GiraphConfiguration conf = new GiraphConfiguration();
conf.setInt(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, 50);
conf.setFloat(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, 0.15f);
conf.setVertexClass(PageRankVertex.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setVertexInputFormatClass(LongDoubleNullTextInputFormat.class);
conf.setVertexOutputFormatClass(
VertexWithDoubleValueNullEdgeTextOutputFormat.class);
conf.setWorkerContextClass(RandomWalkWorkerContext.class);
conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
// Run internally
Iterable<String> results = InternalVertexRunner.run(conf, graph);
Map<Long, Double> steadyStateProbabilities =
RandomWalkTestUtils.parseSteadyStateProbabilities(results);
assertEquals(0.28159076008518047, steadyStateProbabilities.get(1l),
RandomWalkTestUtils.EPSILON);
assertEquals(0.2514648601529863, steadyStateProbabilities.get(2l),
RandomWalkTestUtils.EPSILON);
assertEquals(0.22262961972286327, steadyStateProbabilities.get(3l),
RandomWalkTestUtils.EPSILON);
assertEquals(0.17646783276703806, steadyStateProbabilities.get(4l),
RandomWalkTestUtils.EPSILON);
assertEquals(0.06784692727193153, steadyStateProbabilities.get(5l),
RandomWalkTestUtils.EPSILON);
}
示例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
String[] graph = new String[] { "12 34 56", "34 78", "56 34 78", "78 34" };
GiraphConfiguration conf = new GiraphConfiguration();
conf.setInt(RandomWalkWithRestartVertex.SOURCE_VERTEX, 12);
conf.setInt(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, 30);
conf.setFloat(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, 0.25f);
conf.setVertexClass(RandomWalkWithRestartVertex.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setVertexInputFormatClass(LongDoubleDoubleTextInputFormat.class);
conf.setVertexOutputFormatClass(
VertexWithDoubleValueDoubleEdgeTextOutputFormat.class);
conf.setWorkerContextClass(RandomWalkWorkerContext.class);
conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
// Run internally
Iterable<String> results = InternalVertexRunner.run(conf, graph);
Map<Long, Double> steadyStateProbabilities =
RandomWalkTestUtils.parseSteadyStateProbabilities(results);
// values computed with external software
// 0.25, 0.354872, 0.09375, 0.301377
assertEquals(0.25, steadyStateProbabilities.get(12L), RandomWalkTestUtils.EPSILON);
assertEquals(0.354872, steadyStateProbabilities.get(34L),
RandomWalkTestUtils.EPSILON);
assertEquals(0.09375, steadyStateProbabilities.get(56L), RandomWalkTestUtils.EPSILON);
assertEquals(0.301377, steadyStateProbabilities.get(78L),
RandomWalkTestUtils.EPSILON);
}
示例9: testWeightedGraph
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* A local integration test on toy data
*/
@Test
public void testWeightedGraph() throws Exception {
// A small graph
String[] graph =
new String[] { "12 34:0.1 56:0.9", "34 78:0.9 56:0.1",
"56 12:0.1 34:0.8 78:0.1", "78 34:1.0" };
GiraphConfiguration conf = new GiraphConfiguration();
conf.setInt(RandomWalkWithRestartVertex.SOURCE_VERTEX, 12);
conf.setInt(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, 30);
conf.setFloat(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, 0.15f);
conf.setVertexClass(RandomWalkWithRestartVertex.class);
conf.setOutEdgesClass(ByteArrayEdges.class);
conf.setVertexInputFormatClass(
NormalizingLongDoubleDoubleTextInputFormat.class);
conf.setVertexOutputFormatClass(
VertexWithDoubleValueDoubleEdgeTextOutputFormat.class);
conf.setWorkerContextClass(RandomWalkWorkerContext.class);
conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
// Run internally
Iterable<String> results = InternalVertexRunner.run(conf, graph);
Map<Long, Double> steadyStateProbabilities =
RandomWalkTestUtils.parseSteadyStateProbabilities(results);
// values computed with external software
// 0.163365, 0.378932, 0.156886, 0.300816
assertEquals(0.163365, steadyStateProbabilities.get(12L),
RandomWalkTestUtils.EPSILON);
assertEquals(0.378932, steadyStateProbabilities.get(34L),
RandomWalkTestUtils.EPSILON);
assertEquals(0.156886, steadyStateProbabilities.get(56L),
RandomWalkTestUtils.EPSILON);
assertEquals(0.300816, steadyStateProbabilities.get(78L),
RandomWalkTestUtils.EPSILON);
}
示例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.setComputationClass(WeightedPageRankComputation.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(WeightedPageRankComputation.SUPERSTEP_COUNT,
BenchmarkOption.SUPERSTEPS.getOptionIntValue(cmd));
}
示例11: 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));
}