orc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From majetideepak <...@git.apache.org>
Subject [GitHub] orc pull request #123: ORC-184: Refactor ColumnStatistics classes for writer
Date Sun, 21 May 2017 12:32:04 GMT
Github user majetideepak commented on a diff in the pull request:

    https://github.com/apache/orc/pull/123#discussion_r117631604
  
    --- Diff: c++/src/Statistics.hh ---
    @@ -106,15 +106,50 @@ namespace orc {
     
         void setMinimum(T min) { _minimum = min; }
     
    -    // GET / SET valueCount_
    +    // GET / SET _valueCount
         uint64_t getNumberOfValues() const { return _valueCount; }
     
         void setNumberOfValues(uint64_t numValues) { _valueCount = numValues; }
     
    -    // GET / SET hasNullValue_
    +    // GET / SET _hasNullValue
         bool hasNull() const { return _hasNull; }
     
         void setHasNull(bool hasNull) { _hasNull = hasNull; }
    +
    +    void reset() {
    +      _hasNull = false;
    +      _hasMinimum = false;
    +      _hasMaximum = false;
    +      _hasSum = false;
    +      _hasTotalLength = false;
    +      _totalLength = 0;
    +      _valueCount = 0;
    +    }
    +
    +    // sum is not merged here as we need to check overflow
    +    void merge(const InternalStatisticsImpl& other) {
    +      _hasNull = _hasNull || other._hasNull;
    +      _valueCount += other._valueCount;
    +
    +      if (other._hasMinimum) {
    +        if (!_hasMinimum) {
    +          _hasMinimum = _hasMaximum = true;
    +          _minimum = other._minimum;
    +          _maximum = other._maximum;
    +        } else {
    +          // all template types should support operator<
    +          if (_maximum < other._maximum) {
    --- End diff --
    
    The first option of using templates seems better to me.
    Can use `common.hh` and `common.cc` to put the following.
    ```
    // Return True if val1 < val2
    // Return False otherwise
    template <typename T>
    static inline bool Compare(const T& val1, const T& val2) {
        return val1 < val2
    }
    // Specialize for Decimal
    template <>
    static inline bool Compare(const Decimal& val1, const Decimal& val2) {
       ....
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message