Difference between revisions of " Blueprints API remote mode"
From Blazegraph
(→Code listing) |
(→Create a repository) |
||
Line 46: | Line 46: | ||
<pre> | <pre> | ||
− | final BigdataGraph graph = new BigdataGraphClient("http://localhost:9999/ | + | final BigdataGraph graph = new BigdataGraphClient("http://localhost:9999/blazegraph/sparql"); |
</pre> | </pre> | ||
Latest revision as of 05:08, 21 October 2016
Note that Blazegraph 2.0.0 released an Apache TinkerPop™ 3 implementation.
Contents
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/blazegraph/ 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/blazegraph/sparql"); 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/blazegraph/sparql");
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]