Package krati.store.avro

Examples of krati.store.avro.AvroGenericRecordResolvingSerializer


       
        Serializer<GenericRecord> readerSerializer =
            new AvroGenericRecordSerializer(readerSchema);
       
        Serializer<GenericRecord> resolvingSerializer =
            new AvroGenericRecordResolvingSerializer(writerSchema, readerSchema);
       
        GenericRecord record = createRecordV1(writerSchema, 1);
        writerBytes = writerSerializer.serialize(record);
       
        GenericRecord record1 = writerSerializer.deserialize(writerBytes);
        assertEquals(record.get("id"), record1.get("id"));
        assertEquals(record.get("age"), record1.get("age"));
        assertEquals(record.get("fname"), record1.get("fname"));
        assertEquals(record.get("lname"), record1.get("lname"));
       
        GenericRecord record2 = null;
        try {
            record2 = readerSerializer.deserialize(writerBytes);
        } catch(SerializationException e) {}
        assertNull(record2);
       
        GenericRecord record3 = resolvingSerializer.deserialize(writerBytes);
        assertEquals(record.get("id"), record3.get("id"));
        assertEquals(record.get("age"), record3.get("age"));
        assertEquals(record.get("fname"), record3.get("fname"));
        assertEquals(record.get("lname"), record3.get("lname"));
    }
View Full Code Here

TOP

Related Classes of krati.store.avro.AvroGenericRecordResolvingSerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.