Package org.apache.flink.util
Interface CloseableIterator<T>
-
- Type Parameters:
T
- the type of iterated elements.
- All Superinterfaces:
AutoCloseable
,Iterator<T>
- All Known Implementing Classes:
CloseableIterator.IteratorAdapter
,CollectResultIterator
,FileBasedBufferIterator
,MultiStateKeyIterator
,StatementResult
@PublicEvolving public interface CloseableIterator<T> extends Iterator<T>, AutoCloseable
This interface represents anIterator
that is alsoAutoCloseable
. A typical use-case for this interface are iterators that are based on native-resources such as files, network, or database connections. Clients must callAutoCloseable.close()
after using the iterator.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
CloseableIterator.IteratorAdapter<E>
Adapter fromIterator
toCloseableIterator
.
-
Field Summary
Fields Modifier and Type Field Description static CloseableIterator<?>
EMPTY_INSTANCE
-
Method Summary
Static Methods Modifier and Type Method Description static <T> CloseableIterator<T>
adapterForIterator(Iterator<T> iterator)
static <T> CloseableIterator<T>
adapterForIterator(Iterator<T> iterator, AutoCloseable close)
static <T> CloseableIterator<T>
empty()
static <T> CloseableIterator<T>
flatten(CloseableIterator<T>... iterators)
static <T> CloseableIterator<T>
fromList(List<T> list, Consumer<T> closeNotConsumed)
static <E> CloseableIterator<E>
ofElement(E element, Consumer<E> closeIfNotConsumed)
static <T> CloseableIterator<T>
ofElements(Consumer<T> closeNotConsumed, T... elements)
-
Methods inherited from interface java.lang.AutoCloseable
close
-
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
-
-
-
Field Detail
-
EMPTY_INSTANCE
static final CloseableIterator<?> EMPTY_INSTANCE
-
-
Method Detail
-
adapterForIterator
@Nonnull static <T> CloseableIterator<T> adapterForIterator(@Nonnull Iterator<T> iterator)
-
adapterForIterator
static <T> CloseableIterator<T> adapterForIterator(@Nonnull Iterator<T> iterator, AutoCloseable close)
-
fromList
static <T> CloseableIterator<T> fromList(List<T> list, Consumer<T> closeNotConsumed)
-
flatten
static <T> CloseableIterator<T> flatten(CloseableIterator<T>... iterators)
-
empty
static <T> CloseableIterator<T> empty()
-
ofElements
static <T> CloseableIterator<T> ofElements(Consumer<T> closeNotConsumed, T... elements)
-
ofElement
static <E> CloseableIterator<E> ofElement(E element, Consumer<E> closeIfNotConsumed)
-
-