use of org.eclipse.rdf4j.sail.nativerdf.NativeStore in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Query method createNativeIntelligentGraphRepository.
/**
* Creates the native intelligent graph repository.
*
* @param dir the dir
* @return the org.eclipse.rdf 4 j.repository. repository
* @throws IOException Signals that an I/O exception has occurred.
* @throws SailConfigException the sail config exception
*/
public static org.eclipse.rdf4j.repository.Repository createNativeIntelligentGraphRepository(String dir) throws IOException, SailConfigException {
File dataDir = new File(dir);
FileUtils.deleteDirectory(dataDir);
IntelligentGraphConfig intelligentGraphConfig = new IntelligentGraphConfig();
IntelligentGraphFactory intelligentGraphFactory = new IntelligentGraphFactory();
IntelligentGraphSail intelligentGraphSail = (IntelligentGraphSail) intelligentGraphFactory.getSail(intelligentGraphConfig);
// IntelligentGraphSail intelligentGraphSail = new IntelligentGraphSail();
Sail baseSail = new NativeStore(dataDir);
intelligentGraphSail.setBaseSail(baseSail);
org.eclipse.rdf4j.repository.Repository workingRep = new SailRepository(intelligentGraphSail);
return workingRep;
}
use of org.eclipse.rdf4j.sail.nativerdf.NativeStore in project corese by Wimmics.
the class Rdf4jExperimentations method loadDataFromFile.
@Test
public void loadDataFromFile() throws RDFParseException, UnsupportedRDFormatException, IOException {
// Create and load new Repository.
URL url_data = Rdf4jExperimentations.class.getResource("");
File dataDir = new File(url_data.getPath() + "/data/");
Repository db = new SailRepository(new NativeStore(dataDir));
// Open a connection to the database
try (RepositoryConnection conn = db.getConnection()) {
// We do a simple SPARQL SELECT-query
String queryString = "PREFIX ex: <http://example.org/ns#> \n";
queryString += "PREFIX rf: <" + RDF.NAMESPACE + "> \n";
queryString += "SELECT ?s ?o \n";
queryString += "WHERE { \n";
queryString += " ?s a ?o.";
queryString += "}";
TupleQuery query = conn.prepareTupleQuery(queryString);
// when done.
try (TupleQueryResult result = query.evaluate()) {
// we just iterate over all solutions in the result...
System.out.println("Résult :");
for (BindingSet solution : result) {
// ... and print out the value of the variable binding for ?s and ?o
System.out.println("?s = " + solution.getValue("s"));
System.out.println("?o = " + solution.getValue("o"));
System.out.println("---––––––––––––---");
}
}
} finally {
// before our program exits, make sure the database is properly shut down.
db.shutDown();
}
}
use of org.eclipse.rdf4j.sail.nativerdf.NativeStore in project com.inova8.intelligentgraph by peterjohnlawrence.
the class ObjectValueTest method setUpBeforeClass.
/**
* Sets the up before class.
*
* @throws Exception the exception
*/
@BeforeAll
static void setUpBeforeClass() throws Exception {
File dataDir = new File("src/test/resources/datadir/olgap/");
FileUtils.deleteDirectory(dataDir);
org.eclipse.rdf4j.repository.Repository workingRep = new SailRepository(new NativeStore(dataDir));
String modelFilename = "src/test/resources/calc2graph.data.ttl";
InputStream input = new FileInputStream(modelFilename);
Model model = Rio.parse(input, "", RDFFormat.TURTLE);
conn = workingRep.getConnection();
conn.add(model.getStatements(null, null, null));
}
use of org.eclipse.rdf4j.sail.nativerdf.NativeStore in project commons-rdf by apache.
the class NativeStoreGraphTest method createRepository.
public void createRepository() throws IOException {
final Sail sail = new NativeStore(tempDir.newFolder());
repository = new SailRepository(sail);
repository.initialize();
}
Aggregations