Class IteratorCachingResultSet<O>
- java.lang.Object
-
- com.googlecode.cqengine.resultset.ResultSet<O>
-
- com.googlecode.cqengine.resultset.common.WrappedResultSet<O>
-
- com.googlecode.cqengine.resultset.common.IteratorCachingResultSet<O>
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<O>
public class IteratorCachingResultSet<O> extends WrappedResultSet<O>
AResultSet
which wraps a backing ResultSet, and which caches the iterator returned by the backing ResultSet, to enable repeated invocations onIteratorCachingResultSet.iterator().hasNext()
, to avoid each time requesting a new iterator from the backing ResultSet. An effect of this caching is that if the application callsResultSet.isEmpty()
orResultSet.isNotEmpty()
on this ResultSet before it begins iteration, only one iterator will actually be requested from the backing ResultSet because the cached iterator will be reused each time. On the other hand, whenever the application actually begins to iterate through results, this ResultSet will detect it, and ifiterator()
is invoked again, it will avoid returning the same cached iterator and will obtain a new iterator instead.- Author:
- niall.gallagher
-
-
Field Summary
-
Fields inherited from class com.googlecode.cqengine.resultset.common.WrappedResultSet
wrappedResultSet
-
-
Constructor Summary
Constructors Constructor Description IteratorCachingResultSet(ResultSet<O> backingResultSet)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator<O>
iterator()
-
Methods inherited from class com.googlecode.cqengine.resultset.common.WrappedResultSet
close, contains, getMergeCost, getQuery, getQueryOptions, getRetrievalCost, matches, size
-
Methods inherited from class com.googlecode.cqengine.resultset.ResultSet
isEmpty, isNotEmpty, spliterator, stream, uniqueResult
-
-