@Test(expected = DatasetIOException.class) public void testEmptyFile() throws IOException { final Path emptyFile = new Path("/tmp/empty-file.avro"); Assert.assertTrue("Failed to create a new empty file", fileSystem.createNewFile(emptyFile)); try { AbstractDatasetReader<String> reader = new FileSystemDatasetReader<String>( fileSystem, emptyFile, STRING_SCHEMA, String.class); Assert.assertNotNull(reader); reader.initialize(); } finally { Assert.assertTrue("Failed to clean up empty file", fileSystem.delete(emptyFile, true)); } }
@Override public void initialize() { Preconditions.checkState(state.equals(ReaderWriterState.NEW), "A reader may not be opened more than once - current state:%s", state); LOG.debug("Opening reader on path:{}", path); try { reader = new DataFileReader<E>(new AvroFSInput(fileSystem.open(path), fileSystem.getFileStatus(path).getLen()), DataModelUtil.getDatumReaderForType(type, schema)); } catch (IOException e) { throw new DatasetIOException("Unable to create reader path:" + path, e); } state = ReaderWriterState.OPEN; }
FileSystemDatasetReader extends AbstractDatasetReader<E> { @Override public void initialize() { Preconditions.checkState(state.equals(ReaderWriterState.NEW), "A reader may not be opened more than once - current state:%s", state); LOG.debug("Opening reader on path:{}", path); try { reader = new DataFileReader<E>(new AvroFSInput(fileSystem.open(path), fileSystem.getFileStatus(path).getLen()), DataModelUtil.getDatumReaderForType(type, schema)); } catch (IOException e) { throw new DatasetIOException("Unable to create reader path:" + path, e); } state = ReaderWriterState.OPEN; } }
FileSystemDatasetReader extends AbstractDatasetReader<E> { @Override public void initialize() { Preconditions.checkState(state.equals(ReaderWriterState.NEW), "A reader may not be opened more than once - current state:%s", state); LOG.debug("Opening reader on path:{}", path); try { reader = new DataFileReader<E>(new AvroFSInput(fileSystem.open(path), fileSystem.getFileStatus(path).getLen()), DataModelUtil.getDatumReaderForType(type, schema)); } catch (IOException e) { throw new DatasetIOException("Unable to create reader path:" + path, e); } state = ReaderWriterState.OPEN; } FileSystemDatasetReader(FileSystem fileSystem, Path path, Schema schema,
      Class<E> type); }
FileSystemDatasetReader extends AbstractDatasetReader<E> { @Override public void initialize() { Preconditions.checkState(state.equals(ReaderWriterState.NEW), "A reader may not be opened more than once - current state:%s", state); LOG.debug("Opening reader on path:{}", path); try { reader = new DataFileReader<E>(new AvroFSInput(fileSystem.open(path), fileSystem.getFileStatus(path).getLen()), DataModelUtil.getDatumReaderForType(type, schema)); } catch (IOException e) { throw new DatasetIOException("Unable to create reader path:" + path, e); } state = ReaderWriterState.OPEN; } FileSystemDatasetReader(FileSystem fileSystem, Path path, Schema schema,
      Class<E> type); @Override void initialize(); @Override boolean hasNext(); @Override E next(); @Override void close(); @Override boolean isOpen(); @Override String toString(); }
FileSystemDatasetReader extends AbstractDatasetReader<E> { @Override public void initialize() { Preconditions.checkState(state.equals(ReaderWriterState.NEW), "A reader may not be opened more than once - current state:%s", state); LOG.debug("Opening reader on path:{}", path); try { reader = new DataFileReader<E>(new AvroFSInput(fileSystem.open(path), fileSystem.getFileStatus(path).getLen()), DataModelUtil.getDatumReaderForType(type, schema)); } catch (IOException e) { throw new DatasetIOException("Unable to create reader path:" + path, e); } state = ReaderWriterState.OPEN; } FileSystemDatasetReader(FileSystem fileSystem, Path path, Schema schema,
      Class<E> type); @Override void initialize(); @Override boolean hasNext(); @Override E next(); @Override void close(); @Override boolean isOpen(); @Override String toString();  }