org.eclipse.rdf4j.common.iteration.Iterations Java Examples
The following examples show how to use
org.eclipse.rdf4j.common.iteration.Iterations.
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: PropertyPathTests.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testPropertyPath_ExclusivePath() throws Exception { prepareTest(Arrays.asList("/tests/propertypath/data1.ttl", "/tests/propertypath/data2.ttl")); String query = "SELECT * WHERE { ?x rdf:type/rdfs:subClassOf* foaf:Agent . ?x rdfs:label ?label}"; String actualQueryPlan = federationContext().getQueryManager().getQueryPlan(query); // Note: we currently cannot compare the query plan, because the queryplan contains generated // variable name identifiers for anonymous nodes. // assertQueryPlanEquals(readResourceAsString("/tests/propertypath/query_path_exclusivePath.qp"), // actualQueryPlan); Assertions.assertTrue(actualQueryPlan.contains("ExclusiveArbitraryLengthPath")); try (TupleQueryResult tqr = federationContext().getQueryManager().prepareTupleQuery(query).evaluate()) { List<BindingSet> res = Iterations.asList(tqr); assertContainsAll(res, "label", Sets.newHashSet(l("Person 1"), l("Person 2"))); } }
Example #2
Source File: VOIDInferencerConnection.java From semagrow with Apache License 2.0 | 6 votes |
@Override public void flushUpdates() throws SailException { super.flushUpdates(); if (statementsRemoved) { //logger.debug("statements removed, starting inferencing from scratch"); clearInferred(); addAxiomStatements(); newStatements = new TreeModel(); Iterations.addAll(getWrappedConnection().getStatements(null, null, null, true), newStatements); statementsRemoved = false; } doInferencing(); }
Example #3
Source File: SpinSailConnection.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private int executeConstructors(Resource subj, List<IRI> classHierarchy) throws RDF4JException { int nofInferred = 0; Set<Resource> constructed = Iterations.asSet(TripleSources.getObjectResources( subj, EXECUTED, tripleSource)); for (IRI cls : classHierarchy) { List<Resource> constructors = getConstructorsForClass(cls); if (!constructors.isEmpty()) { logger.trace("executing constructors for resource {} of class {}", subj, cls); for (Resource constructor : constructors) { if (constructed.add(constructor)) { logger.trace("executing constructor {} for resource {}", constructor, subj); nofInferred += executeRule(subj, constructor); addInferredStatement(subj, EXECUTED, constructor); } } } } logger.trace("added {} new triples via constructors for resource {}", nofInferred, subj); return nofInferred; }
Example #4
Source File: RepositoryConnectionTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testGetStatements() throws Exception { testCon.add(bob, name, nameBob); assertTrue("Repository should contain statement", testCon.hasStatement(bob, name, nameBob, false)); try (RepositoryResult<Statement> result = testCon.getStatements(null, name, null, false);) { assertNotNull("Iterator should not be null", result); assertTrue("Iterator should not be empty", result.hasNext()); while (result.hasNext()) { Statement st = result.next(); assertNull("Statement should not be in a context ", st.getContext()); assertTrue("Statement predicate should be equal to name ", st.getPredicate().equals(name)); } } List<Statement> list = Iterations.addAll(testCon.getStatements(null, name, null, false), new ArrayList<>()); assertNotNull("List should not be null", list); assertFalse("List should not be empty", list.isEmpty()); }
Example #5
Source File: KnowledgeBaseServiceImpl.java From inception with Apache License 2.0 | 6 votes |
@Override public List<Statement> listStatementsWithPredicateOrObjectReference(KnowledgeBase kb, String aIdentifier) { try (StopWatch watch = new StopWatch(log, "listStatementsWithPredicateOrObjectReference(%s)", aIdentifier)) { try (RepositoryConnection conn = getConnection(kb)) { ValueFactory vf = conn.getValueFactory(); IRI iri = vf.createIRI(aIdentifier); try (RepositoryResult<Statement> predStmts = conn.getStatements(null, iri, null); RepositoryResult<Statement> objStmts = conn.getStatements(null, null, iri)) { List<Statement> allStmts = new ArrayList<>(); Iterations.addAll(predStmts, allStmts); Iterations.addAll(objStmts, allStmts); return allStmts; } } } }
Example #6
Source File: TestNativeStoreMemoryOverflow.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void test() throws Exception { int size = 10000; // this should really be bigger // load a lot of triples in two different contexts testCon.begin(); final ValueFactory vf = testCon.getValueFactory(); URI context1 = vf.createURI("http://my.context.1"); URI context2 = vf.createURI("http://my.context.2"); final URI predicate = vf.createURI("http://my.predicate"); final URI object = vf.createURI("http://my.object"); testCon.add(new DynamicIteration(size, predicate, object, vf), context1); testCon.add(new DynamicIteration(size, predicate, object, vf), context2); assertEquals(size, Iterations.asList(testCon.getStatements(null, null, null, false, context1)).size()); assertEquals(size, Iterations.asList(testCon.getStatements(null, null, null, false, context2)).size()); testCon.commit(); assertEquals(size, Iterations.asList(testCon.getStatements(null, null, null, false, context1)).size()); assertEquals(size, Iterations.asList(testCon.getStatements(null, null, null, false, context2)).size()); testCon.close(); }
Example #7
Source File: QueryTimeoutTests.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test @Disabled // local test only public void testLocalTimeout() throws Exception { assumeSparqlEndpoint(); prepareTest(Arrays.asList("/tests/medium/data1.ttl", "/tests/medium/data2.ttl", "/tests/medium/data3.ttl", "/tests/medium/data4.ttl")); fedxRule.enableDebug(); repoSettings(1).setLatencySimulator(latencySimulator(2000)); repoSettings(2).setLatencySimulator(latencySimulator(2000)); repoSettings(3).setLatencySimulator(latencySimulator(4000)); Query query = queryManager().prepareQuery(readQueryString("/tests/medium/query05.rq")); query.setMaxExecutionTime(10); Assertions.assertThrows(QueryInterruptedException.class, () -> { try (TupleQueryResult tq = ((TupleQuery) query).evaluate()) { Iterations.asList(tq); } }); }
Example #8
Source File: WriteTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testSimpleUpdateQuery_insertData() throws Exception { prepareTest(Arrays.asList("/tests/basic/data_emptyStore.ttl", "/tests/basic/data_emptyStore.ttl")); Iterator<Endpoint> iter = federationContext().getEndpointManager().getAvailableEndpoints().iterator(); EndpointBase ep1 = (EndpointBase) iter.next(); ep1.setWritable(true); try (RepositoryConnection conn = fedxRule.getRepository().getConnection()) { Update update = conn.prepareUpdate(QueryLanguage.SPARQL, "PREFIX ex: <http://example.org/> INSERT DATA { ex:subject a ex:Person } "); update.execute(); // test that statement is returned from federation List<Statement> stmts = Iterations.asList(conn.getStatements(null, null, null, true)); Assertions.assertEquals(1, stmts.size()); Assertions.assertEquals(RDF.TYPE, stmts.get(0).getPredicate()); } }
Example #9
Source File: ExtensibleDirectEvaluationStatistics.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected double getCardinality(StatementPattern sp) { SailDataset dataset = extensibleSailStore.getExplicitSailSource().dataset(IsolationLevels.NONE); Resource subject = (Resource) sp.getSubjectVar().getValue(); IRI predicate = (IRI) sp.getPredicateVar().getValue(); Value object = sp.getObjectVar().getValue(); if (sp.getScope() == StatementPattern.Scope.DEFAULT_CONTEXTS) { try (Stream<? extends Statement> stream = Iterations .stream(dataset.getStatements(subject, predicate, object))) { return stream.count(); } } else { Resource[] context = new Resource[] { (Resource) sp.getContextVar().getValue() }; try (Stream<? extends Statement> stream = Iterations .stream(dataset.getStatements(subject, predicate, object, context))) { return stream.count(); } } }
Example #10
Source File: QueryEvaluator.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
/*** * Evaluate a graph query, and create an XML results document. * * @param builder response builder helper for generating the XML response to the client, which <em>must not</em> * have had start() called on it * @param xslPath needed to begin writing response body after writing result count cookie * @param req needed to write result count cookie * @param resp needed to write result count cookie * @param cookies needed to write result count cookie * @param query the query to be evaluated * @param writeCookie whether to write the total result count cookie * @throws QueryResultHandlerException */ private void evaluateGraphQuery(final TupleResultBuilder builder, String xslPath, WorkbenchRequest req, HttpServletResponse resp, CookieHandler cookies, final GraphQuery query, boolean writeCookie, boolean paged, int offset, int limit) throws QueryEvaluationException, QueryResultHandlerException { List<Statement> statements = Iterations.asList(query.evaluate()); if (writeCookie) { cookies.addTotalResultCountCookie(req, resp, statements.size()); } builder.transform(xslPath, "graph.xsl"); builder.start(); builder.variables("subject", "predicate", "object"); builder.link(Arrays.asList(INFO)); if (paged && writeCookie) { // Only in this case do we have paged results, but were given the full // query. Just-in-case parameter massaging below to avoid array index // issues. int fromIndex = Math.min(0, offset); statements = statements.subList(fromIndex, Math.max(fromIndex, Math.min(offset + limit, statements.size()))); } for (Statement statement : statements) { builder.result(statement.getSubject(), statement.getPredicate(), statement.getObject(), statement.getContext()); } builder.end(); }
Example #11
Source File: FedXWithLocalRepositoryManagerTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testWithLocalRepositoryManager_FactoryInitialization() throws Exception { addMemoryStore("repo1"); addMemoryStore("repo2"); ValueFactory vf = SimpleValueFactory.getInstance(); addData("repo1", Lists.newArrayList( vf.createStatement(vf.createIRI("http://ex.org/p1"), RDF.TYPE, FOAF.PERSON))); addData("repo2", Lists.newArrayList( vf.createStatement(vf.createIRI("http://ex.org/p2"), RDF.TYPE, FOAF.PERSON))); FedXRepositoryConfig fedXRepoConfig = FedXRepositoryConfigBuilder.create() .withResolvableEndpoint(Arrays.asList("repo1", "repo2")) .build(); repoManager.addRepositoryConfig(new RepositoryConfig("federation", fedXRepoConfig)); Repository repo = repoManager.getRepository("federation"); try (RepositoryConnection conn = repo.getConnection()) { List<Statement> sts = Iterations.asList(conn.getStatements(null, RDF.TYPE, FOAF.PERSON)); Assertions.assertEquals(2, sts.size()); // two persons } }
Example #12
Source File: JoinOptimizerTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void test_checkedJoinOptimizer() throws Exception { prepareTest( Arrays.asList("/tests/basic/data01endpoint1.ttl", "/tests/basic/data01endpoint2.ttl")); // both patterns of the query result in a exclusive statements at the respective endpoints String query = "PREFIX : <http://example.org/> SELECT ?person WHERE { " + "{ :a <" + FOAF.NAME + "> 'Alan' . :a <" + FOAF.INTEREST + "> 'SPARQL 1.1 Basic Federated Query' } }"; String actualQueryPlan = federationContext().getQueryManager().getQueryPlan(query); assertQueryPlanEquals(readResourceAsString("/tests/optimizer/queryPlan_Join_2.txt"), actualQueryPlan); try (TupleQueryResult tqr = federationContext().getQueryManager().prepareTupleQuery(query).evaluate()) { Assertions.assertEquals(1, Iterations.asList(tqr).size()); // one result row, but no bindings } }
Example #13
Source File: JoinOptimizerTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void test_emptyJoinOptimizer() throws Exception { prepareTest( Arrays.asList("/tests/basic/data01endpoint1.ttl", "/tests/basic/data01endpoint2.ttl")); // first part of the query produces 0 results, but make sure that this is optimized properly // second half of the query is required to not have a SingleSourceQuery String query = "SELECT ?person WHERE { " + "{ ?person <" + FOAF.NAME + "> ?name . ?person <urn:doesNotExistProp> ?obj . BIND(?name AS ?nameOut) } UNION { ?person <" + FOAF.INTEREST + "> ?o } }"; String actualQueryPlan = federationContext().getQueryManager().getQueryPlan(query); assertQueryPlanEquals(readResourceAsString("/tests/optimizer/queryPlan_Join_1.txt"), actualQueryPlan); try (TupleQueryResult tqr = federationContext().getQueryManager().prepareTupleQuery(query).evaluate()) { Assertions.assertEquals(2, Iterations.asList(tqr).size()); // two results from endpoint 2 } }
Example #14
Source File: ElasticsearchStoreTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testAddRemoveData() { ElasticsearchStore elasticsearchStore = new ElasticsearchStore("localhost", embeddedElastic.getTransportTcpPort(), "cluster1", "testindex"); try (NotifyingSailConnection connection = elasticsearchStore.getConnection()) { connection.begin(IsolationLevels.NONE); connection.addStatement(RDF.TYPE, RDF.TYPE, RDFS.RESOURCE); connection.commit(); connection.begin(IsolationLevels.NONE); connection.removeStatements(RDF.TYPE, RDF.TYPE, RDFS.RESOURCE); connection.commit(); List<? extends Statement> statements = Iterations.asList(connection.getStatements(null, null, null, true)); assertEquals(0, statements.size()); } elasticsearchStore.shutDown(); }
Example #15
Source File: HashJoinTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testLeftJoin_NoResultForBinding() throws Exception { List<BindingSet> leftBlock = new ArrayList<>(); leftBlock.add(bindingSet(binding("x", irid("p1")), binding("y", l("P1")))); leftBlock.add(bindingSet(binding("y", l("P2")))); List<BindingSet> rightBlock = new ArrayList<>(); rightBlock.add(bindingSet(binding("x", irid("p1")), binding("z", l("something")))); CloseableIteration<BindingSet, QueryEvaluationException> joinResultIter = HashJoin.join(leftBlock, rightBlock, Sets.newHashSet("x"), Collections.emptyList()); List<BindingSet> joinResult = Iterations.asList(joinResultIter); Assertions.assertEquals(1, joinResult.size()); Assertions.assertEquals( bindingSet(binding("x", irid("p1")), binding("y", l("P1")), binding("z", l("something"))), joinResult.get(0)); }
Example #16
Source File: HashJoinTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testMultipleBindings() throws Exception { List<BindingSet> leftBlock = new ArrayList<>(); leftBlock.add(bindingSet(binding("x", irid("p1")), binding("y", l("P1")))); leftBlock.add(bindingSet(binding("x", irid("p2")), binding("y", l("P2")))); List<BindingSet> rightBlock = new ArrayList<>(); rightBlock.add(bindingSet(binding("x", irid("p2")), binding("z", l("something")))); CloseableIteration<BindingSet, QueryEvaluationException> joinResultIter = HashJoin.join(leftBlock, rightBlock, Sets.newHashSet("x"), Collections.emptyList()); List<BindingSet> joinResult = Iterations.asList(joinResultIter); Assertions.assertEquals(1, joinResult.size()); Assertions.assertEquals( bindingSet(binding("x", irid("p2")), binding("y", l("P2")), binding("z", l("something"))), joinResult.get(0)); }
Example #17
Source File: HashJoinTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testSimple() throws Exception { List<BindingSet> leftBlock = new ArrayList<>(); leftBlock.add(bindingSet(binding("x", irid("p1")))); leftBlock.add(bindingSet(binding("x", irid("p2")))); leftBlock.add(bindingSet(binding("x", irid("p3")))); List<BindingSet> rightBlock = new ArrayList<>(); rightBlock.add(bindingSet(binding("x", irid("p2")))); rightBlock.add(bindingSet(binding("x", irid("p1")))); rightBlock.add(bindingSet(binding("x", irid("p4")))); CloseableIteration<BindingSet, QueryEvaluationException> joinResultIter = HashJoin.join(leftBlock, rightBlock, Sets.newHashSet("x"), Collections.emptyList()); List<BindingSet> joinResult = Iterations.asList(joinResultIter); Assertions.assertEquals(Lists.newArrayList( bindingSet(binding("x", irid("p1"))), bindingSet(binding("x", irid("p2")))), joinResult); }
Example #18
Source File: MemTripleSourceTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.sail.memory.MemTripleSource#getStatements(org.eclipse.rdf4j.model.Resource, org.eclipse.rdf4j.model.IRI, org.eclipse.rdf4j.model.Value, org.eclipse.rdf4j.model.Resource[])} * . */ @Test public final void testGetStatementsNoContextsPredicateExClassNoContexts() throws Exception { loadTestData("/alp-testdata.ttl"); TripleSource source = getTripleSourceCommitted(); try (CloseableIteration<? extends Statement, QueryEvaluationException> statements = source.getStatements(null, RDFS.SUBCLASSOF, f.createIRI(EX_NS, "A"))) { List<Statement> list = Iterations.asList(statements); assertEquals(3, list.size()); } }
Example #19
Source File: MemTripleSourceTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.sail.memory.MemTripleSource#getStatements(org.eclipse.rdf4j.model.Resource, org.eclipse.rdf4j.model.IRI, org.eclipse.rdf4j.model.Value, org.eclipse.rdf4j.model.Resource[])} * . */ @Test public final void testGetStatementsOneContextOnePredicate() throws Exception { loadTestData("/alp-testdata.ttl", this.alice); TripleSource source = getTripleSourceCommitted(); try (CloseableIteration<? extends Statement, QueryEvaluationException> statements = source.getStatements(null, RDFS.SUBCLASSOF, null)) { List<Statement> list = Iterations.asList(statements); assertEquals(4, list.size()); } }
Example #20
Source File: MemTripleSourceTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.sail.memory.MemTripleSource#getStatements(org.eclipse.rdf4j.model.Resource, org.eclipse.rdf4j.model.IRI, org.eclipse.rdf4j.model.Value, org.eclipse.rdf4j.model.Resource[])} * . */ @Test public final void testGetStatementsTwoContextsOnePredicate() throws Exception { loadTestData("/alp-testdata.ttl", this.alice, this.bob); TripleSource source = getTripleSourceCommitted(); try (CloseableIteration<? extends Statement, QueryEvaluationException> statements = source.getStatements(null, RDFS.SUBCLASSOF, null)) { List<Statement> list = Iterations.asList(statements); assertEquals(8, list.size()); } }
Example #21
Source File: ReadCacheBenchmark.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Benchmark public List<BindingSet> groupByQueryWithCacheCleared() { clearCache(); try (SailRepositoryConnection connection = repoWithCache.getConnection()) { return Iterations.asList(connection .prepareTupleQuery(query1) .evaluate()); } }
Example #22
Source File: MemTripleSourceTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.sail.memory.MemTripleSource#getStatements(org.eclipse.rdf4j.model.Resource, org.eclipse.rdf4j.model.IRI, org.eclipse.rdf4j.model.Value, org.eclipse.rdf4j.model.Resource[])} * . */ @Test public final void testGetStatementsTwoContextsExClassPredicateTwoContexts() throws Exception { loadTestData("/alp-testdata.ttl", this.alice, this.bob); TripleSource source = getTripleSourceCommitted(); try (CloseableIteration<? extends Statement, QueryEvaluationException> statements = source .getStatements(f.createIRI(EX_NS, "C"), RDFS.SUBCLASSOF, null, this.alice, this.bob)) { List<Statement> list = Iterations.asList(statements); assertEquals(2, list.size()); } }
Example #23
Source File: QueryResults.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static boolean isSubset(TupleQueryResult tqr1, TupleQueryResult tqr2) throws QueryEvaluationException { List<BindingSet> list1 = Iterations.asList(tqr1); List<BindingSet> list2 = Iterations.asList(tqr2); // Compare the number of statements in both sets if (list1.size() > list2.size()) { return false; } return matchBindingSets(list1, list2); }
Example #24
Source File: NamedGraphTests.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testGetContextIDs() throws Exception { prepareTest(Arrays.asList("/tests/named-graphs/data1.trig", "/tests/named-graphs/data2.trig", "/tests/named-graphs/data3.trig", "/tests/named-graphs/data4.trig")); try (RepositoryConnection conn = fedxRule.getRepository().getConnection()) { List<Resource> graphs = Iterations.asList(conn.getContextIDs()); assertThat(graphs).containsExactlyInAnyOrder(NS_1.GRAPH_1, NS_1.GRAPH_2, NS_3.SHARED_GRAPH, NS_2.GRAPH_1, NS_2.GRAPH_2); } }
Example #25
Source File: MemTripleSourceTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.sail.memory.MemTripleSource#getStatements(org.eclipse.rdf4j.model.Resource, org.eclipse.rdf4j.model.IRI, org.eclipse.rdf4j.model.Value, org.eclipse.rdf4j.model.Resource[])} * . */ @Test public final void testGetStatementsNoContextsExClassPredicateNoContexts() throws Exception { loadTestData("/alp-testdata.ttl"); TripleSource source = getTripleSourceCommitted(); try (CloseableIteration<? extends Statement, QueryEvaluationException> statements = source .getStatements(f.createIRI(EX_NS, "C"), RDFS.SUBCLASSOF, null)) { List<Statement> list = Iterations.asList(statements); assertEquals(1, list.size()); } }
Example #26
Source File: MemTripleSourceTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.sail.memory.MemTripleSource#getStatements(org.eclipse.rdf4j.model.Resource, org.eclipse.rdf4j.model.IRI, org.eclipse.rdf4j.model.Value, org.eclipse.rdf4j.model.Resource[])} * . */ @Test public final void testGetStatementsNoContextsOnePredicateOneContext() throws Exception { loadTestData("/alp-testdata.ttl"); TripleSource source = getTripleSourceCommitted(); try (CloseableIteration<? extends Statement, QueryEvaluationException> statements = source.getStatements(null, RDFS.SUBCLASSOF, null, this.alice)) { List<Statement> list = Iterations.asList(statements); assertEquals(0, list.size()); } }
Example #27
Source File: MemTripleSourceTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.sail.memory.MemTripleSource#getStatements(org.eclipse.rdf4j.model.Resource, org.eclipse.rdf4j.model.IRI, org.eclipse.rdf4j.model.Value, org.eclipse.rdf4j.model.Resource[])} * . */ @Test public final void testGetStatementsOneContextOnePredicateOneContext() throws Exception { loadTestData("/alp-testdata.ttl", this.alice); TripleSource source = getTripleSourceCommitted(); try (CloseableIteration<? extends Statement, QueryEvaluationException> statements = source.getStatements(null, RDFS.SUBCLASSOF, null, this.alice)) { List<Statement> list = Iterations.asList(statements); assertEquals(4, list.size()); } }
Example #28
Source File: MemTripleSourceTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Test method for * {@link org.eclipse.rdf4j.sail.memory.MemTripleSource#getStatements(org.eclipse.rdf4j.model.Resource, org.eclipse.rdf4j.model.IRI, org.eclipse.rdf4j.model.Value, org.eclipse.rdf4j.model.Resource[])} * . */ @Test public final void testGetStatementsTwoContextsOnePredicateOneContext() throws Exception { loadTestData("/alp-testdata.ttl", this.alice, this.bob); TripleSource source = getTripleSourceCommitted(); try (CloseableIteration<? extends Statement, QueryEvaluationException> statements = source.getStatements(null, RDFS.SUBCLASSOF, null, this.alice)) { List<Statement> list = Iterations.asList(statements); assertEquals(4, list.size()); } }
Example #29
Source File: ReadCacheBenchmark.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Benchmark public List<BindingSet> complexQueryWithCache() { try (SailRepositoryConnection connection = repoWithCache.getConnection()) { return Iterations.asList(connection .prepareTupleQuery(query5) .evaluate()); } }
Example #30
Source File: ReadCacheBenchmark.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Benchmark public List<BindingSet> pathQueryWithCache() { try (SailRepositoryConnection connection = repoWithCache.getConnection()) { return Iterations.asList(connection .prepareTupleQuery(query6) .evaluate()); } }