Last active
January 8, 2016 08:38
-
-
Save seralf/9599273 to your computer and use it in GitHub Desktop.
Testing virtuoso with Tinkerpop, via Sail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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