[ 
https://issues.apache.org/jira/browse/AVRO-4070?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

David Mollitor updated AVRO-4070:
---------------------------------
    Description: 
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.

  was:
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}


> 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
>             Fix For: 1.13.0
>
>
> 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)

Reply via email to