Thanks for your response. Till GenericSerializer is good but now I cannot use DatumWriter and DatumReader as each vertex in the graph could potentially have Avro GenericRecords with different Schema so when i read i would not be able to determine the schema to use to read the deserialized object. So i changed it to the following one using Kryo Serializer thats from Chill. I am trying to see some lib that could support avro GenericRecord out of the box similar to how Spark supports Avro with Kryo.
public void write(Kryo kryo, Output output, GenericRecord record) {
KryoPool kryoPool = KryoPool.withByteArrayOutputStream(10, new KryoInstantiator());
byte[] ser = kryoPool.toBytesWithClass(record);
output.writeBytes(ser);
}
public GenericRecord read(Kryo tinkerKryo, Input input, Class<GenericRecord> arg2) {
KryoPool kryoPool = KryoPool.withByteArrayOutputStream(10, new KryoInstantiator());
GenericRecord record = (GenericRecord) kryoPool.fromBytes(input.getBuffer());
return record;
}
Even in this case kryo serializer says that it is not a registered class. Below is the exception stack trace
java.lang.RuntimeException: com.esotericsoftware.kryo.KryoException: Encountered unregistered class ID: 101
at org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader$VertexInputIterator.next(GryoReader.java:329)
at org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader$VertexInputIterator.next(GryoReader.java:303)
at org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils.iterate(IteratorUtils.java:70)
at org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader.readGraph(GryoReader.java:94)
at com.jpmc.tv.graph.GraphProcessor.deserilaizeGraph(GraphProcessor.java:147)
at com.jpmc.tv.graph.VertexCreationTest.VertexCreationTest(VertexCreationTest.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Now i would have to register the avro classes again and end up coding my own avro serializers similar to what chill has in scala. I am trying to avoid that and reuse some that's already available.
Hope this makes sense and any suggestions or thoughts would be much appreciated.