【问题标题】:How to write and run apache Giraph Custom code?如何编写和运行 apache Giraph 自定义代码?
【发布时间】:2015-05-29 11:48:05
【问题描述】:

从过去 10 天开始,我一直在研究 Giraph。我知道如何在 Giraph 中安装和执行给定的示例。但是我想设计自己的自定义代码,所以我需要你的帮助。如果有人完成了这个,请告诉我并给出一些想法。

【问题讨论】:

    标签: java giraph


    【解决方案1】:

    您需要创建一个新项目、一个包 foo 和该包中的一个类 foo1。该项目必须引用 giraph-core jar 文件。类 foo1 必须扩展类 AbstractComputation。您应该覆盖 AbstractComputation 的计算函数。在计算功能中,您将基于面向顶点的范例开发自己的图算法。

    有关如何实现自己的算法的更多信息,您可以参考 giraph 的 giraph-examples 包中提供的示例,如 SimpleConnectedComponents.java 和 SingleSourceShortestPaths.java。

    实现 foo1 后,您应该从项目中创建一个 jar 文件,并使用 -libjars 参数将此 jar 文件传递​​到您的命令中。

    【讨论】:

    • 非常感谢您的快速响应。如何在我的命令中使用 -libjars 我正在使用 hadoop jar /usr/local/giraph/giraph-examples/target/giraph-examples-1.2.0- SNAPSHOT-for-hadoop-2.7.0-jar-with-dependencies.jar org.apache.giraph.GiraphRunner org.apache.giraph.examples.SimpleShortestPathsComputation -vif org.apache.giraph.io.formats.JsonLongDoubleFloatDoubleVertexInputFormat -vip /tiny_graph .txt -vof org.apache.giraph.io.formats.IdWithValueTextOutputFormat -op /shortestpaths -w 1 -ca giraph.SplitMasterWorker=false 运行它。你能给我一些示例代码吗?
    • hadoop jar /usr/local/giraph/giraph-examples/target/giraph-examples-1.2.0-SNAPSHOT-for-hado‌​op-2.7.0-jar-with-dependencies.jar org.apache.giraph.GiraphRunner -libjars [path-to-your-jar-file]/foo.jar foo.foo1 -vif org.apache.giraph.io.formats.JsonLongDoubleFloatDoubleVertexInputFormat -vip /tiny_graph.txt -vof org. apache.giraph.io.formats.IdWithValueTextOutputFormat -op /shortestpaths -w 1 -ca giraph.SplitMasterWorker=false
    • 嗨,谢谢...但是当我尝试这样做时,它显示错误为 Not a valid JAR: /usr/local/giraph/giraph-examples/target/giraph-examples-1.2.0 -SNAPSHOT-for-hado‌​‌​op-2.7.0-jar-with-dependencies.jar
    • hadoop jar /usr/local/giraph/giraph-examples/target/giraph-examples-1.2.0-SNAPSHOT-for-hado‌​‌​op-2.7.0-jar-with-dependencies .jar org.apache.giraph.GiraphRunner -libjars /home/GiraphCustom010615/example.jar giraphsample.MaxVal -vif org.apache.giraph.io.formats.JsonLongDoubleFloatDoubleVertexInputFormat -vip /tiny_graph.txt -vof org.apache.giraph.io .formats.IdWithValueTextOutputFormat -op /shortestpaths -w 1 -ca giraph.SplitMasterWorker=false 这里example.jar是我的jar文件,giraphsample是包,类是MaxVal
    • 试试这个:hadoop jar /usr/local/giraph/giraph-examples/target/giraph-examples-1.2.0-SNAPSHOT-for-hado‌​‌​‌​op-2.7.0- jar-with-dependencies.jar org.apache.giraph.GiraphRunner -libjars /home/GiraphCustom010615/example.jar,/usr/local/giraph/giraph-examples/target/giraph-examples-1.2.0-SNAPSHOT-for- hado‌​‌​‌​op-2.7.0-jar-with-dependencies.jar giraphsample.MaxVal -vif org.apache.giraph.io.formats.JsonLongDoubleFloatDoubleVertexInputFormat -vip /tiny_graph.txt -vof org.apache.giraph.io .formats.IdWithValueTextOutputFormat -op /shortestpaths -w 1 -ca giraph.SplitMasterWorker=false 这里是 example.jar
    猜你喜欢
    • 2016-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多