You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by "Yiqun Zhang (Jira)" <ji...@apache.org> on 2021/09/27 07:00:00 UTC

[jira] [Created] (ORC-1008) Overflow detection code is incorrect in IntegerColumnStatisticsImpl

Yiqun Zhang created ORC-1008:
--------------------------------

             Summary: 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++
    Affects Versions: 1.7.0, 1.6.0, 1.8.0
            Reporter: Yiqun Zhang



{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)