You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Sylvain Lebresne (JIRA)" <ji...@apache.org> on 2013/07/12 15:39:48 UTC
[jira] [Resolved] (CASSANDRA-5744) Cleanup
AbstractType/TypeSerializer classes
[ https://issues.apache.org/jira/browse/CASSANDRA-5744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sylvain Lebresne resolved CASSANDRA-5744.
-----------------------------------------
Resolution: Fixed
Fix Version/s: (was: 2.0)
2.0 beta 2
Thanks for the unit tests fix, I should have ran them, sorry.
Anyways, committed, thanks
> Cleanup AbstractType/TypeSerializer classes
> -------------------------------------------
>
> Key: CASSANDRA-5744
> URL: https://issues.apache.org/jira/browse/CASSANDRA-5744
> Project: Cassandra
> Issue Type: Improvement
> Affects Versions: 2.0 beta 1
> Reporter: Sylvain Lebresne
> Assignee: Sylvain Lebresne
> Priority: Minor
> Fix For: 2.0 beta 2
>
> Attachments: 0001-Inverse-serialize-deserialize.txt, 0001-Inverse-serialize-deserialize-v2.patch, 0002-Make-sure-deseriaze-don-t-throw-on-empty-BB.txt, 0003-Avoid-duplicating-code.txt, 0003-Avoid-duplicating-code-v2.patch
>
>
> This is somewhat a followup to CASSANDRA-4495. I'm attaching 3 patches that do the following:
> # It inverse the serialize and deserialize method in TypeSerializer. Sorry I didn't saw that earlier, but calling serialize the method that takes a byte array to produce an object feels wrong to me (and wikipedia seems to agree with me that this should the other way around: http://en.wikipedia.org/wiki/Serialization :))
> # For historical reasons (which imo were somewhat of a mistake in the first place but that's another story), we accept an empty byte buffer as a valid value for any type. When I say "valid", I mean that validate() never throw (except for InetAddressType as it happens, but that's more of an inconsistency that the patch fixes). However, for some reason most deserialize methods were just throwing a random exception if an empty byte buffer. So I think we should be coherent here, if validate() pass, you should be able to deserialize the value alright, and the 2nd patch make sure of that (return null when there was nothing else making sense).
> # The patch removes a bunch of code duplication. Namely, AbstracType has a getSerializer() method that return the corresponding TypeSerializer, but despite that, every AbstractType subclass was redefining its compose, decompose and validate that were just calling the corresponding method in their deserializer. So the patch makes those method concrete in AbstractType and remove the code duplication all over the place. Furthermore, TypeSerializer had a getString(ByteBuffer) and a toString(T value) methods. But since we also have a deserialize(ByteBuffer), the former getString() is really not useful as it's just toString(deserialize()). So the patch also remove that method.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira