@Test public void inverseValueOrderSubjTest() throws CumulusStoreException { Value[] query = new Value[2]; query[0] = buildResource(_subject); query[1] = buildResource(_predicate); Iterator<Statement> iter = _tripleStore.range(query, null, true, null, true, true, Integer.MAX_VALUE); assertTrue(iter != null && iter.hasNext()); double last = Double.MAX_VALUE; double current = Double.MAX_VALUE; while (iter.hasNext()) { last = current; final Statement res = iter.next(); Literal lit = (Literal) res.getObject(); current = Double.parseDouble(lit.getLabel()); assertTrue(last >= current); } }
/** * If an invalid query is received then an empty iterator must be returned. * * @throws Exception never otherwise the test fails. */ @Test public void invalidQueries() throws Exception { final Value[][] invalidQueries = { null, // null { null, null, null }, // bad length { buildResource(randomString()) }, // bad length { buildResource(randomString()), null } // p is a variable }; for (final Value[] invalidQuery : invalidQueries) { assertEquals( "query " + invalidQuery + " must return an empty iterator.", 0, numOfRes(_tripleStore.range(invalidQuery, null, true, null, true, true, Integer.MAX_VALUE))); assertSame( "query " + invalidQuery + " must return an empty iterator.", Iterators.emptyIterator(), _tripleStore.rangeAsIDs(invalidQuery, null, true, null, true, true, Integer.MAX_VALUE)); } }
Iterator<Statement> iter = _tripleStore.range( query, buildLiteral(String.valueOf(lowerBound)),
@Test public void inverseValueOrderTest() throws CumulusStoreException { Value[] query = new Value[2]; query[0] = null; query[1] = buildResource(_predicate); Iterator<Statement> iter = _tripleStore.range(query, null, true, null, true, true, Integer.MAX_VALUE); assertTrue(iter != null && iter.hasNext()); double last = Double.MAX_VALUE; double current = Double.MAX_VALUE; int counter = 0; while (iter.hasNext()) { last = current; Statement res = iter.next(); Literal lit = (Literal) res.getObject(); current = Double.parseDouble(lit.getLabel()); assertTrue(last >= current); counter++; } assertTrue(counter == 320); }
final Iterator<Statement> iter = _tripleStore.range(rangeQuery, null, true, null, true, false, Integer.MAX_VALUE); assertTrue(iter != null && iter.hasNext());
final Iterator<Statement> iter = _tripleStore.range(rangeQuery, null, true, null, true, false, Integer.MAX_VALUE); assertTrue(iter != null && iter.hasNext());
final Iterator<Statement> rangeResultIterator = _tripleStore.range( query, buildLiteral(String.valueOf(_lowerBound)),
Iterator<Statement> iter = _tripleStore.range(query, buildLiteral(String.valueOf(lowerBound)), lower_equals, buildLiteral(String.valueOf(upperBound)), upper_equals, false, Integer.MAX_VALUE); assertTrue(iter != null && iter.hasNext());
query[0] = buildResource(_subject); query[1] = buildResource(_predicate); Iterator<Statement> iter = _tripleStore.range(query, buildLiteral(String.valueOf(_lowerBound)), true, buildLiteral(String.valueOf(_upperBound)), true, false, Integer.MAX_VALUE);
/** * If the range query has not a match on the store then an empty iterator must be returned. * * @throws Exception never, otherwise the test fails. */ @Test public void noSuchDataInTheStore() throws Exception { final URI unmatchingSubject = buildResource(randomString()); final URI unmatchingPredicate = buildResource(randomString()); assertEquals(0, numOfRes(_tripleStore.query(new Value[] { unmatchingSubject, null, null }))); assertEquals(0, numOfRes(_tripleStore.query(new Value[] { unmatchingSubject, unmatchingPredicate, null }))); final Value[][] invalidQueries = { { unmatchingSubject, unmatchingPredicate }, { null, unmatchingPredicate } }; for (final Value[] invalidQuery : invalidQueries) { assertEquals( "query " + invalidQuery + " must return an empty iterator.", 0, numOfRes(_tripleStore.range(invalidQuery, null, true, null, true, true, Integer.MAX_VALUE))); } }