quickstep-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zuyu <...@git.apache.org>
Subject [GitHub] incubator-quickstep pull request #237: QUICKSTEP-89 Add support for common s...
Date Sun, 23 Apr 2017 22:25:26 GMT
Github user zuyu commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/237#discussion_r112828368
  
    --- Diff: query_optimizer/expressions/Scalar.hpp ---
    @@ -65,10 +67,49 @@ class Scalar : public Expression {
           const std::unordered_map<ExprId, const CatalogAttribute*>& substitution_map)
           const = 0;
     
    +  /**
    +   * @brief Check whether this scalar is semantically equivalent to \p other.
    +   *
    +   * @note The fact that two scalars are semantically equal brings more
    +   *       optimization opportunities, e.g. common subexpression elimination.
    +   *       Meanwhile, it is always safe to assume that two scalars are not equal.
    +   *
    +   * @return True if this scalar equals \p other; false otherwise.
    +   */
    +  virtual bool equals(const ScalarPtr &other) const {
    +    return false;
    +  }
    +
    +  /**
    +   * @brief Get a hash of this scalar.
    +   *
    +   * @return A hash of this scalar.
    +   */
    +  std::size_t hash() const {
    +    if (hash_cache_ == nullptr) {
    +      hash_cache_ = std::make_unique<std::size_t>(computeHash());
    +    }
    +    return *hash_cache_;
    +  }
    +
      protected:
       Scalar() {}
     
    +  /**
    +   * @brief Compute a hash of this scalar.
    +   *
    +   * @note Override this method to actually compute the hash. Note that the
    +   *       public method hash() is a caching wrapper for this method.
    +   *
    +   * @return A hash of this scalar.
    +   */
    +  virtual std::size_t computeHash() const {
    +    throw HashNotSupported("Unsupported computeHash() in " + getName());
    --- End diff --
    
    Suggest to change to a pure virtual method.


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