[ 
https://issues.apache.org/jira/browse/AVRO-2620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16970892#comment-16970892
 ] 

ASF subversion and git services commented on AVRO-2620:
-------------------------------------------------------

Commit eab8e019d6452c5cf54c1278db51861ca9bf6aac in avro's branch 
refs/heads/master from Thiruvalluvan M. G.
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=eab8e01 ]

Merge pull request #704 from RyanSkraba/AVRO-2620-log-power-rule

AVRO-2620: Calculate max precision for fixed decimal logical type.

> Max precision on decimal/fixed LogicalType is wrong
> ---------------------------------------------------
>
>                 Key: AVRO-2620
>                 URL: https://issues.apache.org/jira/browse/AVRO-2620
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: c++, java
>            Reporter: Ryan Skraba
>            Assignee: Ryan Skraba
>            Priority: Minor
>
> A decimal logical type with an underlying fixed bytes type is invalid if the 
> precision is greater than can be contained in the fixed bytes.  The 
> calculation for 
>  [max 
> precision|https://github.com/apache/avro/blob/a2098bd88361b5ff9298c462a2dccafbb0c2c508/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java#L262]
>  can return a wrong value when the fixed bytes size is greater than 128.
> For a fixed size of *129*, the {{Math.pow(2, 8 * size - 1)}} part of this 
> formula will return {{Double.INFINITY}}, and the max precision will be 
> considered {{Long.MAX_VALUE}}.  The expected value is 310 digits precision.
> We can apply the log power rule to avoid overflow, or some bit-twiddling 
> approximation (like 
> [java.math.BigDecimal|https://github.com/openjdk/jdk/blob/jdk8-b120/jdk/src/share/classes/java/math/BigDecimal.java#L3779]).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to