List of usage examples for org.apache.hadoop.fs RemoteIterator RemoteIterator
RemoteIterator
From source file:co.cask.cdap.common.io.Locations.java
License:Apache License
/** * Converts a {@link Iterator} into {@link RemoteIterator}. *//* ww w. j a v a2 s. c o m*/ private static <E> RemoteIterator<E> asRemoteIterator(final Iterator<? extends E> itor) { return new RemoteIterator<E>() { @Override public boolean hasNext() throws IOException { return itor.hasNext(); } @Override public E next() throws IOException { return itor.next(); } }; }
From source file:co.cask.cdap.common.io.Locations.java
License:Apache License
/** * Transform a {@link RemoteIterator} using a {@link FunctionWithException}. *///from ww w . j a v a 2 s .co m private static <F, T> RemoteIterator<T> transform(final RemoteIterator<F> itor, final FunctionWithException<F, T, IOException> transform) { return new RemoteIterator<T>() { @Override public boolean hasNext() throws IOException { return itor.hasNext(); } @Override public T next() throws IOException { return transform.apply(itor.next()); } }; }
From source file:com.facebook.presto.hive.PrestoS3FileSystem.java
License:Apache License
@Override public RemoteIterator<LocatedFileStatus> listLocatedStatus(final Path path) throws IOException { return new RemoteIterator<LocatedFileStatus>() { private final Iterator<LocatedFileStatus> iterator = listPrefix(path); @Override//from ww w.ja va2s .c om public boolean hasNext() throws IOException { try { return iterator.hasNext(); } catch (AmazonClientException e) { throw new IOException(e); } } @Override public LocatedFileStatus next() throws IOException { try { return iterator.next(); } catch (AmazonClientException e) { throw new IOException(e); } } }; }
From source file:com.facebook.presto.hive.s3.PrestoS3FileSystem.java
License:Apache License
@Override public RemoteIterator<LocatedFileStatus> listLocatedStatus(Path path) { STATS.newListLocatedStatusCall();/*www . j a v a2 s . com*/ return new RemoteIterator<LocatedFileStatus>() { private final Iterator<LocatedFileStatus> iterator = listPrefix(path); @Override public boolean hasNext() throws IOException { try { return iterator.hasNext(); } catch (AmazonClientException e) { throw new IOException(e); } } @Override public LocatedFileStatus next() throws IOException { try { return iterator.next(); } catch (AmazonClientException e) { throw new IOException(e); } } }; }
From source file:com.facebook.presto.hive.util.TestAsyncRecursiveWalker.java
License:Apache License
private static <E> RemoteIterator<E> remoteIterator(final Iterator<E> iterator) { return new RemoteIterator<E>() { @Override//from w w w. j a va 2s . c o m public boolean hasNext() { return iterator.hasNext(); } @Override public E next() { return iterator.next(); } }; }
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
/** * List cache directives. Incrementally fetches results from the server. * /*from w ww. j a va2 s .c om*/ * @param filter * Filter parameters to use when listing the directives, null to * list all directives visible to us. * @return A RemoteIterator which returns CacheDirectiveInfo objects. */ public RemoteIterator<CacheDirectiveEntry> listCacheDirectives(CacheDirectiveInfo filter) throws IOException { if (filter == null) { filter = new CacheDirectiveInfo.Builder().build(); } if (filter.getPath() != null) { filter = new CacheDirectiveInfo.Builder(filter) .setPath(new Path(getPathName(fixRelativePart(filter.getPath())))).build(); } final RemoteIterator<CacheDirectiveEntry> iter = dfs.listCacheDirectives(filter); return new RemoteIterator<CacheDirectiveEntry>() { @Override public boolean hasNext() throws IOException { return iter.hasNext(); } @Override public CacheDirectiveEntry next() throws IOException { // Although the paths we get back from the NameNode should always be // absolute, we call makeQualified to add the scheme and authority of // this DistributedFilesystem. CacheDirectiveEntry desc = iter.next(); CacheDirectiveInfo info = desc.getInfo(); Path p = info.getPath().makeQualified(getUri(), getWorkingDirectory()); return new CacheDirectiveEntry(new CacheDirectiveInfo.Builder(info).setPath(p).build(), desc.getStats()); } }; }
From source file:de.zib.sfs.StatisticsFileSystem.java
License:BSD License
@Override public RemoteIterator<Path> listCorruptFileBlocks(Path path) throws IOException { final UnwrappedPath unwrappedPath = unwrapPath(path); final RemoteIterator<Path> it = this.wrappedFS.listCorruptFileBlocks(unwrappedPath); return new RemoteIterator<Path>() { @Override//from w ww .j a v a 2s . c om public boolean hasNext() throws IOException { return it.hasNext(); } @Override public Path next() throws IOException { return unwrappedPath.isUnwrapped() ? wrapPath(it.next()) : it.next(); } }; }
From source file:de.zib.sfs.StatisticsFileSystem.java
License:BSD License
@Override public RemoteIterator<LocatedFileStatus> listFiles(Path f, boolean recursive) throws FileNotFoundException, IOException { final UnwrappedPath unwrappedPath = unwrapPath(f); final RemoteIterator<LocatedFileStatus> it = this.wrappedFS.listFiles(unwrappedPath, recursive); return new RemoteIterator<LocatedFileStatus>() { @Override//from ww w. j a va 2 s. c o m public boolean hasNext() throws IOException { return it.hasNext(); } @Override public LocatedFileStatus next() throws IOException { LocatedFileStatus fileStatus = it.next(); if (unwrappedPath.isUnwrapped()) { fileStatus.setPath(setAuthority(wrapPath(fileStatus.getPath()), f.toUri().getAuthority())); } return fileStatus; } }; }
From source file:de.zib.sfs.StatisticsFileSystem.java
License:BSD License
@Override public RemoteIterator<LocatedFileStatus> listLocatedStatus(Path f) throws FileNotFoundException, IOException { final UnwrappedPath unwrappedPath = unwrapPath(f); final RemoteIterator<LocatedFileStatus> it = this.wrappedFS.listLocatedStatus(unwrappedPath); return new RemoteIterator<LocatedFileStatus>() { @Override/* w w w. java 2 s.c om*/ public boolean hasNext() throws IOException { return it.hasNext(); } @Override public LocatedFileStatus next() throws IOException { LocatedFileStatus fileStatus = it.next(); if (unwrappedPath.isUnwrapped()) { fileStatus.setPath(setAuthority(wrapPath(fileStatus.getPath()), f.toUri().getAuthority())); } return fileStatus; } }; }
From source file:org.apache.hive.common.util.MockFileSystem.java
License:Apache License
@Override public RemoteIterator<LocatedFileStatus> listLocatedStatus(final Path f) throws IOException { return new RemoteIterator<LocatedFileStatus>() { private Iterator<LocatedFileStatus> iterator = listLocatedFileStatuses(f).iterator(); @Override//from ww w .jav a2 s . c o m public boolean hasNext() throws IOException { return iterator.hasNext(); } @Override public LocatedFileStatus next() throws IOException { return iterator.next(); } }; }