public boolean hasNext() { while ((chunk == null || index == chunk.length) && src.hasNext()) { // fetch and filter another chunk. chunk = filter.filterChunk(src.nextChunk()); // reset the index into the current chunk. index = 0; } if (chunk == null || index == chunk.length) { // nothing left. return false; } return true; }
@Override public void remove() { src.remove(); }
/** * {@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; }
public void close() { if (open) { open = false; src.close(); } }
/** * 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()); }
@Override final public E[] nextChunk() { return src.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; }
public void close() { src.close(); chunk = null; terms = null; }
/** * 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()); }
@Override public E[] next() { return src.nextChunk(); }
public boolean hasNext() { while ((chunk == null || index == chunk.length) && src.hasNext()) { // fetch and filter another chunk. chunk = filter.filterChunk(src.nextChunk()); // reset the index into the current chunk. index = 0; } if (chunk == null || index == chunk.length) { // nothing left. return false; } return true; }