ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <stanlukya...@gmail.com>
Subject RE: Binary Serialization of Enums By Name
Date Sun, 10 Feb 2019 10:41:06 GMT
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)





From: Stuart Macdonald <stuwee@stuwee.org> 
Sent: Thursday, February 7, 2019 2:52 PM
To: dev <dev@ignite.apache.org>; 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

2. A flag on BinaryConfiguration oto specify serialization of enums by name rather than ordinal.


Any other ideas would be appreciated.




On Mon, 4 Feb 2019 at 16:35, Stuart Macdonald <stuwee@stuwee.org <mailto:stuwee@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.



On 4 Feb 2019, at 16:22, Michael Cherkasov <michael.cherkasov@gmail.com <mailto:michael.cherkasov@gmail.com>
> wrote:

Hi Stuart,


I think you can use Binarylizable interface, you can implement your one serialization for
your enum.





пн, 4 февр. 2019 г. в 15:12, Stuart Macdonald <stuwee@stuwee.org <mailto:stuwee@stuwee.org>



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,


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message