-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Support sized array and sized map. #23
Support sized array and sized map. #23
Conversation
*Added support for size arrays and maps *Fix CBOR Parser bug when fieldname is not a string.
@@ -817,7 +817,7 @@ protected String _numberToName(int ch, boolean neg) throws IOException | |||
if (neg) { | |||
i = -i - 1; | |||
} | |||
return String.valueOf(1); | |||
return String.valueOf(i); |
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.
I will go ahead and fix this separately, backporting in 2.7 at least.
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.
Fix checked in 2.7 (and actually even 2.6 although not sure there will be new releases from that branch)
Ok. First things first: thank you for contributing this patch! I know that ability to use length-prefixed objects and especially arrays is something that has been requested. I went ahead and merged simplest part of the patch (fixing type of Of remaining changes, I am bit ambivalent regarding addition of ability to write And then the bulk of changes: supporting length-prefixed writes. At logical level, I think implementation makes sense and is correct. But I have concerns about efficiency of the implementation. Given that checks are called for each and every value write, and that they are using JDK provider But I think implementation could be improved to mostly/completely eliminate the overhead. Two ways to go about it that I can think of are:
and actually either way it would probably make sense to have one new field in generator itself for "current count", so that regular value writes would only modify that count and not look up state from |
For the performance related concern: For #1 I agree that there will be a performance impact but it's difficult to tell without testing if the effect will be negligible or not. I was not aware of the project jackson-benchmarks and thus I haven't tried to measure the performance impacts of the modifications. For #2, this is something that I look at initially but I had some doubt that is was the right way to go when I looked at how that would be implemented. (Extending JsonWriteContext, overriding some functions, ...) Concerning your last proposition (use a currentCount) I think that this is something that could be easily implemented and that could also help to reduce the performance impact. |
I agree that use of |
@mbaril Actually, thinking bit more about possibly exposing non-String keys, I think it might be a good idea to start exposing this via The only question really is timing: I am trying hard to finalize 2.8.0. But. I think addition of maybe I will create an issue at |
Sound perfect. Thanks! I also took time too run the jackson-benchmarks to compare commit 2.8.0.rc2-2-g08854c6 with 2.8.0.rc2-4-gb6a63b9. I haven't look the tests in details but it looks like the modifications have an impact on performance. |
@mbaril Thank you for running the tests and making the change for current count. From simple runs I did locally I could not see much of performance difference, nor was there anything in profiler, so unless I made a mistake it looks like patch as-is wouldn't add measurable overhead for usage where count functionality is not used. I may want to do some minor tweaking (for naming etc), perhaps encapsulate It also looks like we already have CLA for you which is good. So I think what I'll do is merge the patch, and get this included in 2.8.0. Thanks! |
Interesting. With some minor playing with attempts to optimize, found out that there is one very performance-sensitive part in On plus side, patch as-is is remarkably nicely behaving at least wrt |
*Added support for write field name with long type values.
This is to be able to create map with number as key.
*Added support for size arrays and maps
*Fix CBOR Parser bug when fieldname is not a string.