Search in sources :

Example 16 with IndexPredicateAnalyzer

use of org.apache.hadoop.hive.ql.index.IndexPredicateAnalyzer in project mongo-hadoop by mongodb.

the class HiveMongoInputFormat method getFilter.

DBObject getFilter(final JobConf conf, final Map<String, String> colToMongoNames) {
    String serializedExpr = conf.get(TableScanDesc.FILTER_EXPR_CONF_STR);
    if (serializedExpr != null) {
        ExprNodeGenericFuncDesc expr = Utilities.deserializeExpression(serializedExpr);
        IndexPredicateAnalyzer analyzer = IndexPredicateAnalyzer.createAnalyzer(false);
        // Allow all column names.
        String columnNamesStr = conf.get(ColumnProjectionUtils.READ_COLUMN_NAMES_CONF_STR);
        String[] columnNames = StringUtils.split(columnNamesStr, '\\', StringUtils.COMMA);
        for (String colName : columnNames) {
            analyzer.allowColumnName(colName);
        }
        List<IndexSearchCondition> searchConditions = new LinkedList<IndexSearchCondition>();
        analyzer.analyzePredicate(expr, searchConditions);
        return getFilter(searchConditions, colToMongoNames);
    }
    return null;
}
Also used : IndexSearchCondition(org.apache.hadoop.hive.ql.index.IndexSearchCondition) ExprNodeGenericFuncDesc(org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc) IndexPredicateAnalyzer(org.apache.hadoop.hive.ql.index.IndexPredicateAnalyzer) LinkedList(java.util.LinkedList)

Aggregations

IndexPredicateAnalyzer (org.apache.hadoop.hive.ql.index.IndexPredicateAnalyzer)16 IndexSearchCondition (org.apache.hadoop.hive.ql.index.IndexSearchCondition)12 ArrayList (java.util.ArrayList)8 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)6 ExprNodeGenericFuncDesc (org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc)5 DecomposedPredicate (org.apache.hadoop.hive.ql.metadata.HiveStoragePredicateHandler.DecomposedPredicate)4 GenericUDFOPEqual (org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPEqual)3 GenericUDFOPEqualOrGreaterThan (org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPEqualOrGreaterThan)3 GenericUDFOPEqualOrLessThan (org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPEqualOrLessThan)3 GenericUDFOPGreaterThan (org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPGreaterThan)3 GenericUDFOPLessThan (org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPLessThan)3 LinkedList (java.util.LinkedList)2 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)2 Index (org.apache.hadoop.hive.metastore.api.Index)2 Partition (org.apache.hadoop.hive.ql.metadata.Partition)2 TypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1