There there is another option to solve this using Kryo's @Bind annotation
for the field. Example:

@Bind(JavaSerializer.class)
SetMultimap<String, String> someMap;

This will work when there is an existing alternative serializer for the
type in question.



On Sat, Nov 14, 2015 at 9:47 AM, Michael Ravits <[email protected]>
wrote:

> Thanks!
>
> On Fri, Nov 13, 2015 at 4:55 PM, Gaurav Gupta <[email protected]>
> wrote:
>
> > Michael,
> >
> >
> > Here is what you should do..
> >
> > Create a new Serializer
> >
> >
> > import java.io.IOException;
> >
> > import java.io.ObjectInputStream;
> >
> > import java.util.UUID;
> >
> >
> > import com.esotericsoftware.kryo.Kryo;
> >
> >
> > public class CustomeSerializableStreamCodec<T> extends
> > com.datatorrent.lib.codec.KryoSerializableStreamCodec
> >
> > {
> >
> >
> >   public CustomeSerializableStreamCodec()
> >
> >   {
> >
> >    super();
> >
> >   }
> >
> >   private void readObject(ObjectInputStream in) throws IOException,
> > ClassNotFoundException
> >
> >   {
> >
> >     in.defaultReadObject();
> >
> >     this.kryo = new Kryo();
> >
> >
> > this.kryo.setClassLoader(Thread.currentThread().getContextClassLoader());
> >
> >     this.kryo.register(UUID.class, new UUIDSerializer()); // Register
> your
> > classes here
> >
> >   ]
> >
> >   private static final long serialVersionUID = 201411031405L;
> >
> > }
> >
> >
> > In your DAG, use this Serializer on the input port that is expecting the
> > UUID tuple something like this
> >
> >
> > CustomeSerializableStreamCodec codec = new
> > CustomeSerializableStreamCodec<>();
> >
> > dag.setInputPortAttribute(output.input, Context.PortContext.STREAM_CODEC,
> > codec);
> >
> > Thanks
> > -Gaurav
> >
> > On Fri, Nov 13, 2015 at 6:16 AM, Michael Ravits <[email protected]>
> > wrote:
> >
> > > Hi Gaurav,
> > >
> > > I've found this custom serializer:
> > >
> > >
> >
> https://github.com/magro/kryo-serializers/blob/master/src/main/java/de/javakaffee/kryoserializers/UUIDSerializer.java
> > >
> > > Question is where would be the correct place with regard to
> application's
> > > lifecycle to register this serializer.
> > >
> > > Michael
> > >
> > > On Fri, Nov 13, 2015 at 4:11 PM, Gaurav Gupta <[email protected]>
> > > wrote:
> > >
> > > > Michael,
> > > >
> > > > I think Kryo is complaining because UUID type doesn’t have default
> > > > constructor.
> > > >
> > > > Thanks
> > > > - Gaurav
> > > >
> > > > > On Nov 13, 2015, at 6:02 AM, Michael Ravits <[email protected]
> >
> > > > wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > I'm experimenting with incubating apex 3.1.1.
> > > > > I've tried sending an object with a UUID type property and Kryo
> > > > complained
> > > > > that there is no serializer for this type.
> > > > > Where would be the most appropriate place to register the UUID
> > > > serializer?
> > > > >
> > > > > Thanks,
> > > > > Michael
> > > >
> > > >
> > >
> >
>

Reply via email to