@InterfaceAudience.Public @InterfaceStability.Unstable public final class RemoteIterators extends Object
foreach(RemoteIterator, ConsumerRaisingIOE)
method will
LOG at debug any IOStatistics provided by the iterator, if such
statistics are provided. There's no attempt at retrieval and logging
if the LOG is not set to debug, so it is a zero cost feature unless
the logger org.apache.hadoop.fs.functional.RemoteIterators
is at DEBUG.
Based on the S3A Listing code, and some some work on moving other code
to using iterative listings so as to pick up the statistics.Modifier and Type | Method and Description |
---|---|
static <T> void |
cleanupRemoteIterator(org.apache.hadoop.fs.RemoteIterator<T> source)
Clean up after an iteration.
|
static <S> org.apache.hadoop.fs.RemoteIterator<S> |
closingRemoteIterator(org.apache.hadoop.fs.RemoteIterator<S> iterator,
Closeable toClose)
This adds an extra close operation alongside the passthrough
to any Closeable.close() method supported by the source iterator.
|
static <S> org.apache.hadoop.fs.RemoteIterator<S> |
filteringRemoteIterator(org.apache.hadoop.fs.RemoteIterator<S> iterator,
org.apache.hadoop.util.functional.FunctionRaisingIOE<? super S,Boolean> filter)
Create a RemoteIterator from a RemoteIterator and a filter
function which returns true for every element to be passed
through.
|
static <T> long |
foreach(org.apache.hadoop.fs.RemoteIterator<T> source,
org.apache.hadoop.util.functional.ConsumerRaisingIOE<? super T> consumer)
Apply an operation to all values of a RemoteIterator.
|
static <S,T> org.apache.hadoop.fs.RemoteIterator<T> |
mappingRemoteIterator(org.apache.hadoop.fs.RemoteIterator<S> iterator,
org.apache.hadoop.util.functional.FunctionRaisingIOE<? super S,T> mapper)
Create an iterator from an iterator and a transformation function.
|
static <T> org.apache.hadoop.fs.RemoteIterator<T> |
remoteIteratorFromArray(T[] array)
Create a remote iterator from an array.
|
static <T> org.apache.hadoop.fs.RemoteIterator<T> |
remoteIteratorFromIterable(Iterable<T> iterable)
Create a remote iterator from a java.util.Iterable -e.g.
|
static <T> org.apache.hadoop.fs.RemoteIterator<T> |
remoteIteratorFromIterator(Iterator<T> iterator)
Create a remote iterator from a java.util.Iterator.
|
static <T> org.apache.hadoop.fs.RemoteIterator<T> |
remoteIteratorFromSingleton(T singleton)
Create an iterator from a singleton.
|
static <T> T[] |
toArray(org.apache.hadoop.fs.RemoteIterator<T> source,
T[] a)
Build an array from a RemoteIterator.
|
static <T> List<T> |
toList(org.apache.hadoop.fs.RemoteIterator<T> source)
Build a list from a RemoteIterator.
|
static <S,T> org.apache.hadoop.fs.RemoteIterator<T> |
typeCastingRemoteIterator(org.apache.hadoop.fs.RemoteIterator<S> iterator)
Create a RemoteIterator from a RemoteIterator, casting the
type in the process.
|
public static <T> org.apache.hadoop.fs.RemoteIterator<T> remoteIteratorFromSingleton(@Nullable T singleton)
T
- typesingleton
- instancepublic static <T> org.apache.hadoop.fs.RemoteIterator<T> remoteIteratorFromIterator(Iterator<T> iterator)
T
- typepublic static <T> org.apache.hadoop.fs.RemoteIterator<T> remoteIteratorFromIterable(Iterable<T> iterable)
T
- typepublic static <T> org.apache.hadoop.fs.RemoteIterator<T> remoteIteratorFromArray(T[] array)
T
- typepublic static <S,T> org.apache.hadoop.fs.RemoteIterator<T> mappingRemoteIterator(org.apache.hadoop.fs.RemoteIterator<S> iterator, org.apache.hadoop.util.functional.FunctionRaisingIOE<? super S,T> mapper)
S
- source typeT
- result typeiterator
- sourcemapper
- transformationpublic static <S,T> org.apache.hadoop.fs.RemoteIterator<T> typeCastingRemoteIterator(org.apache.hadoop.fs.RemoteIterator<S> iterator)
S
- source typeT
- result typeiterator
- sourcepublic static <S> org.apache.hadoop.fs.RemoteIterator<S> filteringRemoteIterator(org.apache.hadoop.fs.RemoteIterator<S> iterator, org.apache.hadoop.util.functional.FunctionRaisingIOE<? super S,Boolean> filter)
next()
call.S
- typeiterator
- sourcefilter
- filterpublic static <S> org.apache.hadoop.fs.RemoteIterator<S> closingRemoteIterator(org.apache.hadoop.fs.RemoteIterator<S> iterator, Closeable toClose)
S
- source type.iterator
- sourcetoClose
- extra object to close.public static <T> List<T> toList(org.apache.hadoop.fs.RemoteIterator<T> source) throws IOException
T
- typesource
- source iteratorIOException
- if the source RemoteIterator raises it.public static <T> T[] toArray(org.apache.hadoop.fs.RemoteIterator<T> source, T[] a) throws IOException
T
- typesource
- source iteratora
- destination array; if too small a new array
of the same type is createdIOException
- if the source RemoteIterator raises it.public static <T> long foreach(org.apache.hadoop.fs.RemoteIterator<T> source, org.apache.hadoop.util.functional.ConsumerRaisingIOE<? super T> consumer) throws IOException
T
- type of sourcesource
- iterator sourceconsumer
- consumer of the values.IOException
- if the source RemoteIterator or the consumer raise one.public static <T> void cleanupRemoteIterator(org.apache.hadoop.fs.RemoteIterator<T> source)
T
- type of sourcesource
- iterator sourceCopyright © 2022 Apache Software Foundation. All rights reserved.