You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Nandor Kollar (JIRA)" <ji...@apache.org> on 2019/03/27 16:57:00 UTC

[jira] [Resolved] (AVRO-2351) Long/Int in Binary Decoder

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

Nandor Kollar resolved AVRO-2351.
---------------------------------
       Resolution: Fixed
    Fix Version/s: 1.9.0

> Long/Int in Binary Decoder
> --------------------------
>
>                 Key: AVRO-2351
>                 URL: https://issues.apache.org/jira/browse/AVRO-2351
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.9.0
>            Reporter: David Mollitor
>            Assignee: David Mollitor
>            Priority: Minor
>             Fix For: 1.9.0
>
>
> {code:java|title=BinaryDecoder.java}
> /**
>    * Returns the number of items to follow in the current array or map. Returns
>    * 0 if there are no more items in the current array and the array/map has
>    * ended.
>    *
>    * @throws IOException
>    */
>   protected long doReadItemCount() throws IOException {
>     long result = readLong();
>     if (result < 0) {
>       readLong(); // Consume byte-count if present
>       result = -result;
>     }
>     return result;
>   }
>   /**
>    * Reads the count of items in the current array or map and skip those items,
>    * if possible. If it could skip the items, keep repeating until there are no
>    * more items left in the array or map. If items cannot be skipped (because
>    * byte count to skip is not found in the stream) return the count of the
>    * items found. The client needs to skip the items individually.
>    *
>    * @return Zero if there are no more items to skip and end of array/map is
>    *         reached. Positive number if some items are found that cannot be
>    *         skipped and the client needs to skip them individually.
>    * @throws IOException
>    */
>   private long doSkipItems() throws IOException {
>     long result = readInt();
>     while (result < 0) {
>       long bytecount = readLong();
>       doSkipBytes(bytecount);
>       result = readInt();
>     }
>     return result;
>   }
> {code}
> https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java#L370-L406
> The spec states that the sizes are {{long}} values.The {{doReadItemCount}} method has it correct and the {{doSkipItems}} method uses {{int}} values values.
> https://avro.apache.org/docs/1.8.2/spec.html#binary_encode_complex



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)