Package org.apache.pig.impl.physicalLayer

Examples of org.apache.pig.impl.physicalLayer.PhysicalOperator


    }
   
    static DataBag EvaluateOperator(LogicalOperator logOp, LineageTracer lineageTracer, Map<LogicalOperator, DataBag> derivedData, Map<OperatorKey, OperatorKey> logicalToPhysicalKeys, Map<OperatorKey, ExecPhysicalOperator> physicalOpTable) throws IOException {
      //We have the compiled physical plan. We just replace the inputs to the physical operator corresponding to the supplied logical
      //operator by POReads reading from databags from the derivedData
      PhysicalOperator pOp = (PhysicalOperator)physicalOpTable.get(logicalToPhysicalKeys.get(logOp.getOperatorKey()));
      if(lineageTracer != null) {
        pOp.setLineageTracer(lineageTracer);
      }
      OperatorKey[] origInputs = new OperatorKey[pOp.inputs.length];
      for(int i = 0; i < origInputs.length; ++i) {
        origInputs[i] = pOp.inputs[i];
      }
     
      for(int i = 0; i < pOp.inputs.length; ++i) {
        PORead read = new PORead(logOp.getScope(),
          NodeIdGenerator.getGenerator().getNextNodeId(logOp.getScope()),
          physicalOpTable,
          LogicalOperator.FIXED,
          derivedData.get(logOp.getOpTable().get(logOp.getInputs().get(i))));
       
        pOp.inputs[i] = read.getOperatorKey();
      }
     
      //get the output data
      DataBag outputData = BagFactory.getInstance().newDefaultBag();
        pOp.open();
        Tuple t = pOp.getNext();
        while(t != null) {
          outputData.add(t);
          t = pOp.getNext();
        }
       
        pOp.close();
       
        //restore the physical operator to its previous form
        pOp.setLineageTracer(null);
        for(int i = 0; i < origInputs.length; ++i) {
          physicalOpTable.remove(pOp.inputs[i]);
          pOp.inputs[i] = origInputs[i];
        }
       
View Full Code Here


    }

    public LocalJob execute(ExecPhysicalPlan plan) throws ExecException {
        DataBag results = BagFactory.getInstance().newDefaultBag();
        try {
            PhysicalOperator pp = (PhysicalOperator)physicalOpTable.get(plan.getRoot());

            pp.visit(new InstantiateFuncCallerPOVisitor(pigContext, physicalOpTable));
            pp.open();
           
            Tuple t;
            while ((t = (Tuple) pp.getNext()) != null) {
                results.add(t);
            }
           
            pp.close();
        }
        catch (Exception e) {
            throw new ExecException(e);
        }
       
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.physicalLayer.PhysicalOperator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.