graph-databasesblazegraphbigdata

GAS API implementation and usage


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?


Solution

  • 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.