Skip to content

Blueprints_API_remote_mode

Brad Bebee edited this page Feb 13, 2020 · 1 revision

Introduction

A sample Java application demonstrates using Blazegraph™ in remote mode with Blueprints. See Using Blueprints with Blazegraph tutorial for more details. This project was created in Eclipse IDE with Maven. You need to have a NanoSparqlServer running (see Quick Start instructions). Endpoint http://localhost:9999/bigdata/ is used for remote repository connection in the application.

Download a sample application

You can download the sample-blueprints-remote application here.

Code listing

package sample.blueprints.remote;

import org.apache.log4j.Logger;

import com.bigdata.blueprints.BigdataGraph;
import com.bigdata.blueprints.BigdataGraphClient;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Vertex;


public class SampleBlazegraphBlueprintsRemote {

    protected static final Logger log = Logger.getLogger(SampleBlazegraphBlueprintsRemote.class);

    public static void main(String[] args) throws Exception {

        final BigdataGraph graph = new BigdataGraphClient("http://localhost:9999/bigdata");
        try {
            graph.loadGraphML(SampleBlazegraphBlueprintsRemote.class.getResource("/graph-example-1.xml").getFile());
            for (Vertex v : graph.getVertices()) {
                log.info(v);
            }
            for (Edge e : graph.getEdges()) {
                log.info(e);
            }
        } finally {
            graph.shutdown();
        }
    }
}

Comments

Create a repository

   final BigdataGraph graph = new BigdataGraphClient("http://localhost:9999/bigdata");

Load data

graph.loadGraphML(SampleBlazegraphBlueprintsRemote.class.getResource("/graph-example-1.xml").getFile());

Get data from a repository

               for (Vertex v : graph.getVertices()) {
            log.info(v);
        }
        for (Edge e : graph.getEdges()) {
            log.info(e);
        }

Program output

New service class org.openrdf.query.resultio.sparqljson.SPARQLResultsJSONWriterFactory replaces existing service class com.bigdata.rdf.rio.json.BigdataSPARQLResultsJSONWriterFactory
New service class org.openrdf.query.resultio.sparqljson.SPARQLResultsJSONParserFactory replaces existing service class com.bigdata.rdf.rio.json.BigdataSPARQLResultsJSONParserFactory
v[1]
v[2]
v[3]
v[4]
v[5]
v[6]
e[7][1->2]
e[8][1->4]
e[9][1->3]
e[10][4->5]
e[11][4->3]
e[12][6->3]
Clone this wiki locally