RE: Binary Serialization of Enums By Name
Hi Stuart, I can see the value of storing enums by name. One thing is the problem you’ve described. The other is that they become more readable when the enum class is not present which is the case sometimes. However, I find having two built-in ways to serialize enums quite complicated. I’m sure it will lead to more issues in corner cases. So the only thing I would look into is possible migration from ordinal-based to name-based enum serialization in 3.0. But that’s 3.0. To solve your issue I would rather go with explicitly specified ordinals like public enum Foo { ONE(1), TWO(2), THREE(3) } Stan From: Stuart Macdonald Sent: Thursday, February 7, 2019 2:52 PM To: dev ; user@ignite.apache.org Subject: Re: Binary Serialization of Enums By Name Adding dev list. In the absence of any way of modifying binary serialization of enums, would the dev community consider accepting a pull request? Two options I would consider: 1. A custom “enum serialiser” on the BinaryTypeConfiguration and an associated enum serialization interface. 2. A flag on BinaryConfiguration oto specify serialization of enums by name rather than ordinal. Any other ideas would be appreciated. Stuart. On Mon, 4 Feb 2019 at 16:35, Stuart Macdonald mailto:stu...@stuwee.org> > wrote: Hi Mike, Thanks for the response. I can’t see how that’s possible with the current Binarylizable interface as enums are immutable, there’s no nullary constructor for an enum and we can’t update its name after construction. I gave it a shot to see what would happen but the read/write methods weren’t being called at all. Any other suggestions would be much appreciated. Stuart. On 4 Feb 2019, at 16:22, Michael Cherkasov mailto:michael.cherka...@gmail.com> > wrote: Hi Stuart, I think you can use Binarylizable interface, you can implement your one serialization for your enum. Thanks, Mike. пн, 4 февр. 2019 г. в 15:12, Stuart Macdonald mailto:stu...@stuwee.org> >: Igniters, I have some cache objects which contain enum fields, which when persisted through Ignite binary persistence are persisted using their enum ordinal position. However these enums are often modified whereby new values are inserted in the middle of the existing enum values, which breaks deserialization by ordinal. Does anyone know of a way to have Ignite serialize enums by name (ie. standard java enum serialization), or to allow for custom serialization routines for enums? Many thanks, Stuart.
Re: Binary Serialization of Enums By Name
Adding dev list. In the absence of any way of modifying binary serialization of enums, would the dev community consider accepting a pull request? Two options I would consider: 1. A custom “enum serialiser” on the BinaryTypeConfiguration and an associated enum serialization interface. 2. A flag on BinaryConfiguration oto specify serialization of enums by name rather than ordinal. Any other ideas would be appreciated. Stuart. On Mon, 4 Feb 2019 at 16:35, Stuart Macdonald wrote: > Hi Mike, > > Thanks for the response. I can’t see how that’s possible with the current > Binarylizable interface as enums are immutable, there’s no nullary > constructor for an enum and we can’t update its name after construction. I > gave it a shot to see what would happen but the read/write methods weren’t > being called at all. > > Any other suggestions would be much appreciated. > > Stuart. > > On 4 Feb 2019, at 16:22, Michael Cherkasov > wrote: > > Hi Stuart, > > I think you can use Binarylizable interface, you can implement your one > serialization for your enum. > > Thanks, > Mike. > > пн, 4 февр. 2019 г. в 15:12, Stuart Macdonald : > >> Igniters, >> >> I have some cache objects which contain enum fields, which when persisted >> through Ignite binary persistence are persisted using their enum ordinal >> position. However these enums are often modified whereby new values are >> inserted in the middle of the existing enum values, which breaks >> deserialization by ordinal. Does anyone know of a way to have Ignite >> serialize enums by name (ie. standard java enum serialization), or to allow >> for custom serialization routines for enums? >> >> Many thanks, >> Stuart. >> >
Re: Binary Serialization of Enums By Name
Hi Mike, Thanks for the response. I can’t see how that’s possible with the current Binarylizable interface as enums are immutable, there’s no nullary constructor for an enum and we can’t update its name after construction. I gave it a shot to see what would happen but the read/write methods weren’t being called at all. Any other suggestions would be much appreciated. Stuart. On 4 Feb 2019, at 16:22, Michael Cherkasov wrote: Hi Stuart, I think you can use Binarylizable interface, you can implement your one serialization for your enum. Thanks, Mike. пн, 4 февр. 2019 г. в 15:12, Stuart Macdonald : > Igniters, > > I have some cache objects which contain enum fields, which when persisted > through Ignite binary persistence are persisted using their enum ordinal > position. However these enums are often modified whereby new values are > inserted in the middle of the existing enum values, which breaks > deserialization by ordinal. Does anyone know of a way to have Ignite > serialize enums by name (ie. standard java enum serialization), or to allow > for custom serialization routines for enums? > > Many thanks, > Stuart. >
Re: Binary Serialization of Enums By Name
Hi Stuart, I think you can use Binarylizable interface, you can implement your one serialization for your enum. Thanks, Mike. пн, 4 февр. 2019 г. в 15:12, Stuart Macdonald : > Igniters, > > I have some cache objects which contain enum fields, which when persisted > through Ignite binary persistence are persisted using their enum ordinal > position. However these enums are often modified whereby new values are > inserted in the middle of the existing enum values, which breaks > deserialization by ordinal. Does anyone know of a way to have Ignite > serialize enums by name (ie. standard java enum serialization), or to allow > for custom serialization routines for enums? > > Many thanks, > Stuart. >
Binary Serialization of Enums By Name
Igniters, I have some cache objects which contain enum fields, which when persisted through Ignite binary persistence are persisted using their enum ordinal position. However these enums are often modified whereby new values are inserted in the middle of the existing enum values, which breaks deserialization by ordinal. Does anyone know of a way to have Ignite serialize enums by name (ie. standard java enum serialization), or to allow for custom serialization routines for enums? Many thanks, Stuart.