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 Mon, 24 Apr 2017 00:16:14 GMT
Github user zuyu commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/237#discussion_r112847711
  
    --- Diff: query_optimizer/expressions/SimpleCase.cpp ---
    @@ -161,6 +163,50 @@ ::quickstep::Scalar* SimpleCase::concretize(
           else_result_expression.release());
     }
     
    +std::size_t SimpleCase::computeHash() const {
    +  std::size_t hash_code =
    +      CombineHashes(static_cast<std::size_t>(ExpressionType::kSimpleCase),
    +                    case_operand_->hash());
    +  for (std::size_t i = 0; i < condition_operands_.size(); ++i) {
    +    hash_code = CombineHashes(hash_code, condition_operands_[i]->hash());
    +    hash_code = CombineHashes(hash_code, conditional_result_expressions_[i]->hash());
    +  }
    +  if (else_result_expression_ != nullptr) {
    +    hash_code = CombineHashes(hash_code, else_result_expression_->hash());
    +  }
    +  return hash_code;
    +}
    +
    +bool SimpleCase::equals(const ScalarPtr &other) const {
    +  SimpleCasePtr expr;
    +  if (!SomeSimpleCase::MatchesWithConditionalCast(other, &expr)) {
    +    return false;
    +  }
    +  if (!case_operand_->equals(expr->case_operand_)) {
    +    return false;
    +  }
    +  if (condition_operands_.size() != expr->condition_operands_.size()) {
    +    return false;
    +  }
    +  for (std::size_t i = 0; i < condition_operands_.size(); ++i) {
    +    if (!condition_operands_[i]->equals(expr->condition_operands_[i])
    +        || !conditional_result_expressions_[i]->equals(
    +                expr->conditional_result_expressions_[i])) {
    +      return false;
    +    }
    +  }
    +  if ((else_result_expression_ == nullptr
    +       || expr->else_result_expression_ == nullptr)
    --- End diff --
    
    Please add four whitespace indentations.
    
    Actually, to be consistent with other bool expression usages, I recommend to refactor
as following:
    
    ```
      if ((else_result_expression_ == nullptr ||
               expr->else_result_expression_ == nullptr)) &&
          else_result_expression_ != expr->else_result_expression_) {
      ...
    }
    ```


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