AvroFileHdfsReader implements SingleFileHdfsReader { public static int offsetComparator(String offset1, String offset2) { AvroFileCheckpoint cp1 = new AvroFileCheckpoint(offset1); AvroFileCheckpoint cp2 = new AvroFileCheckpoint(offset2); return cp1.compareTo(cp2); } AvroFileHdfsReader(SystemStreamPartition systemStreamPartition); @Override void open(String pathStr, String singleFileOffset); @Override void seek(String singleFileOffset); @Override IncomingMessageEnvelope readNext(); @Override boolean hasNext(); @Override void close(); @Override String nextOffset(); static int offsetComparator(String offset1, String offset2);  }
@Test public void testOffsetComparator() { Assert.assertEquals(-1, AvroFileHdfsReader.offsetComparator("0", "1452")); Assert.assertEquals(-1, AvroFileHdfsReader.offsetComparator("2001@3", "2001@4")); Assert.assertEquals(-1, AvroFileHdfsReader.offsetComparator("2001@4", "2010@1")); Assert.assertEquals(-1, AvroFileHdfsReader.offsetComparator("2001@3", "2011@3")); Assert.assertEquals(-1, AvroFileHdfsReader.offsetComparator("2001", "2001@4")); Assert.assertEquals(-1, AvroFileHdfsReader.offsetComparator("2001", "2010@1")); Assert.assertEquals(-1, AvroFileHdfsReader.offsetComparator("2001@3", "2010")); Assert.assertEquals(1, AvroFileHdfsReader.offsetComparator("1984", "0")); Assert.assertEquals(1, AvroFileHdfsReader.offsetComparator("1984@2", "1984@1")); Assert.assertEquals(1, AvroFileHdfsReader.offsetComparator("14341@2", "1984@2")); Assert.assertEquals(1, AvroFileHdfsReader.offsetComparator("14341@1", "1984@10")); Assert.assertEquals(1, AvroFileHdfsReader.offsetComparator("14341", "1984@10")); Assert.assertEquals(1, AvroFileHdfsReader.offsetComparator("14341@1", "1984")); Assert.assertEquals(0, AvroFileHdfsReader.offsetComparator("1989", "1989")); Assert.assertEquals(0, AvroFileHdfsReader.offsetComparator("1989@0", "1989")); Assert.assertEquals(0, AvroFileHdfsReader.offsetComparator("1989", "1989@0")); Assert.assertEquals(0, AvroFileHdfsReader.offsetComparator("0", "0")); Assert.assertEquals(0, AvroFileHdfsReader.offsetComparator("1989@1", "1989@1")); }
@Test(expected = Exception.class) public void testOffsetComparator_InvalidInput() { AvroFileHdfsReader.offsetComparator("1982,13", "1930,1"); }