Java Code Examples for org.eclipse.rdf4j.repository.sail.SailRepository#shutDown()
The following examples show how to use
org.eclipse.rdf4j.repository.sail.SailRepository#shutDown() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MinCountPrefilledVsEmptyBenchmark.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Benchmark public void shaclEmpty() throws Exception { ShaclSail shaclRepo = Utils.getInitializedShaclSail("shacl.ttl"); SailRepository repository = new SailRepository(shaclRepo); try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(); connection.commit(); } try (SailRepositoryConnection connection = repository.getConnection()) { for (List<Statement> statements : allStatements) { connection.begin(); connection.add(statements); connection.commit(); } } repository.shutDown(); }
Example 2
Source File: MaxCountBenchmarkEmpty.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Benchmark public void sparqlInsteadOfShacl() { SailRepository repository = new SailRepository(new MemoryStore()); repository.init(); try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(); connection.commit(); } try (SailRepositoryConnection connection = repository.getConnection()) { for (List<Statement> statements : allStatements) { connection.begin(); connection.add(statements); try (Stream<BindingSet> stream = connection.prepareTupleQuery("select * where {?a a <" + RDFS.RESOURCE + ">. ?a <" + RDFS.LABEL + "> ?c, ?d. FILTER(?c != ?d)}").evaluate().stream()) { stream.forEach(System.out::println); } connection.commit(); } } repository.shutDown(); }
Example 3
Source File: NotClassBenchmarkEmpty.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Benchmark public void noShacl() { SailRepository repository = new SailRepository(new MemoryStore()); repository.init(); try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(); connection.commit(); } try (SailRepositoryConnection connection = repository.getConnection()) { for (List<Statement> statements : allStatements) { connection.begin(); connection.add(statements); connection.commit(); } } repository.shutDown(); }
Example 4
Source File: UniqueLangBenchmarkEmpty.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Benchmark public void noShacl() { SailRepository repository = new SailRepository(new MemoryStore()); repository.init(); try (SailRepositoryConnection connection = repository.getConnection()) { for (List<Statement> statements : allStatements) { connection.begin(IsolationLevels.SNAPSHOT); connection.add(statements); connection.commit(); } } repository.shutDown(); }
Example 5
Source File: MinCountBenchmarkEmpty.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Benchmark public void noShacl() { SailRepository repository = new SailRepository(new MemoryStore()); repository.init(); try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(); connection.commit(); } try (SailRepositoryConnection connection = repository.getConnection()) { for (List<Statement> statements : allStatements) { connection.begin(); connection.add(statements); connection.commit(); } } repository.shutDown(); }
Example 6
Source File: MongoDbRyaSailFactoryLoadFilesIT.java From rya with Apache License 2.0 | 5 votes |
/** * Shuts the repository down, releasing any resources that it keeps hold of. * Once shut down, the repository can no longer be used until it is * re-initialized. * @param repository the {@link SailRepository} to close. */ private static void close(final SailRepository repository) { if (repository != null) { try { repository.shutDown(); } catch (final RepositoryException e) { log.error("Encountered an error while closing Sail Repository", e); } } }
Example 7
Source File: RyaDirectExample.java From rya with Apache License 2.0 | 5 votes |
private static void closeQuietly(final SailRepository repository) { if (repository != null) { try { repository.shutDown(); } catch (final RepositoryException e) { // quietly absorb this exception } } }
Example 8
Source File: MinCountPrefilledVsEmptyBenchmark.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Benchmark public void shaclEmptyJustInitializeAndEmptyTransaction() throws Exception { ShaclSail shaclRepo = Utils.getInitializedShaclSail("shacl.ttl"); SailRepository repository = new SailRepository(shaclRepo); try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(); connection.commit(); } repository.shutDown(); }
Example 9
Source File: TimeAwareHBaseSailTest.java From Halyard with Apache License 2.0 | 5 votes |
@Test public void timestampDateTimeTest() throws Exception { CloseableIteration<? extends Statement, SailException> iter; HBaseSail sail = new TimeAwareHBaseSail(HBaseServerTestInstance.getInstanceConfig(), "timestamptable", true, 0, true, 0, null, null); SailRepository rep = new SailRepository(sail); rep.initialize(); SailRepositoryConnection con = rep.getConnection(); assertTrue(testUpdate(con, "insert {<http://whatever> <http://whatever> <http://whatever>} where {bind(\"2002-05-30T09:30:10.2\"^^<http://www.w3.org/2001/XMLSchema#dateTime> as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}")); assertTrue(testUpdate(con, "delete {<http://whatever> <http://whatever> <http://whatever>} where {bind(\"2002-05-30T09:30:10.1\"^^<http://www.w3.org/2001/XMLSchema#dateTime> as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}")); assertFalse(testUpdate(con, "delete {<http://whatever> <http://whatever> <http://whatever>} where {bind(\"2002-05-30T09:30:10.4\"^^<http://www.w3.org/2001/XMLSchema#dateTime> as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}")); assertFalse(testUpdate(con, "insert {<http://whatever> <http://whatever> <http://whatever>} where {bind(\"2002-05-30T09:30:10.3\"^^<http://www.w3.org/2001/XMLSchema#dateTime> as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}")); assertTrue(testUpdate(con, "insert {<http://whatever> <http://whatever> <http://whatever>} where {bind(\"2002-05-30T09:30:10.4\"^^<http://www.w3.org/2001/XMLSchema#dateTime> as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}")); rep.shutDown(); }
Example 10
Source File: RyaMongoGeoDirectExample.java From rya with Apache License 2.0 | 5 votes |
private static void closeQuietly(final SailRepository repository) { if (repository != null) { try { repository.shutDown(); } catch (final RepositoryException e) { // quietly absorb this exception } } }
Example 11
Source File: ComplexLargeBenchmark.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Benchmark public void noPreloadingNonEmptyParallel() { try { SailRepository repository = new SailRepository(Utils.getInitializedShaclSail("complexBenchmark/shacl.ttl")); ((ShaclSail) repository.getSail()).disableValidation(); try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(IsolationLevels.NONE); SimpleValueFactory vf = SimpleValueFactory.getInstance(); connection.add(vf.createBNode(), vf.createIRI("http://fjljfiwoejfoiwefiew/a"), vf.createBNode()); connection.commit(); } ((ShaclSail) repository.getSail()).enableValidation(); ((ShaclSail) repository.getSail()).setParallelValidation(true); ((ShaclSail) repository.getSail()).setCacheSelectNodes(true); // ((ShaclSail) repository.getSail()).setPerformanceLogging(true); try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(IsolationLevels.NONE); try (InputStream resourceAsStream = getData()) { connection.add(resourceAsStream, "", RDFFormat.TURTLE); } connection.commit(); } repository.shutDown(); } catch (IOException e) { throw new RuntimeException(e); } }
Example 12
Source File: ModifyShapesPostInitTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test(expected = SailConflictException.class) public void testDeadlockDetection() throws Throwable { ShaclSail shaclSail = new ShaclSail(new MemoryStore()); SailRepository sailRepository = new SailRepository(shaclSail); sailRepository.init(); SailRepositoryConnection connection1 = sailRepository.getConnection(); SailRepositoryConnection connection2 = sailRepository.getConnection(); try { connection2.begin(); StringReader shaclRules = new StringReader(String.join("\n", "", "@prefix ex: <http://example.com/ns#> .", "@prefix sh: <http://www.w3.org/ns/shacl#> .", "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .", "@prefix foaf: <http://xmlns.com/foaf/0.1/>.", "ex:PersonShape", " a sh:NodeShape ;", " sh:targetClass ex:Person ;", " sh:property [", " sh:path ex:age ;", " sh:minCount 1 ;", " ] .")); connection2.add(shaclRules, "", RDFFormat.TURTLE, RDF4J.SHACL_SHAPE_GRAPH); connection1.begin(); addInTransaction(connection1, "ex:steve a ex:Person ."); try { connection1.commit(); } catch (RepositoryException e) { throw e.getCause(); } } finally { connection2.close(); connection1.close(); sailRepository.shutDown(); } }
Example 13
Source File: ModifyShapesPostInitTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void testAddingShapesThatFails() throws Throwable { ShaclSail shaclSail = new ShaclSail(new MemoryStore()); SailRepository sailRepository = new SailRepository(shaclSail); sailRepository.init(); SailRepositoryConnection connection1 = sailRepository.getConnection(); SailRepositoryConnection connection2 = sailRepository.getConnection(); add(connection1, "ex:pete a ex:Person ."); connection2.begin(); StringReader shaclRules = new StringReader(String.join("\n", "", "@prefix ex: <http://example.com/ns#> .", "@prefix sh: <http://www.w3.org/ns/shacl#> .", "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .", "@prefix foaf: <http://xmlns.com/foaf/0.1/>.", "ex:PersonShape", " a sh:NodeShape ;", " sh:targetClass ex:Person ;", " sh:property [", " sh:path ex:age ;", " sh:minCount 1 ;", " ] .")); connection2.add(shaclRules, "", RDFFormat.TURTLE, RDF4J.SHACL_SHAPE_GRAPH); try { connection2.commit(); } catch (Throwable ignored) { } connection2.rollback(); add(connection1, "ex:steve a ex:Person ."); connection2.close(); connection1.close(); sailRepository.shutDown(); }
Example 14
Source File: ComplexBenchmark.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Benchmark public void shaclNothingToValidateTransactions() throws Exception { SailRepository repository = new SailRepository(Utils.getInitializedShaclSail("complexBenchmark/shacl.ttl")); ((ShaclSail) repository.getSail()).setParallelValidation(false); try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(IsolationLevels.SNAPSHOT); connection.add(connection.getValueFactory().createBNode(), RDFS.LABEL, connection.getValueFactory().createLiteral("")); connection.commit(); } repository.shutDown(); }
Example 15
Source File: ModifyShapesPostInitTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test(expected = ShaclSailValidationException.class) public void testViolation() throws Throwable { ShaclSail shaclSail = new ShaclSail(new MemoryStore()); SailRepository sailRepository = new SailRepository(shaclSail); sailRepository.init(); SailRepositoryConnection connection1 = sailRepository.getConnection(); SailRepositoryConnection connection2 = sailRepository.getConnection(); connection2.begin(); StringReader shaclRules = new StringReader(String.join("\n", "", "@prefix ex: <http://example.com/ns#> .", "@prefix sh: <http://www.w3.org/ns/shacl#> .", "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .", "@prefix foaf: <http://xmlns.com/foaf/0.1/>.", "ex:PersonShape", " a sh:NodeShape ;", " sh:targetClass ex:Person ;", " sh:property [", " sh:path ex:age ;", " sh:minCount 1 ;", " ] .")); connection2.add(shaclRules, "", RDFFormat.TURTLE, RDF4J.SHACL_SHAPE_GRAPH); connection2.commit(); try { add(connection1, "ex:steve a ex:Person ."); } catch (Throwable e) { throw e.getCause(); } connection2.close(); connection1.close(); sailRepository.shutDown(); }
Example 16
Source File: ComplexBenchmark.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Benchmark public void shaclCache() throws Exception { SailRepository repository = new SailRepository(Utils.getInitializedShaclSail("complexBenchmark/shacl.ttl")); ((ShaclSail) repository.getSail()).setParallelValidation(false); try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(IsolationLevels.SNAPSHOT); connection.prepareUpdate(transaction1).execute(); connection.commit(); connection.begin(IsolationLevels.SNAPSHOT); connection.prepareUpdate(transaction2).execute(); connection.commit(); } repository.shutDown(); }
Example 17
Source File: ElasticsearchStoreTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void testSailRepository() { SailRepository elasticsearchStore = new SailRepository( new ElasticsearchStore("localhost", embeddedElastic.getTransportTcpPort(), "cluster1", "testindex")); elasticsearchStore.shutDown(); }
Example 18
Source File: ElasticsearchSailExample.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Create a LuceneSail and add some triples to it, ask a query. */ public static void createSimple() throws Exception { // create a sesame memory sail MemoryStore memoryStore = new MemoryStore(); // create a lucenesail to wrap the memorystore LuceneSail lucenesail = new LuceneSail(); lucenesail.setParameter(LuceneSail.INDEX_CLASS_KEY, ElasticsearchIndex.class.getName()); // wrap memorystore in a lucenesail lucenesail.setBaseSail(memoryStore); // create a Repository to access the sails SailRepository repository = new SailRepository(lucenesail); repository.initialize(); try ( // add some test data, the FOAF ont SailRepositoryConnection connection = repository.getConnection()) { connection.begin(); connection.add( ElasticsearchSailExample.class.getResourceAsStream("/org/openrdf/sail/lucene/examples/foaf.rdfs"), "", RDFFormat.RDFXML); connection.commit(); // search for resources that mention "person" String queryString = "PREFIX search: <" + LuceneSailSchema.NAMESPACE + "> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "SELECT * WHERE { \n" + "?subject search:matches ?match . \n" + "?match search:query \"person\" ; \n" + " search:property ?property ; \n" + " search:score ?score ; \n" + " search:snippet ?snippet . \n" + "?subject rdf:type ?type . \n" + "} LIMIT 3 \n" + "BINDINGS ?type { \n" + " (<http://www.w3.org/2002/07/owl#Class>) \n" + "}"; tupleQuery(queryString, connection); // search for property "name" with domain "person" queryString = "PREFIX search: <" + LuceneSailSchema.NAMESPACE + "> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "SELECT * WHERE { \n" + "?subject rdfs:domain ?domain . \n" + "?subject search:matches ?match . \n" + "?match search:query \"chat\" ; \n" + " search:score ?score . \n" + "?domain search:matches ?match2 . \n" + "?match2 search:query \"person\" ; \n" + " search:score ?score2 . \n" + "} LIMIT 5"; tupleQuery(queryString, connection); // search in subquery and filter results queryString = "PREFIX search: <" + LuceneSailSchema.NAMESPACE + "> \n" + "SELECT * WHERE { \n" + "{ SELECT * WHERE { \n" + " ?subject search:matches ?match . \n" + " ?match search:query \"person\" ; \n" + " search:property ?property ; \n" + " search:score ?score ; \n" + " search:snippet ?snippet . \n" + "} } \n" + "FILTER(CONTAINS(STR(?subject), \"Person\")) \n" + "} \n" + ""; tupleQuery(queryString, connection); // search for property "homepage" with domain foaf:Person queryString = "PREFIX search: <" + LuceneSailSchema.NAMESPACE + "> \n" + "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "CONSTRUCT { ?x rdfs:domain foaf:Person } \n" + "WHERE { \n" + "?x rdfs:domain foaf:Person . \n" + "?x search:matches ?match . \n" + "?match search:query \"homepage\" ; \n" + " search:property ?property ; \n" + " search:score ?score ; \n" + " search:snippet ?snippet . \n" + "} LIMIT 3 \n"; graphQuery(queryString, connection); } finally { repository.shutDown(); } }
Example 19
Source File: ComplexBenchmark.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 3 votes |
@Benchmark public void shaclNoTransactions() throws Exception { SailRepository repository = new SailRepository(Utils.getInitializedShaclSail("complexBenchmark/shacl.ttl")); repository.shutDown(); }
Example 20
Source File: NativeStoreBenchmark.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 3 votes |
public void memoryStore() throws IOException { NotifyingSail shaclSail = new MemoryStore(); SailRepository sailRepository = new SailRepository(shaclSail); sailRepository.init(); try (SailRepositoryConnection connection = sailRepository.getConnection()) { connection.begin(IsolationLevels.NONE); try (InputStream inputStream = getFile("complexBenchmark/shacl.ttl")) { connection.add(inputStream, "", RDFFormat.TURTLE, RDF4J.SHACL_SHAPE_GRAPH); } connection.commit(); connection.begin(IsolationLevels.NONE); try (InputStream inputStream = new BufferedInputStream(getFile("complexBenchmark/generated.ttl"))) { connection.add(inputStream, "", RDFFormat.TURTLE); } connection.commit(); } sailRepository.shutDown(); }