Github user jianqiao commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/237#discussion_r113070938
  
    --- 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_;
    --- End diff --
    
    Also `std::hash` returns `std::size_t`, so it may be more consistent to use 
`std::size_t` as hash value type here.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to