AvroEventDeserializer implements EventDeserializer { @Override public void reset() throws IOException { long pos = ((RemoteMarkable) ris).getMarkPosition(); fileReader.sync(pos); } private  AvroEventDeserializer(Context context, ResettableInputStream ris); @Override Event readEvent(); @Override List<Event> readEvents(int numEvents); @Override void mark(); @Override void reset(); @Override void close(); static final String CONFIG_SCHEMA_TYPE_KEY; static final String AVRO_SCHEMA_HEADER_HASH; static final String AVRO_SCHEMA_HEADER_LITERAL; }
@Test public void resetTest() throws IOException { File tempFile = newTestFile(true); String target = tempFile.getAbsolutePath(); logger.info("Target: {}", target); TransientPositionTracker tracker = new TransientPositionTracker(target); AvroEventDeserializer.Builder desBuilder = new AvroEventDeserializer.Builder(); EventDeserializer deserializer = desBuilder.build(new Context(), new ResettableFileInputStream(tempFile, tracker)); BinaryDecoder decoder = null; DatumReader<GenericRecord> reader = new GenericDatumReader<GenericRecord>(schema); decoder = DecoderFactory.get().binaryDecoder( deserializer.readEvent().getBody(), decoder); assertEquals("bar", reader.read(null, decoder).get("foo").toString()); deserializer.reset(); decoder = DecoderFactory.get().binaryDecoder( deserializer.readEvent().getBody(), decoder); assertEquals("bar", reader.read(null, decoder).get("foo").toString()); deserializer.mark(); decoder = DecoderFactory.get().binaryDecoder( deserializer.readEvent().getBody(), decoder); assertEquals("baz", reader.read(null, decoder).get("foo").toString()); deserializer.reset(); decoder = DecoderFactory.get().binaryDecoder( deserializer.readEvent().getBody(), decoder); assertEquals("baz", reader.read(null, decoder).get("foo").toString()); assertNull(deserializer.readEvent()); }