Package org.apache.iceberg.io
Interface CloseableIterable<T>
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
,java.lang.Iterable<T>
- All Known Implementing Classes:
AvroIterable
,CloseableIterable.ConcatCloseableIterable
,ManifestReader
,ParallelIterable
,ParquetIterable
,ParquetReader
,SortedMerge
,VectorizedParquetReader
,VectorizedTableScanIterable
public interface CloseableIterable<T> extends java.lang.Iterable<T>, java.io.Closeable
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
CloseableIterable.ConcatCloseableIterable<E>
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <E> CloseableIterable<E>
combine(java.lang.Iterable<E> iterable, java.io.Closeable closeable)
static <E> CloseableIterable<E>
concat(java.lang.Iterable<CloseableIterable<E>> iterable)
static <T> CloseableIterable<T>
count(Counter counter, CloseableIterable<T> iterable)
Counts the number of elements in the givenCloseableIterable
by incrementing theCounter
instance for eachIterator.next()
call.static <E> CloseableIterable<E>
empty()
static <E> CloseableIterable<E>
filter(CloseableIterable<E> iterable, java.util.function.Predicate<E> pred)
static <E> CloseableIterable<E>
filter(Counter skipCounter, CloseableIterable<E> iterable, java.util.function.Predicate<E> pred)
Filters the givenCloseableIterable
and counts the number of elements that do not match the predicate by incrementing theCounter
.CloseableIterator<T>
iterator()
Returns a closeable iterator over elements of typeT
.static <I,O>
CloseableIterable<O>transform(CloseableIterable<I> iterable, java.util.function.Function<I,O> transform)
static <E> CloseableIterable<E>
whenComplete(CloseableIterable<E> iterable, java.lang.Runnable onCompletionRunnable)
Will run the given runnable whenCloseable.close()
has been called.static <E> CloseableIterable<E>
withNoopClose(E entry)
static <E> CloseableIterable<E>
withNoopClose(java.lang.Iterable<E> iterable)
-
-
-
Method Detail
-
iterator
CloseableIterator<T> iterator()
Returns a closeable iterator over elements of typeT
.- Specified by:
iterator
in interfacejava.lang.Iterable<T>
- Returns:
- an
CloseableIterator
.
-
withNoopClose
static <E> CloseableIterable<E> withNoopClose(E entry)
-
withNoopClose
static <E> CloseableIterable<E> withNoopClose(java.lang.Iterable<E> iterable)
-
empty
static <E> CloseableIterable<E> empty()
-
combine
static <E> CloseableIterable<E> combine(java.lang.Iterable<E> iterable, java.io.Closeable closeable)
-
whenComplete
static <E> CloseableIterable<E> whenComplete(CloseableIterable<E> iterable, java.lang.Runnable onCompletionRunnable)
Will run the given runnable whenCloseable.close()
has been called.- Type Parameters:
E
- The type of the underlying iterable- Parameters:
iterable
- The underlyingCloseableIterable
to iterate overonCompletionRunnable
- The runnable to run after the underlying iterable was closed- Returns:
- A new
CloseableIterable
where the runnable will be executed as the final step afterCloseable.close()
has been called
-
filter
static <E> CloseableIterable<E> filter(CloseableIterable<E> iterable, java.util.function.Predicate<E> pred)
-
filter
static <E> CloseableIterable<E> filter(Counter skipCounter, CloseableIterable<E> iterable, java.util.function.Predicate<E> pred)
Filters the givenCloseableIterable
and counts the number of elements that do not match the predicate by incrementing theCounter
.- Type Parameters:
E
- The underlying type to be iterated.- Parameters:
skipCounter
- TheCounter
instance to increment on each skipped item during filtering.iterable
- The underlyingCloseableIterable
to filter.- Returns:
- A filtered
CloseableIterable
where the given skipCounter is incremented whenever the predicate does not match.
-
count
static <T> CloseableIterable<T> count(Counter counter, CloseableIterable<T> iterable)
Counts the number of elements in the givenCloseableIterable
by incrementing theCounter
instance for eachIterator.next()
call.- Type Parameters:
T
- The underlying type to be iterated.- Parameters:
counter
- TheCounter
instance to increment on eachIterator.next()
call.iterable
- The underlyingCloseableIterable
to count- Returns:
- A
CloseableIterable
that increments the given counter on eachIterator.next()
call.
-
transform
static <I,O> CloseableIterable<O> transform(CloseableIterable<I> iterable, java.util.function.Function<I,O> transform)
-
concat
static <E> CloseableIterable<E> concat(java.lang.Iterable<CloseableIterable<E>> iterable)
-
-