Using Blueprints

From Blazegraph
Revision as of 19:35, 14 April 2015 by Brad Bebee (Talk | contribs) (Getting Started with Gremlin)

Jump to: navigation, search

Using Blueprints with Blazegraph

Blueprints is an open-source property graph model interface useful for writing applications on top of a graph database. Gremlin is a domain specific language for traversing property graphs that comes with an excellent REPL useful for interacting with a Blueprints database. Rexster exposes a Blueprints database as a web service and comes with a web-based workbench application called DogHouse.

Getting Started with Gremlin

To get started with Blazegraph via Blueprints, Gremlin, and Rexster, start by getting your Blazegraph server running per the instructions NanoSparqlServer.

Blazegraph comes with an ant task to download, unpack, and configure a Gremlin console for use with Blazegraph:

ant gremlin

You can then start the Gremlin console and begin interacting with Blazegraph:

                  (o o) 

From Gremlin (or Blueprints code) you can then connect to the Blazegraph server and upload the sample GraphML file:

gremlin> import com.bigdata.blueprints.* 
gremlin> g = new BigdataGraphClient("http://localhost:9999/bigdata") 
gremlin> g.loadGraphML("./ant-build/gremlin-groovy-2.5.0/data/graph-example-1.xml") 
gremlin> g.V gremlin> g.E 

Using Embedded Instance

To get started using Blazegraph with an embedded

         private static final String journalFile = "/tmp/blazegraph/blueprints.jnl";

         public void useEmbeddedBlazegraph()

                final BigdataGraph g = new BigdataGraphEmbedded(getOrCreateRepository(journalFile));
                final String testFile = "graph-example-1.xml";

                try {
				GraphMLReader.inputGraph(graph, this.getClass().getResourceAsStream(testFile));
				for (Vertex v : graph.getVertices()) {
				for (Edge e : graph.getEdges()) {
	         } catch (IOException e) {


         public BigdataSailRepository getOrCreateRepository(String journalFile) {

		final java.util.Properties props = new java.util.Properties();
		BigdataSailRepository repo = null;

		 * Lax edges allows us to use non-unique edge identifiers
		props.setProperty(BigdataGraph.Options.LAX_EDGES, "true");

		 * SPARQL bottom up evaluation semantics can have performance impact.

		if (journalFile == null || !new File(journalFile).exists()) {

			 * No journal specified or journal does not exist yet at specified
			 * location. Create a new store. (If journal== null an in-memory
			 * store will be created.
			repo = BigdataSailFactory.createRepository(props, journalFile,
					Option.TextIndex);// , Option.RDR);

		} else {

			 * Journal already exists at specified location. Open existing
			 * store.
			repo = BigdataSailFactory.openRepository(journalFile);

		try {
		} catch (RepositoryException e) {
			// TODO Auto-generated catch block
		return repo;

Using a Remote Instance