Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version field serializer #274

Merged
merged 2 commits into from
Dec 30, 2014

Conversation

tesseract2048
Copy link
Contributor

A version based serializer with backward compatibility (no forward compatibility).

This can be used for scenarios like:

  • Already used FieldSerializer to serialize persisted object, but about to add field(s)
  • Need light-weighted and simple backward compatible serializer with little overhead, since forward compatibility are not always necessary

*
* @return
*/
short value() default 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be int, since writeVarInt is used to write the version.

@NathanSweet
Copy link
Member

I like the serializer idea! It has less overhead than TaggedFieldSerializer and the only downside versus TaggedFieldSerializer is that fields can't be renamed. Can you address the comments above and we'll merge?

@magro
Copy link
Collaborator

magro commented Dec 21, 2014

It would be great if the pull request would update the readme as well.

@tesseract2048
Copy link
Contributor Author

Hi, thanks for attention.

Actually magic number worked in my scenario (because i somehow used FieldSerializer to store objects to HBase...), so i figured that this could work for someone else, but not necessarily (yes FieldSerializer could write the same number at the very beginning, with small possibility, though the lost could be endured).
So, in my case, using FieldSerializer for persisted objects are bad choice already, the best thing to do is try to fix with a simple approach (without refreshing the whole database, that could cost a lot.)

I will the clean up the code and update later.

@tesseract2048
Copy link
Contributor Author

Additionally, i think forward compatibility could be achieved with appending version before every field, and use chunked i/o to support skipping.
But turns out that would introduce more overhead, and forward compatibility is rarely required in my view (they can just deploy all programs with latest version).

@tesseract2048 tesseract2048 changed the title Add versioning field serializer Add version field serializer Dec 22, 2014
@tesseract2048
Copy link
Contributor Author

Hi there, I believe the latest commit will do the work, since there is no need to introduce more overhead for forward compatibility.
And i've updated README.

NathanSweet added a commit that referenced this pull request Dec 30, 2014
Add version field serializer
@NathanSweet NathanSweet merged commit b136fc9 into EsotericSoftware:master Dec 30, 2014
@NathanSweet
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants