Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you 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.
  */
 package org.apache.hadoop.hive.ql.ppd;
 
 import java.util.List;
 import java.util.Map;
 
Context for Expression Walker for determining predicate pushdown candidates It contains a ExprInfo object for each expression that is processed.
 
 public class ExprWalkerInfo implements NodeProcessorCtx {

  
Information maintained for an expr while walking an expr tree.
 
   private static class ExprInfo {
    
true if expr rooted at this node doesn't contain more than one table. alias
 
     public boolean isCandidate = false;
    
alias that this expression refers to.
 
     public String alias = null;
    
new expr for this expression.
 
     public ExprNodeDesc convertedExpr = null;
 
     public ExprInfo() {
     }
 
     public ExprInfo(boolean isCandidateString aliasExprNodeDesc replacedNode) {
       this. = isCandidate;
       this. = alias;
        = replacedNode;
     }
   }
 
   protected static final Log LOG = LogFactory.getLog(OpProcFactory.class
       .getName());;
   private Operator<? extends Serializableop = null;
   private RowResolver toRR = null;

  
this map contains a expr infos. Each key is a node in the expression tree and the information for each node is the value which is used while walking the tree by its parent.
 
   private final Map<StringList<ExprNodeDesc>> pushdownPreds;
  
Values the expression sub-trees (predicates) that can be pushed down for root expression tree. Since there can be more than one alias in an expression tree, this is a map from the alias to predicates.
 
   private final Map<ExprNodeDescExprInfoexprInfoMap;
   private boolean isDeterministic = true;
 
   public ExprWalkerInfo() {
      = new HashMap<StringList<ExprNodeDesc>>();
      = new HashMap<ExprNodeDescExprInfo>();
   }
 
   public ExprWalkerInfo(Operator<? extends Serializableop,
       final RowResolver toRR) {
     this. = op;
     this. = toRR;
 
      = new HashMap<StringList<ExprNodeDesc>>();
      = new HashMap<ExprNodeDescExprInfo>();
   }

  

Returns:
the op of this expression.
 
   public Operator<? extends SerializablegetOp() {
    return ;
  }

  

Returns:
the row resolver of the operator of this expression.
  public RowResolver getToRR() {
    return ;
  }

  

Returns:
converted expression for give node. If there is none then returns null.
    ExprInfo ei = .get(nd);
    if (ei == null) {
      return null;
    }
    return ei.convertedExpr;
  }

  
adds a replacement node for this expression.

Parameters:
oldNode original node
newNode new node
  public void addConvertedNode(ExprNodeDesc oldNodeExprNodeDesc newNode) {
    ExprInfo ei = .get(oldNode);
    if (ei == null) {
      ei = new ExprInfo();
      .put(oldNodeei);
    }
    ei.convertedExpr = newNode;
    .put(newNodenew ExprInfo(ei.isCandidateei.aliasnull));
  }

  
Returns true if the specified expression is pushdown candidate else false.

Parameters:
expr
Returns:
true or false
  public boolean isCandidate(ExprNodeDesc expr) {
    ExprInfo ei = .get(expr);
    if (ei == null) {
      return false;
    }
    return ei.isCandidate;
  }

  
Marks the specified expr to the specified value.

Parameters:
expr
b can
  public void setIsCandidate(ExprNodeDesc exprboolean b) {
    ExprInfo ei = .get(expr);
    if (ei == null) {
      ei = new ExprInfo();
      .put(exprei);
    }
    ei.isCandidate = b;
  }

  
Returns the alias of the specified expr.

Parameters:
expr
Returns:
The alias of the expression
  public String getAlias(ExprNodeDesc expr) {
    ExprInfo ei = .get(expr);
    if (ei == null) {
      return null;
    }
    return ei.alias;
  }

  
Adds the specified alias to the specified expr.

Parameters:
expr
alias
  public void addAlias(ExprNodeDesc exprString alias) {
    if (alias == null) {
      return;
    }
    ExprInfo ei = .get(expr);
    if (ei == null) {
      ei = new ExprInfo();
      .put(exprei);
    }
    ei.alias = alias;
  }

  
Adds the specified expr as the top-most pushdown expr (ie all its children can be pushed).

Parameters:
expr
  public void addFinalCandidate(ExprNodeDesc expr) {
    String alias = getAlias(expr);
    if (.get(alias) == null) {
      .put(aliasnew ArrayList<ExprNodeDesc>());
    }
    .get(alias).add(expr.clone());
  }

  
Returns the list of pushdown expressions for each alias that appear in the current operator's RowResolver. The exprs in each list can be combined using conjunction (AND).

Returns:
the map of alias to a list of pushdown predicates
    return ;
  }

  
Merges the specified pushdown predicates with the current class.

Parameters:
ewi ExpressionWalkerInfo
  public void merge(ExprWalkerInfo ewi) {
    if (ewi == null) {
      return;
    }
    for (Entry<StringList<ExprNodeDesc>> e : ewi.getFinalCandidates()
        .entrySet()) {
      List<ExprNodeDescpredList = .get(e.getKey());
      if (predList != null) {
        predList.addAll(e.getValue());
      } else {
        .put(e.getKey(), e.getValue());
      }
    }
  }

  
sets the deterministic flag for this expression.

Parameters:
b deterministic or not
  public void setDeterministic(boolean b) {
     = b;
  }

  

Returns:
whether this expression is deterministic or not.
  public boolean isDeterministic() {
    return ;
  }
New to GrepCode? Check out our FAQ X