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

Yiqun Zhang commented on ORC-1008:
----------------------------------

Java overflow check has the same problem with the addition of the Java 
component tag.
 

> Overflow detection code is incorrect in IntegerColumnStatisticsImpl
> -------------------------------------------------------------------
>
>                 Key: ORC-1008
>                 URL: https://issues.apache.org/jira/browse/ORC-1008
>             Project: ORC
>          Issue Type: Bug
>          Components: C++, Java
>    Affects Versions: 1.6.0, 1.7.0, 1.8.0
>            Reporter: Yiqun Zhang
>            Priority: Major
>
> {code:java}
> void IntegerColumnStatisticsImpl::update(int64_t value, int repetitions) { 
>    _stats.updateMinMax(value); 
>   
>    if (_stats.hasSum()) { 
>      bool wasPositive = _stats.getSum() >= 0; 
>      _stats.setSum(value * repetitions + _stats.getSum()); 
>      if ((value >= 0) == wasPositive) { 
>        _stats.setHasSum((_stats.getSum() >= 0) == wasPositive); 
>      } 
>    } 
>  } 
> {code}
> A counter-example can easily be given
> Assume sum=1, update(std::numeric_limits<int64_t>::max(), 3);
> value * repetitions + _stats.getSum() is overflowed, but is still a positive 
> number : 9223372036854775806



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

Reply via email to