@Test public void testCreate_DirectoryPresentButNoFiles() throws IOException{ String inputFilePath = Files.createTempDir().getAbsolutePath(); Configuration conf = new Configuration(); LocalFileSystem local = FileSystem.getLocal(conf); Iterable<String> iterable = CompositePathIterable.create(local, new Path(inputFilePath), new TextFileReaderFactory<String>(Writables.strings(), conf)); assertTrue(Lists.newArrayList(iterable).isEmpty()); }
public static <S> Iterable<S> create(FileSystem fs, Path path, FileReaderFactory<S> readerFactory) throws IOException { if (!fs.exists(path)){ throw new IOException("No files found to materialize at: " + path); } FileStatus[] stati = null; try { stati = fs.listStatus(path, FILTER); } catch (FileNotFoundException e) { stati = null; } if (stati == null) { throw new IOException("No files found to materialize at: " + path); } if (stati.length == 0) { return Collections.emptyList(); } else { return new CompositePathIterable<S>(stati, fs, readerFactory); } }
CompositePathIterable implements Iterable<T> { public static <S> Iterable<S> create(FileSystem fs, Path path, FileReaderFactory<S> readerFactory) throws IOException { if (!fs.exists(path)){ throw new IOException("No files found to materialize at: " + path); } FileStatus[] stati = null; try { stati = fs.listStatus(path, FILTER); } catch (FileNotFoundException e) { stati = null; } if (stati == null) { throw new IOException("No files found to materialize at: " + path); } if (stati.length == 0) { return Collections.emptyList(); } else { return new CompositePathIterable<S>(stati, fs, readerFactory); } } }
CompositePathIterable implements Iterable<T> { public static <S> Iterable<S> create(FileSystem fs, Path path, FileReaderFactory<S> readerFactory) throws IOException { if (!fs.exists(path)){ throw new IOException("No files found to materialize at: " + path); } FileStatus[] stati = null; try { stati = fs.listStatus(path, FILTER); } catch (FileNotFoundException e) { stati = null; } if (stati == null) { throw new IOException("No files found to materialize at: " + path); } if (stati.length == 0) { return Collections.emptyList(); } else { return new CompositePathIterable<S>(stati, fs, readerFactory); } } private  CompositePathIterable(FileStatus[] stati, FileSystem fs, FileReaderFactory<T> readerFactory); }
CompositePathIterable implements Iterable<T> { public static <S> Iterable<S> create(FileSystem fs, Path path, FileReaderFactory<S> readerFactory) throws IOException { if (!fs.exists(path)){ throw new IOException("No files found to materialize at: " + path); } FileStatus[] stati = null; try { stati = fs.listStatus(path, FILTER); } catch (FileNotFoundException e) { stati = null; } if (stati == null) { throw new IOException("No files found to materialize at: " + path); } if (stati.length == 0) { return Collections.emptyList(); } else { return new CompositePathIterable<S>(stati, fs, readerFactory); } } private  CompositePathIterable(FileStatus[] stati, FileSystem fs, FileReaderFactory<T> readerFactory); static Iterable<S> create(FileSystem fs, Path path, FileReaderFactory<S> readerFactory); @Override Iterator<T> iterator(); }
CompositePathIterable implements Iterable<T> { public static <S> Iterable<S> create(FileSystem fs, Path path, FileReaderFactory<S> readerFactory) throws IOException { if (!fs.exists(path)){ throw new IOException("No files found to materialize at: " + path); } FileStatus[] stati = null; try { stati = fs.listStatus(path, FILTER); } catch (FileNotFoundException e) { stati = null; } if (stati == null) { throw new IOException("No files found to materialize at: " + path); } if (stati.length == 0) { return Collections.emptyList(); } else { return new CompositePathIterable<S>(stati, fs, readerFactory); } } private  CompositePathIterable(FileStatus[] stati, FileSystem fs, FileReaderFactory<T> readerFactory); static Iterable<S> create(FileSystem fs, Path path, FileReaderFactory<S> readerFactory); @Override Iterator<T> iterator();  }