Skip to content

Instantly share code, notes, and snippets.

@datablend
Created July 16, 2011 09:58
Show Gist options
  • Save datablend/1086222 to your computer and use it in GitHub Desktop.
Save datablend/1086222 to your computer and use it in GitHub Desktop.
// Create the sail graph database
graph = new MyNeo4jGraph("var/flights", 100000);
graph.setTransactionMode(TransactionalGraph.Mode.MANUAL);
sail = new GraphSail(graph);
// Initialize the sail store
sail.initialize();
// Get the sail repository connection
connection = new SailRepository(sail).getConnection();
// Import the data
connection.add(getResource("sneeair.rdf"), null, RDFFormat.RDFXML);
// Execute SPARQL query
TupleQuery durationquery = connection.prepareTupleQuery(QueryLanguage.SPARQL,
"PREFIX io: <http://www.daml.org/2001/06/itinerary/itinerary-ont#> " +
"PREFIX fl: <http://www.snee.com/ns/flights#> " +
"SELECT ?number ?departure ?destination " +
"WHERE { " +
"?flight io:flight ?number . " +
"?flight fl:flightFromCityName ?departure . " +
"?flight fl:flightToCityName ?destination . " +
"?flight io:duration \"1:35\" . " +
"}");
TupleQueryResult result = durationquery.evaluate();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment