[
https://issues.apache.org/jira/browse/AVRO-4070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17887725#comment-17887725
]
ASF subversion and git services commented on AVRO-4070:
-------------------------------------------------------
Commit 9304cb793aee4d5b1da56b1dced3b7e65329779f in avro's branch
refs/heads/main from belugabehr
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=9304cb793 ]
AVRO-4070: Optimize Check Max Collection Length for New Collections (#3195)
> Optimize Check Max Collection Length for New Collections
> --------------------------------------------------------
>
> Key: AVRO-4070
> URL: https://issues.apache.org/jira/browse/AVRO-4070
> Project: Apache Avro
> Issue Type: Improvement
> Components: java
> Affects Versions: 1.12.0
> Reporter: David Mollitor
> Assignee: David Mollitor
> Priority: Trivial
> Labels: pull-request-available
> Fix For: 1.13.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> To squeeze out a little more performance, the following
> 'checkMaxCollectionLength()' method can be streamlined given: the first
> parameter is always 0L and the second parameter is always greater than or
> equal to zero.
> {code:java}
> public long readArrayStart() throws IOException {
> collectionCount = SystemLimitException.checkMaxCollectionLength(0L,
> doReadItemCount());
> return collectionCount;
> }
> /**
> * A block with count zero indicates
> * the end of the array. If a block's count is negative, its absolute value
> is
> * used, and the count is followed immediately by a long block size
> indicating
> * the number of bytes in the block.
> */
> protected long doReadItemCount() throws IOException {
> long result = readLong();
> if (result < 0L) {
> // Consume byte-count if present
> readLong();
> result = -result;
> }
> return result;
> }
> {code}
> This gets called for every Array start and therefore is a hot path.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)