org.apache.hadoop.hive.ql.index
Class IndexPredicateAnalyzer

java.lang.Object
  extended by org.apache.hadoop.hive.ql.index.IndexPredicateAnalyzer

public class IndexPredicateAnalyzer
extends Object

IndexPredicateAnalyzer decomposes predicates, separating the parts which can be satisfied by an index from the parts which cannot. Currently, it only supports pure conjunctions over binary expressions comparing a column reference with a constant value. It is assumed that all column aliases encountered refer to the same table.


Constructor Summary
IndexPredicateAnalyzer()
           
 
Method Summary
 void addComparisonOp(String udfName)
          Registers a comparison operator as one which can be satisfied by an index search.
 void allowColumnName(String columnName)
          Adds a column name to the set of column names allowed.
 ExprNodeDesc analyzePredicate(ExprNodeDesc predicate, List<IndexSearchCondition> searchConditions)
          Analyzes a predicate.
 void clearAllowedColumnNames()
          Clears the set of column names allowed in comparisons.
 ExprNodeGenericFuncDesc translateSearchConditions(List<IndexSearchCondition> searchConditions)
          Translates search conditions back to ExprNodeDesc form (as a left-deep conjunction).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexPredicateAnalyzer

public IndexPredicateAnalyzer()
Method Detail

addComparisonOp

public void addComparisonOp(String udfName)
Registers a comparison operator as one which can be satisfied by an index search. Unless this is called, analyzePredicate will never find any indexable conditions.

Parameters:
udfName - name of comparison operator as returned by either GenericUDFBridge.getUdfName() (for simple UDF's) or udf.getClass().getName() (for generic UDF's).

clearAllowedColumnNames

public void clearAllowedColumnNames()
Clears the set of column names allowed in comparisons. (Initially, all column names are allowed.)


allowColumnName

public void allowColumnName(String columnName)
Adds a column name to the set of column names allowed.

Parameters:
columnName - name of column to be allowed

analyzePredicate

public ExprNodeDesc analyzePredicate(ExprNodeDesc predicate,
                                     List<IndexSearchCondition> searchConditions)
Analyzes a predicate.

Parameters:
predicate - predicate to be analyzed
searchConditions - receives conditions produced by analysis
Returns:
residual predicate which could not be translated to searchConditions

translateSearchConditions

public ExprNodeGenericFuncDesc translateSearchConditions(List<IndexSearchCondition> searchConditions)
Translates search conditions back to ExprNodeDesc form (as a left-deep conjunction).

Parameters:
searchConditions - (typically produced by analyzePredicate)
Returns:
ExprNodeGenericFuncDesc form of search conditions


Copyright © 2014 The Apache Software Foundation. All rights reserved.