Package io.delta.kernel.internal.util
Class Utils
Object
io.delta.kernel.internal.util.Utils
Various utility methods to help the connectors work with data objects returned by Kernel
- Since:
- 3.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseCloseables(AutoCloseable... closeables) Close the given one or moreAutoCloseables.static voidcloseCloseablesSilently(AutoCloseable... closeables) Close the given list ofAutoCloseableobjects.static <T> CloseableIterator<T> flatten(CloseableIterator<CloseableIterator<T>> nestedIterator) Flattens a nestedCloseableIteratorstructure into a single flat iterator.static CloseableIterator<Row> intoRows(CloseableIterator<FilteredColumnarBatch> sourceBatches) Convert a ClosableIterator of FilteredColumnarBatch into a CloseableIterator of Rowstatic <T> Optional<T> iteratorLast(CloseableIterator<T> iterator) Returns the last element from the givenCloseableIterator, if present.static StringresolvePath(Engine engine, String path) static <T> CloseableIterator<T> singletonCloseableIterator(T elem) Utility method to create a singletonCloseableIterator.static <T> CloseableIterator<T> toCloseableIterator(Iterator<T> iter) Convert aIteratortoCloseableIterator.
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
singletonCloseableIterator
Utility method to create a singletonCloseableIterator.- Type Parameters:
T- Element type.- Parameters:
elem- Element to create iterator with.- Returns:
- A
CloseableIteratorwith just one element.
-
toCloseableIterator
Convert aIteratortoCloseableIterator. Useful when passing normal iterators for arguments that requireCloseableIteratortype.- Type Parameters:
T- Element type- Parameters:
iter-Iteratorinstance- Returns:
- A
CloseableIteratorwrapping the givenIterator
-
closeCloseables
Close the given one or moreAutoCloseables.AutoCloseable.close()will be called on all given non-null closeables. Will throw uncheckedRuntimeExceptionif an error occurs while closing. If multiple closeables causes exceptions in closing, the exceptions will be added as suppressed to the main exception that is thrown.- Parameters:
closeables-
-
closeCloseablesSilently
Close the given list ofAutoCloseableobjects. Any exception thrown is silently ignored.- Parameters:
closeables-
-
intoRows
public static CloseableIterator<Row> intoRows(CloseableIterator<FilteredColumnarBatch> sourceBatches) Convert a ClosableIterator of FilteredColumnarBatch into a CloseableIterator of Row -
flatten
public static <T> CloseableIterator<T> flatten(CloseableIterator<CloseableIterator<T>> nestedIterator) Flattens a nestedCloseableIteratorstructure into a single flat iterator. This method takes an iterator of iterators (nested structure) and flattens it into a single iterator that yields all elements from all inner iterators in sequence.Important: Callers must call
Closeable.close()on the returned iterator even if it is not fully consumed, to ensure all inner iterators are properly closed and resources are released.- Type Parameters:
T- The type of elements in the inner iterators- Parameters:
nestedIterator- An iterator of iterators to flatten- Returns:
- A new
CloseableIteratorthat flattens all nested iterators
-
iteratorLast
Returns the last element from the givenCloseableIterator, if present.This method iterates through all elements of the iterator to find the last one. Once iteration is complete, the iterator is automatically closed to release any underlying resources.
- Type Parameters:
T- The type of elements in the iterator- Parameters:
iterator- The iterator to get the last element from- Returns:
- An
Optionalcontaining the last element, orOptional.empty()if the iterator is empty. - Throws:
UncheckedIOException- If anIOExceptionoccurs while closing the iterator.
-
resolvePath
-