public static void assertCount(long expected, Stream stream) { org.junit.Assert.assertEquals(expected, stream.count()); }
@Benchmark public void serial_lazy_jdk() { long evens = this.integersJDK.stream().filter(each -> each % 2 == 0).count(); Assert.assertEquals(SIZE / 2, evens); }
@Test public void testLoadNonExistent() { assertEquals(0L, testSubject.readEvents(randomUUID().toString()).asStream().count()); }
@Benchmark public void parallel_lazy_jdk() { long evens = this.integersJDK.parallelStream().filter(each -> each % 2 == 0).count(); Assert.assertEquals(SIZE / 2, evens); }
@Test public void testNonDeterministic() { MaterializedResult materializedResult = computeActual("SELECT rand() FROM orders LIMIT 10"); long distinctCount = materializedResult.getMaterializedRows().stream() .map(row -> row.getField(0)) .distinct() .count(); assertTrue(distinctCount >= 8, "rand() must produce different rows"); materializedResult = computeActual("SELECT apply(1, x -> x + rand()) FROM orders LIMIT 10"); distinctCount = materializedResult.getMaterializedRows().stream() .map(row -> row.getField(0)) .distinct() .count(); assertTrue(distinctCount >= 8, "rand() must produce different rows"); }
@Benchmark public void serial_lazy_jdk() { long evens = this.integersJDK.stream().filter(each -> each % 2 == 0).count(); Assert.assertEquals(SIZE / 2, evens); }
@Test public void largeTest() throws Exception { final int numDoc = 30000; final String store = "vertex"; initialize(store); for (int i = 1; i <= numDoc; i++) { add(store, "doc" + i, getRandomDocument(), true); } clopen(); final long time = System.currentTimeMillis(); Stream<String> result = tx.queryStream(new IndexQuery(store, And.of(PredicateCondition.of(WEIGHT, Cmp.GREATER_THAN_EQUAL, 0.2), PredicateCondition.of(WEIGHT, Cmp.LESS_THAN, 0.6), PredicateCondition.of(LOCATION, Geo.WITHIN, Geoshape.circle(48.5, 0.5, 1000.00))))); final long oldResultSize = result.count(); System.out.println(oldResultSize + " vs " + (numDoc / 1000 * 2.4622623015)); System.out.println("Query time on " + numDoc + " docs (ms): " + (System.currentTimeMillis() - time)); result = tx.queryStream(new IndexQuery(store, And.of(PredicateCondition.of(WEIGHT, Cmp.GREATER_THAN_EQUAL, 0.2), PredicateCondition.of(WEIGHT, Cmp.LESS_THAN, 0.6), PredicateCondition.of(LOCATION, Geo.WITHIN, Geoshape.circle(48.5, 0.5, 1000.00))), numDoc / 1000)); assertEquals(numDoc / 1000, result.count()); result = tx.queryStream(new IndexQuery(store, And.of(PredicateCondition.of(WEIGHT, Cmp.GREATER_THAN_EQUAL, 0.2), PredicateCondition.of(WEIGHT, Cmp.LESS_THAN, 0.6), PredicateCondition.of(LOCATION, Geo.WITHIN, Geoshape.circle(48.5, 0.5, 1000.00))), numDoc / 1000 * 100)); assertEquals(oldResultSize, result.count()); }
@Benchmark public void parallel_lazy_jdk() { long evens = this.integersJDK.parallelStream().filter(each -> each % 2 == 0).count(); Assert.assertEquals(SIZE / 2, evens); }