本文整理汇总了Java中org.apache.giraph.conf.GiraphConfiguration.hasVertexOutputFormat方法的典型用法代码示例。如果您正苦于以下问题:Java GiraphConfiguration.hasVertexOutputFormat方法的具体用法?Java GiraphConfiguration.hasVertexOutputFormat怎么用?Java GiraphConfiguration.hasVertexOutputFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.giraph.conf.GiraphConfiguration
的用法示例。
在下文中一共展示了GiraphConfiguration.hasVertexOutputFormat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
* Attempts to run the vertex internally in the current JVM, reading from and
* writing to a temporary folder on local disk. Will start its own zookeeper
* instance.
*
* @param conf GiraphClasses specifying which types to use
* @param checkpointsDir if set, will use this folder
* for storing checkpoints.
* @param tmpDir file path for storing temporary files.
* @return linewise output data, or null if job fails
* @throws Exception if anything goes wrong
*/
public static Iterable<String> run(
GiraphConfiguration conf,
String checkpointsDir,
File tmpDir) throws Exception {
String ns = conf.get(HBaseGraphConfiguration.Keys.GRAPH_NAMESPACE);
String prefix = conf.get(HBaseGraphConfiguration.Keys.GRAPH_TABLE_PREFIX);
String tablePrefix = (ns != null ? ns + TableName.NAMESPACE_DELIM : "") + (prefix != null ? prefix : "");
conf.set(Constants.EDGE_INPUT_TABLE, tablePrefix + Constants.EDGES);
conf.set(Constants.VERTEX_INPUT_TABLE, tablePrefix + Constants.VERTICES);
File outputDir = FileUtils.createTempDir(tmpDir, "output");
File zkDir = FileUtils.createTempDir(tmpDir, "_bspZooKeeper");
File zkMgrDir = FileUtils.createTempDir(tmpDir, "_defaultZkManagerDir");
conf.setWorkerConfiguration(1, 1, 100.0f);
GiraphConstants.SPLIT_MASTER_WORKER.set(conf, false);
GiraphConstants.LOCAL_TEST_MODE.set(conf, true);
conf.set(GiraphConstants.ZOOKEEPER_DIR, zkDir.toString());
GiraphConstants.ZOOKEEPER_MANAGER_DIRECTORY.set(conf,
zkMgrDir.toString());
if (checkpointsDir == null) {
checkpointsDir = FileUtils.createTempDir(
tmpDir, "_checkpoints").toString();
}
GiraphConstants.CHECKPOINT_DIRECTORY.set(conf, checkpointsDir);
// Create and configure the job to run the vertex
GiraphJob job = new GiraphJob(conf, conf.getComputationName());
Job internalJob = job.getInternalJob();
//FileOutputFormatUtil.setOutputPath(job.getInternalJob(),
// new Path(outputDir.toString()));
internalJob.getConfiguration().set("mapred.output.dir", outputDir.toString());
// Configure a local zookeeper instance
ZookeeperConfig qpConfig = configLocalZooKeeper(zkDir);
boolean success = runZooKeeperAndJob(qpConfig, job);
if (!success) {
return null;
}
File outFile = new File(outputDir, "part-m-00000");
if (conf.hasVertexOutputFormat() && outFile.canRead()) {
return Files.readLines(outFile, Charsets.UTF_8);
} else {
return ImmutableList.of();
}
}