/** * Unit test for correct rendering of a partial chunk when an element has * already been drawn from the iterator. */ public void test_filter2() { IChunkedIterator<Long> itr = new ChunkedStriterator(Arrays.asList( new Long[] { 1L, 2L, 3L }).iterator()) .addFilter(new ChunkedFilter<IChunkedIterator<Long>, Long, Long>() { @Override protected Long[] filterChunk(Long[] chunk) { for (int i = 0; i < chunk.length; i++) { chunk[i] *= 2; } return chunk; } }); assertEquals(Long.valueOf(2L), itr.next()); assertEquals(new Long[] { 4L, 6L }, itr.nextChunk()); }
/** * Unit test for correct rendering of a partial chunk when an element has * already been drawn from the iterator. */ public void test_filter2() { IChunkedIterator<Long> itr = new ChunkedStriterator(Arrays.asList( new Long[] { 1L, 2L, 3L }).iterator()) .addFilter(new ChunkedFilter<IChunkedIterator<Long>, Long, Long>() { @Override protected Long[] filterChunk(Long[] chunk) { for (int i = 0; i < chunk.length; i++) { chunk[i] *= 2; } return chunk; } }); assertEquals(Long.valueOf(2L), itr.next()); assertEquals(new Long[] { 4L, 6L }, itr.nextChunk()); }
/** * {@inheritDoc} * <p> * When <code>exact == false</code> this does not count the backchained * entailments. When <code>exact == true</code> traverses the * {@link #iterator()} so as to produce an exact count of the #of elements * that would in fact be visited, which combines those from the database * with those generated dynamically (NOT efficient). */ @Override public long rangeCount(boolean exact) { if (!exact) return accessPath.rangeCount(exact); log.warn("Will materialize statements and generate inferences"); final IChunkedIterator<ISPO> itr = iterator(); long n = 0L; try { while (itr.hasNext()) { itr.next(); n++; } } finally { itr.close(); } return n; }
/** * {@inheritDoc} * <p> * When <code>exact == false</code> this does not count the backchained * entailments. When <code>exact == true</code> traverses the * {@link #iterator()} so as to produce an exact count of the #of elements * that would in fact be visited, which combines those from the database * with those generated dynamically (NOT efficient). */ @Override public long rangeCount(boolean exact) { if (!exact) return accessPath.rangeCount(exact); log.warn("Will materialize statements and generate inferences"); final IChunkedIterator<ISPO> itr = iterator(); long n = 0L; try { while (itr.hasNext()) { itr.next(); n++; } } finally { itr.close(); } return n; }
tmp.add(itr.next());
tmp.add(itr.next());
right.set(distinctVar, new Constant(rightItr.next()));
right.set(distinctVar, new Constant(rightItr.next()));