text: /*
   * Copyright 2017 MapD Technologies, Inc.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  #ifndef QUERYENGINE_EXPRESSIONREWRITE_H
  #define QUERYENGINE_EXPRESSIONREWRITE_H
  
  #include <memory>
  #include <list>
  #include <vector>
  
  namespace Analyzer {
  
  class Expr;
  
  class InValues;
  
  }  // namespace Analyzer
  
  class InputColDescriptor;
  
  // Rewrites an OR tree where leaves are equality compare against literals.
  std::shared_ptr<Analyzer::Expr> rewrite_expr(const Analyzer::Expr*);
  
  std::list<std::shared_ptr<Analyzer::Expr>> redirect_exprs(
      const std::list<std::shared_ptr<Analyzer::Expr>>& exprs,
      const std::list<std::shared_ptr<const InputColDescriptor>>& col_descs);
  
  std::vector<std::shared_ptr<Analyzer::Expr>> redirect_exprs(
      const std::vector<Analyzer::Expr*>& exprs,
      const std::list<std::shared_ptr<const InputColDescriptor>>& col_descs);
  
  std::shared_ptr<Analyzer::Expr> redirect_expr(const Analyzer::Expr* expr,
                                                const std::list<std::shared_ptr<const InputColDescriptor>>& col_descs);
  
  std::shared_ptr<Analyzer::Expr> fold_expr(const Analyzer::Expr*);
  
  #endif  // QUERYENGINE_EXPRESSIONREWRITE_H
  