Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package edu.uci.ics.hivesterix.logical.plan;
  
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
 import java.util.Set;
 
 import  org.apache.hadoop.hive.ql.exec.ColumnInfo;
 import  org.apache.hadoop.hive.ql.exec.ExtractOperator;
 import  org.apache.hadoop.hive.ql.exec.FileSinkOperator;
 import  org.apache.hadoop.hive.ql.exec.FilterOperator;
 import  org.apache.hadoop.hive.ql.exec.GroupByOperator;
 import  org.apache.hadoop.hive.ql.exec.JoinOperator;
 import  org.apache.hadoop.hive.ql.exec.LateralViewJoinOperator;
 import  org.apache.hadoop.hive.ql.exec.LimitOperator;
 import  org.apache.hadoop.hive.ql.exec.MapJoinOperator;
 import  org.apache.hadoop.hive.ql.exec.Operator;
 import  org.apache.hadoop.hive.ql.exec.ReduceSinkOperator;
 import  org.apache.hadoop.hive.ql.exec.SelectOperator;
 import  org.apache.hadoop.hive.ql.exec.TableScanOperator;
 import  org.apache.hadoop.hive.ql.exec.UDF;
 import  org.apache.hadoop.hive.ql.exec.UDTFOperator;
 import  org.apache.hadoop.hive.ql.exec.UnionOperator;
 import  org.apache.hadoop.hive.ql.plan.AggregationDesc;
 import  org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc;
 import  org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc;
 import  org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
 import  org.apache.hadoop.hive.ql.plan.ExprNodeFieldDesc;
 import  org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc;
 import  org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc;
 import  org.apache.hadoop.hive.ql.plan.PartitionDesc;
 import  org.apache.hadoop.hive.ql.plan.UDTFDesc;
 import  org.apache.hadoop.hive.ql.plan.api.OperatorType;
 import  org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
 import  org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge;
 import  org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
 
 
 @SuppressWarnings("rawtypes")
 public class HiveAlgebricksTranslator implements Translator {
 
     private int currentVariable = 0;
 
 
     private boolean continueTraverse = true;
 
     private IMetadataProvider<PartitionDesc, ObjectmetaData;

    
map variable name to the logical variable
 
map field name to LogicalVariable
 
map logical variable to name
asterix root operators
a list of visitors
    private List<Visitorvisitors = new ArrayList<Visitor>();

    
output writer to print things out
    private static PrintWriter outputWriter = new PrintWriter(new OutputStreamWriter(.));

    
map a logical variable to type info
    private HashMap<LogicalVariable, TypeInfo> variableToType = new HashMap<LogicalVariable, TypeInfo>();
    @Override
    public LogicalVariable getVariable(String fieldName, TypeInfo type) {
        LogicalVariable var = .get(fieldName);
        if (var == null) {
            ++;
            var = new LogicalVariable();
            .put(fieldNamevar);
            .put(var.toString(), var);
            .put(vartype);
            .put(varfieldName);
        }
        return var;
    }
    @Override
    public LogicalVariable getNewVariable(String fieldName, TypeInfo type) {
        ++;
        LogicalVariable var = new LogicalVariable();
        .put(fieldNamevar);
        .put(var.toString(), var);
        .put(vartype);
        .put(varfieldName);
        return var;
    }
    @Override
    public void replaceVariable(LogicalVariable oldVarLogicalVariable newVar) {
        String name = this..get(oldVar);
        if (name != null) {
            .put(namenewVar);
            .put(newVar.toString(), newVar);
            .put(oldVar.toString(), newVar);
            .put(newVarname);
        }
    }
    @Override
    public IMetadataProvider<PartitionDesc, ObjectgetMetadataProvider() {
        return ;
    }

    
only get an variable, without rewriting it

Parameters:
fieldName
Returns:
    private LogicalVariable getVariableOnly(String fieldName) {
        return .get(fieldName);
    }
    private void updateVariable(String fieldNameLogicalVariable variable) {
        LogicalVariable var = .get(fieldName);
        if (var == null) {
            .put(fieldNamevariable);
            .put(fieldNamevariable);
        } else if (!var.equals(variable)) {
            .put(fieldNamevariable);
            .put(fieldNamevariable);
        }
    }

    
get a list of logical variables from the schema

Parameters:
schema
Returns:
    @Override
        List<LogicalVariablevariables = new ArrayList<LogicalVariable>();
        List<Stringnames = schema.getNames();
        for (String name : names)
            variables.add(.get(name));
        return variables;
    }

    
get variable to typeinfo map

Returns:
    public HashMap<LogicalVariable, TypeInfo> getVariableContext() {
        return this.;
    }

    
get the number of variables s

Returns:
    public int getVariableCounter() {
        return  + 1;
    }

    
translate from hive operator tree to asterix operator tree

Parameters:
hive roots
Returns:
Algebricks roots
    public void translate(List<Operator> hiveRootILogicalOperator parentOperator,
            HashMap<String, PartitionDesc> aliasToPathMapthrows AlgebricksException {
        
register visitors
        .add(new FilterVisitor());
        .add(new GroupByVisitor());
        .add(new JoinVisitor());
        .add(new LateralViewJoinVisitor());
        .add(new UnionVisitor());
        .add(new LimitVisitor());
        .add(new MapJoinVisitor());
        .add(new ProjectVisitor());
        .add(new SortVisitor());
        .add(new ExtractVisitor());
        .add(new TableScanWriteVisitor(aliasToPathMap));
        List<Mutable<ILogicalOperator>> refList = translate(hiveRootnew MutableObject<ILogicalOperator>(
                parentOperator));
        insertReplicateOperator(refList);
        if (refList != null)
            .addAll(refList);
    }

    
translate operator DAG

Parameters:
hiveRoot
AlgebricksParentOperator
Returns:
    private List<Mutable<ILogicalOperator>> translate(List<Operator> hiveRoot,
            Mutable<ILogicalOperatorAlgebricksParentOperatorthrows AlgebricksException {
        for (Operator hiveOperator : hiveRoot) {
             = true;
            Mutable<ILogicalOperatorcurrentOperatorRef = null;
            if (hiveOperator.getType() == OperatorType.FILTER) {
                FilterOperator fop = (FilterOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(fopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null)
                        break;
                }
            } else if (hiveOperator.getType() == OperatorType.REDUCESINK) {
                ReduceSinkOperator fop = (ReduceSinkOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(fopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null)
                        break;
                }
            } else if (hiveOperator.getType() == OperatorType.JOIN) {
                JoinOperator fop = (JoinOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(fopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null) {
                         = true;
                        break;
                    } else
                         = false;
                }
                if (currentOperatorRef == null)
                    return null;
            } else if (hiveOperator.getType() == OperatorType.LATERALVIEWJOIN) {
                LateralViewJoinOperator fop = (LateralViewJoinOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(fopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null)
                        break;
                }
                if (currentOperatorRef == null)
                    return null;
            } else if (hiveOperator.getType() == OperatorType.MAPJOIN) {
                MapJoinOperator fop = (MapJoinOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(fopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null) {
                         = true;
                        break;
                    } else
                         = false;
                }
                if (currentOperatorRef == null)
                    return null;
            } else if (hiveOperator.getType() == OperatorType.SELECT) {
                SelectOperator fop = (SelectOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(fopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null)
                        break;
                }
            } else if (hiveOperator.getType() == OperatorType.EXTRACT) {
                ExtractOperator fop = (ExtractOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(fopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null)
                        break;
                }
            } else if (hiveOperator.getType() == OperatorType.GROUPBY) {
                GroupByOperator fop = (GroupByOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(fopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null)
                        break;
                }
            } else if (hiveOperator.getType() == OperatorType.TABLESCAN) {
                TableScanOperator fop = (TableScanOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(fopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null)
                        break;
                }
            } else if (hiveOperator.getType() == OperatorType.FILESINK) {
                FileSinkOperator fop = (FileSinkOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(fopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null)
                        break;
                }
            } else if (hiveOperator.getType() == OperatorType.LIMIT) {
                LimitOperator lop = (LimitOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(lopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null)
                        break;
                }
            } else if (hiveOperator.getType() == OperatorType.UDTF) {
                UDTFOperator lop = (UDTFOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(lopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null)
                        break;
                }
            } else if (hiveOperator.getType() == OperatorType.UNION) {
                UnionOperator lop = (UnionOperator) hiveOperator;
                for (Visitor visitor : ) {
                    currentOperatorRef = visitor.visit(lopAlgebricksParentOperatorthis);
                    if (currentOperatorRef != null) {
                         = true;
                        break;
                    } else
                         = false;
                }
            } else
                ;
            if (hiveOperator.getChildOperators() != null && hiveOperator.getChildOperators().size() > 0
                    && ) {
                @SuppressWarnings("unchecked")
                List<Operator> children = hiveOperator.getChildOperators();
                if (currentOperatorRef == null)
                    currentOperatorRef = AlgebricksParentOperator;
                translate(childrencurrentOperatorRef);
            }
            if (hiveOperator.getChildOperators() == null || hiveOperator.getChildOperators().size() == 0)
                .add(currentOperatorRef);
        }
        return ;
    }

    
used in select, group by to get no-column-expression columns

Parameters:
cols
Returns:
    public ILogicalOperator getAssignOperator(Mutable<ILogicalOperatorparentList<ExprNodeDesc> cols,
            ArrayList<LogicalVariablevariables) {
        ArrayList<Mutable<ILogicalExpression>> expressions = new ArrayList<Mutable<ILogicalExpression>>();

        
variables to be appended in the assign operator
        ArrayList<LogicalVariableappendedVariables = new ArrayList<LogicalVariable>();
        // one variable can only be assigned once
        for (ExprNodeDesc hiveExpr : cols) {
            rewriteExpression(hiveExpr);
            if (hiveExpr instanceof ExprNodeColumnDesc) {
                ExprNodeColumnDesc desc2 = (ExprNodeColumnDesc) hiveExpr;
                String fieldName = desc2.getTabAlias() + "." + desc2.getColumn();
                // System.out.println("project expr: " + fieldName);
                if (fieldName.indexOf("$$") < 0) {
                    LogicalVariable var = getVariable(fieldNamehiveExpr.getTypeInfo());
                    desc2.setColumn(var.toString());
                    desc2.setTabAlias("");
                    variables.add(var);
                } else {
                    LogicalVariable var = .get(desc2.getColumn());
                    String name = this..get(var);
                    var = this.getVariableOnly(name);
                    variables.add(var);
                }
            } else {
                Mutable<ILogicalExpressionasterixExpr = translateScalarFucntion(hiveExpr);
                expressions.add(asterixExpr);
                LogicalVariable var = getVariable(hiveExpr.getExprString() + asterixExpr.hashCode(),
                        hiveExpr.getTypeInfo());
                variables.add(var);
                appendedVariables.add(var);
            }
        }

        
create an assign operator to deal with appending
        ILogicalOperator assignOp = null;
        if (appendedVariables.size() > 0) {
            assignOp = new AssignOperator(appendedVariablesexpressions);
            assignOp.getInputs().add(parent);
        }
        return assignOp;
    }
    private ILogicalPlan plan;
    public ILogicalPlan genLogicalPlan() {
         = new ALogicalPlanImpl();
        return ;
    }
    public void printOperators() throws AlgebricksException {
        StringBuilder buffer = new StringBuilder();
        PlanPrettyPrinter.printPlan(bufferpvisitor, 0);
        .println(buffer);
        .println("rewritten variables: ");
        .flush();
        printVariables();
    }
    public static void setOutputPrinter(PrintWriter writer) {
         = writer;
    }
    private void printVariables() {
        for (Entry<StringLogicalVariableentry : entries) {
            .println(entry.getKey() + " -> " + entry.getValue());
        }
        .flush();
    }

    
generate the object inspector for the output of an operator

Parameters:
operator The Hive operator
Returns:
an ObjectInspector object
    public Schema generateInputSchema(Operator operator) {
        List<StringvariableNames = new ArrayList<String>();
        List<TypeInfo> typeList = new ArrayList<TypeInfo>();
        List<ColumnInfo> columns = operator.getSchema().getSignature();
        for (ColumnInfo col : columns) {
            // typeList.add();
            TypeInfo type = col.getType();
            typeList.add(type);
            String fieldName = col.getInternalName();
            variableNames.add(fieldName);
        }
        return new Schema(variableNamestypeList);
    }

    
rewrite the names of output columns for feature expression evaluators to use

Parameters:
operator
    public void rewriteOperatorOutputSchema(Operator operator) {
        List<ColumnInfo> columns = operator.getSchema().getSignature();
        for (ColumnInfo column : columns) {
            String columnName = column.getTabAlias() + "." + column.getInternalName();
            if (columnName.indexOf("$$") < 0) {
                LogicalVariable var = getVariable(columnNamecolumn.getType());
                column.setInternalName(var.toString());
            }
        }
    }
    @Override
    public void rewriteOperatorOutputSchema(List<LogicalVariablevariables, Operator operator) {
        //printOperatorSchema(operator);
        List<ColumnInfo> columns = operator.getSchema().getSignature();
        if (variables.size() != columns.size()) {
            throw new IllegalStateException("output cardinality error " + operator.getName() + " variable size: "
                    + variables.size() + " expected " + columns.size());
        }
        for (int i = 0; i < variables.size(); i++) {
            LogicalVariable var = variables.get(i);
            ColumnInfo column = columns.get(i);
            String fieldName = column.getTabAlias() + "." + column.getInternalName();
            if (fieldName.indexOf("$$") < 0) {
                updateVariable(fieldNamevar);
                column.setInternalName(var.toString());
            }
        }
        //printOperatorSchema(operator);
    }

    
rewrite an expression and substitute variables

Parameters:
expr hive expression
    public void rewriteExpression(ExprNodeDesc expr) {
        if (expr instanceof ExprNodeColumnDesc) {
            ExprNodeColumnDesc desc = (ExprNodeColumnDesc) expr;
            String fieldName = desc.getTabAlias() + "." + desc.getColumn();
            if (fieldName.indexOf("$$") < 0) {
                LogicalVariable var = getVariableOnly(fieldName);
                if (var == null) {
                    fieldName = "." + desc.getColumn();
                    var = getVariableOnly(fieldName);
                    if (var == null) {
                        fieldName = "null." + desc.getColumn();
                        var = getVariableOnly(fieldName);
                        if (var == null) {
                            throw new IllegalStateException(fieldName + " is wrong!!! ");
                        }
                    }
                }
                String name = this..get(var);
                var = getVariableOnly(name);
                desc.setColumn(var.toString());
            }
        } else {
            if (expr.getChildren() != null && expr.getChildren().size() > 0) {
                List<ExprNodeDesc> children = expr.getChildren();
                for (ExprNodeDesc desc : children)
                    rewriteExpression(desc);
            }
        }
    }

    
rewrite an expression and substitute variables

Parameters:
expr hive expression
    public void rewriteExpressionPartial(ExprNodeDesc expr) {
        if (expr instanceof ExprNodeColumnDesc) {
            ExprNodeColumnDesc desc = (ExprNodeColumnDesc) expr;
            String fieldName = desc.getTabAlias() + "." + desc.getColumn();
            if (fieldName.indexOf("$$") < 0) {
                LogicalVariable var = getVariableOnly(fieldName);
                desc.setColumn(var.toString());
            }
        } else {
            if (expr.getChildren() != null && expr.getChildren().size() > 0) {
                List<ExprNodeDesc> children = expr.getChildren();
                for (ExprNodeDesc desc : children)
                    rewriteExpressionPartial(desc);
            }
        }
    }
    // private void printOperatorSchema(Operator operator) {
    // // System.out.println(operator.getName());
    // // List<ColumnInfo> columns = operator.getSchema().getSignature();
    // // for (ColumnInfo column : columns) {
    // // System.out.print(column.getTabAlias() + "." +
    // // column.getInternalName() + "  ");
    // // }
    // // System.out.println();
    // }

    
translate scalar function expression

Parameters:
hiveExpr
Returns:
    public Mutable<ILogicalExpressiontranslateScalarFucntion(ExprNodeDesc hiveExpr) {
        ILogicalExpression AlgebricksExpr;
        if (hiveExpr instanceof ExprNodeGenericFuncDesc) {
            List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();
            List<ExprNodeDesc> children = hiveExpr.getChildren();
            for (ExprNodeDesc child : children)
                arguments.add(translateScalarFucntion(child));
            ExprNodeGenericFuncDesc funcExpr = (ExprNodeGenericFuncDesc) hiveExpr;
            GenericUDF genericUdf = funcExpr.getGenericUDF();
            UDF udf = null;
            if (genericUdf instanceof GenericUDFBridge) {
                GenericUDFBridge bridge = (GenericUDFBridge) genericUdf;
                try {
                    udf = bridge.getUdfClass().newInstance();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            
set up the hive function
            Object hiveFunction = genericUdf;
            if (udf != null)
                hiveFunction = udf;
                    .getClass());
            if (funcId == null) {
                funcId = new FunctionIdentifier(.hiveFunction.getClass().getName());
            }
            Object functionInfo = null;
            if (genericUdf instanceof GenericUDFBridge) {
                functionInfo = funcExpr;
            }

            
generate the function call expression
            ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(new HiveFunctionInfo(
                    funcIdfunctionInfo), arguments);
            AlgebricksExpr = AlgebricksFuncExpr;
        } else if (hiveExpr instanceof ExprNodeColumnDesc) {
            ExprNodeColumnDesc column = (ExprNodeColumnDesc) hiveExpr;
            LogicalVariable var = this.getVariable(column.getColumn());
            AlgebricksExpr = new VariableReferenceExpression(var);
        } else if (hiveExpr instanceof ExprNodeFieldDesc) {
            FunctionIdentifier funcId;
            ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(new HiveFunctionInfo(
                    funcIdhiveExpr));
            AlgebricksExpr = AlgebricksFuncExpr;
        } else if (hiveExpr instanceof ExprNodeConstantDesc) {
            ExprNodeConstantDesc hiveConst = (ExprNodeConstantDesc) hiveExpr;
            Object value = hiveConst.getValue();
            AlgebricksExpr = new ConstantExpression(new HivesterixConstantValue(value));
        } else if (hiveExpr instanceof ExprNodeNullDesc) {
            FunctionIdentifier funcId;
            funcId = new FunctionIdentifier(..);
            ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(new HiveFunctionInfo(
                    funcIdhiveExpr));
            AlgebricksExpr = AlgebricksFuncExpr;
        } else {
            throw new IllegalStateException("unknown hive expression");
        }
        return new MutableObject<ILogicalExpression>(AlgebricksExpr);
    }

    
translate aggregation function expression

Parameters:
aggregateDesc
Returns:
    public Mutable<ILogicalExpressiontranslateAggregation(AggregationDesc aggregateDesc) {
        String UDAFName = aggregateDesc.getGenericUDAFName();
        List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();
        List<ExprNodeDesc> children = aggregateDesc.getParameters();
        for (ExprNodeDesc child : children)
            arguments.add(translateScalarFucntion(child));
        FunctionIdentifier funcId = new FunctionIdentifier(.UDAFName + "("
                + aggregateDesc.getMode() + ")");
        HiveFunctionInfo funcInfo = new HiveFunctionInfo(funcIdaggregateDesc);
        AggregateFunctionCallExpression aggregationExpression = new AggregateFunctionCallExpression(funcInfofalse,
                arguments);
        return new MutableObject<ILogicalExpression>(aggregationExpression);
    }

    
translate aggregation function expression

Parameters:
aggregator
Returns:
    public Mutable<ILogicalExpressiontranslateUnnestFunction(UDTFDesc udtfDescMutable<ILogicalExpressionargument) {
        String UDTFName = udtfDesc.getUDTFName();
        FunctionIdentifier funcId = new FunctionIdentifier(.UDTFName);
        UnnestingFunctionCallExpression unnestingExpression = new UnnestingFunctionCallExpression(new HiveFunctionInfo(
                funcIdudtfDesc));
        unnestingExpression.getArguments().add(argument);
        return new MutableObject<ILogicalExpression>(unnestingExpression);
    }

    
get typeinfo
    @Override
    public TypeInfo getType(LogicalVariable var) {
        return .get(var);
    }

    
get variable from variable name
    @Override
    public LogicalVariable getVariable(String name) {
        return .get(name);
    }
    @Override
    public LogicalVariable getVariableFromFieldName(String fieldName) {
        return this.getVariableOnly(fieldName);
    }

    
set the metadata provider
    @Override
    public void setMetadataProvider(IMetadataProvider<PartitionDesc, Objectmetadata) {
        this. = metadata;
    }

    
insert ReplicateOperator when necessary
    private void insertReplicateOperator(List<Mutable<ILogicalOperator>> roots) {
        buildChildToParentsMapping(rootschildToParentsMap);
        for (Entry<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> entry : childToParentsMap.entrySet()) {
            List<Mutable<ILogicalOperator>> pList = entry.getValue();
            if (pList.size() > 1) {
                ILogicalOperator rop = new ReplicateOperator(pList.size());
                Mutable<ILogicalOperatorropRef = new MutableObject<ILogicalOperator>(rop);
                Mutable<ILogicalOperatorchildRef = entry.getKey();
                rop.getInputs().add(childRef);
                for (Mutable<ILogicalOperatorparentRef : pList) {
                    ILogicalOperator parentOp = parentRef.getValue();
                    int index = parentOp.getInputs().indexOf(childRef);
                    parentOp.getInputs().set(indexropRef);
                }
            }
        }
    }

    
build the mapping from child to Parents

Parameters:
roots
childToParentsMap
            Map<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> map) {
        for (Mutable<ILogicalOperatoropRef : roots) {
            List<Mutable<ILogicalOperator>> childRefs = opRef.getValue().getInputs();
            for (Mutable<ILogicalOperatorchildRef : childRefs) {
                List<Mutable<ILogicalOperator>> parentList = map.get(childRef);
                if (parentList == null) {
                    parentList = new ArrayList<Mutable<ILogicalOperator>>();
                    map.put(childRefparentList);
                }
                if (!parentList.contains(opRef))
                    parentList.add(opRef);
            }
            buildChildToParentsMapping(childRefsmap);
        }
    }
New to GrepCode? Check out our FAQ X