GAS API implementation and usage

你说的曾经没有我的故事 提交于 2019-12-10 11:20:05

问题


I'm trying to learn and use the GAS API to implement a Random Walk over my database, associating every visited vertex to the starting vertex.

I'm having some issues understanding how I can manage to do this; I've been reviewing the PATHS, BFS, PR, and other GAS classes as examples, but I'm not quite sure how to start.

I think my implementation should extend BaseGASProgram and implement the needed methods. Also, as iterative, the frontier contains all the vertexes of the current iteration. The concept of predecessor is also clear to me.

But I don't think that I understand very well the Gather, Apply, Scatter philosophy and how to distribute the Random Walk over these three concepts.

Also, once I implement my code, how do I call it? How do I even call the already implemented algorithms (PR, SSSP, BFS, etc.) inside my code? Should I instantiate an SSSP object and then what? Or GASContext? GASRunnerBase?


回答1:


Take a look at the TestBFS class in the bigdata-gas package:

final IGASEngine gasEngine = getGraphFixture()
        .newGASEngine(1/* nthreads */);

try {

    final SailConnection cxn = getGraphFixture().getSail()
            .getConnection();

    try {

        final IGraphAccessor graphAccessor = getGraphFixture()
                .newGraphAccessor(cxn);

        final IGASContext<BFS.VS, BFS.ES, Void> gasContext = gasEngine
                .newGASContext(graphAccessor, new BFS());

        final IGASState<BFS.VS, BFS.ES, Void> gasState = gasContext
                .getGASState();

        // Initialize the froniter.
        gasState.setFrontier(gasContext, p.getMike());

        // Converge.
        gasContext.call();

[snip]

To use it outside of the test case context, you need to create a SailConnection of some sort. See the blazegraph-samples GitHub project for examples. Then you need to create a SAILGASEngine. This should get you started in terms of calling the GASEngine directly at the Java layer.



来源:https://stackoverflow.com/questions/36261303/gas-api-implementation-and-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!