Skip to content

Instantly share code, notes, and snippets.

@seralf
Last active January 8, 2016 08:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seralf/9599273 to your computer and use it in GitHub Desktop.
Save seralf/9599273 to your computer and use it in GitHub Desktop.
Testing virtuoso with Tinkerpop, via Sail
<!-- fortytwo -->
<dependency>
<groupId>net.fortytwo.sesametools</groupId>
<artifactId>repository-sail</artifactId>
<version>1.8-SNAPSHOT</version>
</dependency>
<!-- tinkerpop -->
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-sail-graph</artifactId>
<version>2.4.0</version>
</dependency>
...
<repository>
<id>fortytwo</id>
<name>fortytwo.net Maven repository</name>
<url>http://fortytwo.net/maven2</url>
</repository>
public class TestTinkerpopVirtuosoSPARQL {
public static void main(String[] args) throws Exception {
Graph graph = new SparqlRepositorySailGraph("http://localhost:8890/sparql");
int i = 0;
Iterable<Edge> edges = graph.getEdges();
for (Edge edge : edges) {
System.out.println(edge);
i++;
if (i > 100)
break; // we consider only the first 100 edges (relationships)
}
graph.shutdown();
}
}
package sesame.esempi;
import net.fortytwo.sesametools.reposail.RepositorySail;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.sail.Sail;
import virtuoso.sesame2.driver.VirtuosoRepository;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.impls.sail.SailGraph;
public class TestVirtuosoTinkerpop {
public static void main(String[] args) throws Exception {
Repository repository = new VirtuosoRepository("jdbc:virtuoso://localhost:1111", "dba", "dba");
RepositoryConnection conn = repository.getConnection();
repository.initialize();
Sail sail = new RepositorySail(repository);
Graph graph = new SailGraph(sail);
int i = 0;
Iterable<Edge> edges = graph.getEdges();
for (Edge edge : edges) {
System.out.println(edge);
i++;
if (i > 100)
break; // we consider only the first 100 edges (relationships)
}
conn.close();
// sail.shutDown(); // just for reference...
repository.shutDown(); // just for reference...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment