gharris1727 opened a new pull request, #15469:
URL: https://github.com/apache/kafka/pull/15469

   The Values class has checkstyle suppressions for NPathComplexity, 
MethodLength, CyclomaticComplexity, and JavaNCSS. Rather than suppressing these 
problems, we should refactor the oversize methods into smaller methods that 
satisfy the checkstyle heuristics.
   
   I added a benchmark to verify that this refactoring does not cause a 
performance regression. Once I had the benchmark, I found some really obvious 
optimizations:
   
   * parseAsTemporal was catching ParseExceptions, and I eliminated those by 
checking the ParsePosition.
   * number parsing was catching multiple ArithmeticExceptions when numbers had 
decimal parts, or were too large to fit in certain types. The new 
implementation does some equivalent rounding and cast-checking to avoid the 
exceptions.
   
   With these changes, the parse() profile shows a significant improvement, 
while all of the other methods are nearly the same or slightly faster than 
before. I'll include the detailed results from my machine in a follow-up 
comment.
   
   Finally I just did some simplification that makes the generic convertTo 
method call the specific convertTo(Boolean,Byte, etc) methods, rather than 
having every one of the specific methods call the single generic method. This 
eliminates the need for casting Object to the return types, and eliminates 
flaws that could come from that cast failing. I fixed one such flaw in #15399 
that I found while doing this refactor.
   
   The SchemaMerger is a refactor of the fix in #15399 because the additional 
fields and control flow exceeded the checkstyle heuristics.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to