Package io.delta.kernel.utils
Interface CloseableIterator<T>
- Type Parameters:
T- the type of elements returned by this iterator
- All Superinterfaces:
AutoCloseable,Closeable,Iterator<T>
Closeable extension of
Iterator- Since:
- 3.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumRepresents the result of applying the filter condition in thebreakableFilter(Function)method of aCloseableIterator. -
Method Summary
Modifier and TypeMethodDescriptiondefault CloseableIterator<T>Returns a newCloseableIteratorthat applies aCloseableIterator.BreakableFilterResult-based filtering function to determine whether elements of this iterator should be included or excluded, or whether the iteration should terminate.default CloseableIterator<T>combine(CloseableIterator<T> other) Combine the current iterator with another iterator.default CloseableIterator<T>Returns a newCloseableIteratorthat includes only the elements of this iterator for which the givenmapperfunction returnstrue.booleanhasNext()Returns true if the iteration has more elements.default <U> CloseableIterator<U>next()Returns the next element in the iteration.default CloseableIterator<T>Returns a newCloseableIteratorthat includes elements from this iterator as long as the givenmapperfunction returnstrue.Collects all elements from thisCloseableIteratorinto aList.Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Method Details
-
hasNext
boolean hasNext()Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)- Specified by:
hasNextin interfaceIterator<T>- Returns:
- true if the iteration has more elements
- Throws:
KernelEngineException- For any underlying exception occurs inEnginewhile trying to execute the operation. The original exception is (if any) wrapped in this exception as cause. E.g.IOExceptionthrown while trying to read from a Delta log file. It will be wrapped in this exception as cause.KernelException- When encountered an operation or state that is invalid or unsupported.
-
next
T next()Returns the next element in the iteration.- Specified by:
nextin interfaceIterator<T>- Returns:
- the next element in the iteration
- Throws:
NoSuchElementException- if the iteration has no more elementsKernelEngineException- For any underlying exception occurs inEnginewhile trying to execute the operation. The original exception is (if any) wrapped in this exception as cause. E.g.IOExceptionthrown while trying to read from a Delta log file. It will be wrapped in this exception as cause.KernelException- When encountered an operation or state that is invalid or unsupported in Kernel. For example, trying to read from a Delta table that has advanced features which are not yet supported by Kernel.
-
map
-
filter
Returns a newCloseableIteratorthat includes only the elements of this iterator for which the givenmapperfunction returnstrue.- Parameters:
mapper- A function that determines whether an element should be included in the resulting iterator.- Returns:
- A
CloseableIteratorthat includes only the filtered the elements of this iterator.
-
takeWhile
Returns a newCloseableIteratorthat includes elements from this iterator as long as the givenmapperfunction returnstrue. Once the mapper function returnsfalse, the iteration is terminated.- Parameters:
mapper- A function that determines whether to include an element in the resulting iterator.- Returns:
- A
CloseableIteratorthat stops iteration when the condition is not met.
-
breakableFilter
default CloseableIterator<T> breakableFilter(Function<T, CloseableIterator.BreakableFilterResult> mapper) Returns a newCloseableIteratorthat applies aCloseableIterator.BreakableFilterResult-based filtering function to determine whether elements of this iterator should be included or excluded, or whether the iteration should terminate.- Parameters:
mapper- A function that determines the filtering action for each element: include, exclude, or break.- Returns:
- A
CloseableIteratorthat applies the specifiedCloseableIterator.BreakableFilterResult-based logic.
-
combine
Combine the current iterator with another iterator. The resulting iterator will return all elements from the current iterator followed by all elements from the other iterator.- Parameters:
other- the other iterator to combine with- Returns:
- a new iterator that combines the current iterator with the other iterator
-
toInMemoryList
Collects all elements from thisCloseableIteratorinto aList.This method iterates through all elements of the iterator, storing them in an in-memory list. Once iteration is complete, the iterator is automatically closed to release any underlying resources.
- Returns:
- A
Listcontaining all elements from this iterator. - Throws:
UncheckedIOException- If anIOExceptionoccurs while closing the iterator.
-