public boolean hasNext() { while (curFileIndex < filePaths.size()) { if (curReader.hasNext()) { return true; } curReader.close(); curFileIndex++; if (curFileIndex < filePaths.size()) { curReader = HdfsReaderFactory.getHdfsReader(readerType, systemStreamPartition); curReader.open(filePaths.get(curFileIndex), "0"); } } return false; }
@Test public void testSequentialRead() throws Exception { SystemStreamPartition ssp = new SystemStreamPartition("hdfs", "testStream", new Partition(0)); SingleFileHdfsReader reader = new AvroFileHdfsReader(ssp); reader.open(AVRO_FILE, "0"); int index = 0; while (reader.hasNext()) { GenericRecord record = (GenericRecord) reader.readNext().getMessage(); Assert.assertEquals(index, record.get(FIELD_1)); Assert.assertEquals("string_" + index, record.get(FIELD_2).toString()); index++; } Assert.assertEquals(NUM_EVENTS, index); reader.close(); }