Search in sources :

Example 11 with NativeStore

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;
}
Also used : SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) LuceneSail(org.eclipse.rdf4j.sail.lucene.LuceneSail) Sail(org.eclipse.rdf4j.sail.Sail) IntelligentGraphSail(com.inova8.intelligentgraph.sail.IntelligentGraphSail) NativeStore(org.eclipse.rdf4j.sail.nativerdf.NativeStore) IntelligentGraphFactory(com.inova8.intelligentgraph.sail.IntelligentGraphFactory) IntelligentGraphSail(com.inova8.intelligentgraph.sail.IntelligentGraphSail) File(java.io.File) IntelligentGraphConfig(com.inova8.intelligentgraph.sail.IntelligentGraphConfig)

Example 12 with NativeStore

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();
    }
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) BindingSet(org.eclipse.rdf4j.query.BindingSet) Repository(org.eclipse.rdf4j.repository.Repository) SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) NativeStore(org.eclipse.rdf4j.sail.nativerdf.NativeStore) TupleQuery(org.eclipse.rdf4j.query.TupleQuery) TupleQueryResult(org.eclipse.rdf4j.query.TupleQueryResult) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 13 with NativeStore

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));
}
Also used : SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Model(org.eclipse.rdf4j.model.Model) NativeStore(org.eclipse.rdf4j.sail.nativerdf.NativeStore) File(java.io.File) FileInputStream(java.io.FileInputStream) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 14 with NativeStore

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();
}
Also used : SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) Sail(org.eclipse.rdf4j.sail.Sail) NativeStore(org.eclipse.rdf4j.sail.nativerdf.NativeStore)

Aggregations

SailRepository (org.eclipse.rdf4j.repository.sail.SailRepository)14 NativeStore (org.eclipse.rdf4j.sail.nativerdf.NativeStore)14 File (java.io.File)13 InputStream (java.io.InputStream)9 FileInputStream (java.io.FileInputStream)7 Model (org.eclipse.rdf4j.model.Model)7 BeforeAll (org.junit.jupiter.api.BeforeAll)7 Sail (org.eclipse.rdf4j.sail.Sail)4 IntelligentGraphSail (com.inova8.intelligentgraph.sail.IntelligentGraphSail)3 RepositoryConnection (org.eclipse.rdf4j.repository.RepositoryConnection)3 LuceneSail (org.eclipse.rdf4j.sail.lucene.LuceneSail)3 IntelligentGraphConfig (com.inova8.intelligentgraph.sail.IntelligentGraphConfig)2 IntelligentGraphFactory (com.inova8.intelligentgraph.sail.IntelligentGraphFactory)2 URL (java.net.URL)2 BindingSet (org.eclipse.rdf4j.query.BindingSet)2 Repository (org.eclipse.rdf4j.repository.Repository)2 Test (org.junit.Test)2 CoreseModel (fr.inria.corese.rdf4j.CoreseModel)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1