-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[FlexBuffers][Java] Implementation of FlexBuffers API #5476
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
Conversation
6662c85 to
cfcbabe
Compare
e6fabe4 to
a6a5178
Compare
aardappel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is generally great! Some ideas on efficiency though..
27f4280 to
912e25f
Compare
This is the initial attemp to implement FlexBuffer on Java. There is some limitations as compared to the C++ implementation: 1 - No mutations implemented yet 2 - Does not parse from json Also, this initial implementation is not focused and performance, but get the basics write. So there is many opportunities for optimization, for instance, remove all enums, return CharSequence instead of Strings and object pooling.
f63c6b6 to
1c7e2da
Compare
This change removes BitWidth enum in favor of static ints. Also make all "reads" APIs closer to C++ implementation (try to cast or convert as much as possible, assuming user knows what he is doing). Finally, we remove the helper classes for building vectors and maps. There is no official benchmarks, but the unit tests are running in less than 50% for previous runs, which mean those optimizations are worth it.
1c7e2da to
c0bcd1b
Compare
There was a incorrect assumption that strings would be null-terminated, which could lead to truncated strings. S now it relies size instead of null-termination. Other minor improvements
2dcb603 to
2db5384
Compare
|
Ok, looks like we're in a good position to merge. Anything else? |
|
Oh, how about some doc updates? Mention it in JavaCShaprUsage.md, FlexBuffers.md. In the latter, we can have a new section, usage in Java, and rename the existing section Usage in C++. Maybe note before that section that C++, Java are the only supported languages so far (with an external Swift port available). Don't feel the need to make the examples in Java as big as in C++, at least one small example would be good, whatever you feel works. |
I believe basic functionality is there, so I think it is good enough. I have a bunch other ideas I want to explore (specially transform json -> flexb). But it make sense to write it down somewhere and discuss with you first before jump into more coding.
Makes sense. Would it be okay to add it in a separate PR? 1800+ lines in a single PR is already annoying me. |
|
Ok, that's fine. If you can make the doc updates the first PR that be great. Thanks for the hard work! A nice feature addition :) |
|
Just pushed small fix: 9b13201 |
* [FlexBuffers][Java] Implementation of FlexBuffers API This is the initial attemp to implement FlexBuffer on Java. There is some limitations as compared to the C++ implementation: 1 - No mutations implemented yet 2 - Does not parse from json Also, this initial implementation is not focused and performance, but get the basics write. So there is many opportunities for optimization, for instance, remove all enums, return CharSequence instead of Strings and object pooling. * [FlexBuffers][Java] Optimizations and simplification of the Builder API. This change removes BitWidth enum in favor of static ints. Also make all "reads" APIs closer to C++ implementation (try to cast or convert as much as possible, assuming user knows what he is doing). Finally, we remove the helper classes for building vectors and maps. There is no official benchmarks, but the unit tests are running in less than 50% for previous runs, which mean those optimizations are worth it. * [FlexBuffers][Java] Fix Reference::asString behavior There was a incorrect assumption that strings would be null-terminated, which could lead to truncated strings. S now it relies size instead of null-termination. Other minor improvements
Implementation of FlexBuffers API
This is the initial attempt to implement FlexBuffer on Java.
There is some limitations as compared to the C++ implementation:
1 - No mutations implemented yet
2 - Does not parse from json
Also, this initial implementation is not focused and performance, but
get the basics write. So there is many opportunities for optimization, for instance,
remove all enums, return CharSequence instead of Strings and object pooling.
A small tool calledflexbwhich I am using to convert json data into FlexBuffers so it can test easily while implementing the features.I think it useful asflatcdoes not convert to flexbuffers.I am submitting this PR as WIP in order to get early feedback and improve API or whatever can be found early.