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.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators;
 
 import java.util.List;
 
This operator is part of the RANK operator implementation. Reads the output tuple from POCounter and the cumulative sum previously calculated. Here is read the task identifier in order to get the corresponding cumulative sum, and the local counter at the tuple. These values are summed and prepended to the tuple.
 
 
 public class PORank extends PhysicalOperator {
 
     private static final Log log = LogFactory.getLog(PORank.class);
 
     private static final long serialVersionUID = 1L;
 
     private List<PhysicalPlanrankPlans;
     private List<BooleanmAscCols;
     private List<ByteExprOutputTypes;
 
     protected static final TupleFactory mTupleFactory = TupleFactory.getInstance();

    
Unique identifier that links POCounter and PORank, through the global counter labeled with it.
 
     private String operationID;

    
Counter used to set tuples into the equivalence classes.
 
     private int localCountIllustrator = 0;
 
     public PORank(OperatorKey k) {
         this(k, -1, null);
     }
 
     public PORank(OperatorKey kint rp) {
         this(krpnull);
     }
 
     public PORank(OperatorKey kList<PhysicalOperatorinp) {
         this(k, -1, inp);
     }
 
     public PORank(OperatorKey kint rpList<PhysicalOperatorinp) {
         super(krpinp);
     }
 
     @SuppressWarnings({ "rawtypes""unchecked" })
     public PORank(OperatorKey operatorKeyint requestedParallelismList inp,
             List<PhysicalPlanrankPlansList<BooleanascendingCol) {
         super(operatorKeyrequestedParallelisminp);
         this.setRankPlans(rankPlans);
         this.setAscendingCols(ascendingCol);
 
          = new ArrayList<Byte>(rankPlans.size());
 
         for (PhysicalPlan plan : rankPlans) {
             .add(plan.getLeaves().get(0).getResultType());
         }
    }
    @Override
    public Tuple illustratorMarkup(Object inObject outint eqClassIndex) {
        if( != null){
            ExampleTuple tOut = new ExampleTuple((Tuple)out);
            .addData((Tuple)out);
            .getEquivalenceClasses().get(eqClassIndex).add((Tuple)in);
            LineageTracer lineageTracer = .getLineage();
            lineageTracer.insert(tOut);
            return tOut;
        }
        return (Tupleout;
    }
    @Override
    public void visit(PhyPlanVisitor vthrows VisitorException {
        v.visitRank(this);
    }
    @Override
    public Result getNextTuple() throws ExecException {
        Result inp = null;
        while (true) {
            inp = processInput();
            if (inp.returnStatus == .
                    || inp.returnStatus == .)
                break;
            if (inp.returnStatus == .) {
                continue;
            }
            return addRank(inp);
        }
        return inp;
    }

    
Reads the output tuple from POCounter and the cumulative sum previously calculated. Here is read the task identifier in order to get the corresponding cumulative sum, and the local counter at the tuple. These values are summed and prepended to the tuple.

Parameters:
input processed by POCounter
Returns:
input as Result. The input.result tuple owns the prepend rank value
    public Result addRank(Result inputthrows ExecException {
        int i = 1;
        Tuple in = (Tupleinput.result;
        Tuple out = .newTuple(in.getAll().size() - 1);
        Long taskId = Long.valueOf(in.get(0).toString());
        Long localCounter = (Longin.get(1);
        String nameCounter = . + getOperationID() + . + String.valueOf(taskId);
        Long rank = ..get().getLongnameCounter , -1L );
        
        if( != null) {
            rank = 0L;
        }
        if(rank == -1) {
            .error("Error on reading counter "nameCounter);
            throw new RuntimeException("Unable to read counter "nameCounter);
        }
        out.set(0, rank + localCounter);
        //Add the content of the tuple
        List<Objectsub = in.getAll().subList(2, in.getAll().size());
        for (Object o : sub)
            out.set(i++, o);
        if( > 2)
             = 0;
        input.result = illustratorMarkup(inout);
        ++;
        return input;
    }
    @Override
    public boolean supportsMultipleInputs() {
        return false;
    }
    @Override
    public boolean supportsMultipleOutputs() {
        return false;
    }
    @Override
    public String name() {
        return getAliasString() + "PORank" + "["
        + DataType.findTypeName() + "]" + " - "
        + .toString();
    }
    public void setRankPlans(List<PhysicalPlanrankPlans) {
        this. = rankPlans;
    }
    public List<PhysicalPlangetRankPlans() {
        return ;
    }
    public void setAscendingCols(List<BooleanmAscCols) {
        this. = mAscCols;
    }
    public List<BooleangetAscendingCols() {
        return ;
    }

    
Operation ID: identifier shared within the corresponding POCounter

Parameters:
operationID
    public void setOperationID(String operationID) {
        this. = operationID;
    }
    public String getOperationID() {
        return ;
    }
New to GrepCode? Check out our FAQ X