Package org.apache.pig.pen.util

Examples of org.apache.pig.pen.util.ExampleTuple


            res.result = input;
            res.returnStatus = POStatus.STATUS_OK;
            detachInput();
            nextReturnEOP = true ;
            if(lineageTracer != null) {
          ExampleTuple tOut = (ExampleTuple) res.result;
          lineageTracer.insert(tOut);
          lineageTracer.union(tOut, tOut);
            }
            return res;
        }
View Full Code Here


            while(true) {
                res = processPlan();              
               
                if(res.returnStatus==POStatus.STATUS_OK) {
                    if(lineageTracer !=  null && res.result != null) {
                    ExampleTuple tOut = new ExampleTuple((Tuple) res.result);
                    tOut.synthetic = tIn.synthetic;
                    lineageTracer.insert(tOut);
                    lineageTracer.union(tOut, tIn);
                    res.result = tOut;
                    }
                    return res;
                }
                if(res.returnStatus==POStatus.STATUS_EOP) {
                    processingPlan = false;
                    for(PhysicalPlan plan : inputPlans)
                        plan.detachInput();
                    break;
                }
                if(res.returnStatus==POStatus.STATUS_ERR) {
                    return res;
                }
                if(res.returnStatus==POStatus.STATUS_NULL) {
                    continue;
                }
            }
        }
        //The nested plan processing is done or is
        //yet to begin. So process the input and start
        //nested plan processing on the input tuple
        //read
        while (true) {
            inp = processInput();
            if (inp.returnStatus == POStatus.STATUS_EOP ||
                    inp.returnStatus == POStatus.STATUS_ERR) {
                return inp;
            }
            if (inp.returnStatus == POStatus.STATUS_NULL) {
                continue;
            }
                      
            attachInputToPlans((Tuple) inp.result);
            Tuple tuple = (Tuple)inp.result;
           
            for (PhysicalOperator po : opsToBeReset) {
                po.reset();
            }
           
            if (isAccumulative()) {             
                for(int i=0; i<tuple.size(); i++) {               
                    if (tuple.getType(i) == DataType.BAG) {
                        // we only need to check one bag, because all the bags
                        // share the same buffer
                        buffer = ((AccumulativeBag)tuple.get(i)).getTuplebuffer();
                        break;
                    }
                }
               
                while(true) {                       
                    if (buffer.hasNextBatch()) {       
                        try {
                            buffer.nextBatch();
                        }catch(IOException e) {
                            throw new ExecException(e);
                        }
                       
                        setAccumStart();                   
                    }else{               
                        buffer.clear();
                        setAccumEnd();                   
                    }
                   
                    res = processPlan();             
                   
                    if (res.returnStatus == POStatus.STATUS_BATCH_OK) {
                        // attach same input again to process next batch
                        attachInputToPlans((Tuple) inp.result);
                    } else {
                        break;
                    }
                }
               
            } else {                       
                res = processPlan();         
            }
           
            processingPlan = true;

            if(lineageTracer != null && res.result != null) {
            //we check for res.result since that can also be null in the case of flatten
            tIn = (ExampleTuple) inp.result;
            ExampleTuple tOut = new ExampleTuple((Tuple) res.result);
            tOut.synthetic = tIn.synthetic;
            lineageTracer.insert(tOut);
            lineageTracer.union(tOut, tIn);
            res.result = tOut;
            }
View Full Code Here

            } else
                out.append(in);
        }
       
        if(lineageTracer != null) {
            ExampleTuple tOut = new ExampleTuple();
            tOut.reference(out);
        }
        return out;
    }
View Full Code Here

                // input
                // constraints
                for (Iterator<Tuple> it = outputConstraints.iterator(); it
                        .hasNext();) {
                    Tuple outputConstraint = it.next();
                    ExampleTuple inputConstraint = GenerateMatchingTuple(
                            outputConstraint, filterCond, false);
                    if (inputConstraint != null)
                        inputConstraints.add(inputConstraint);
                }
            } else if (outputData.size() == 0) { // no output constraints, but
                // output is empty; generate
                // one input that will pass the
                // filter
                ExampleTuple inputConstraint = GenerateMatchingTuple(filter
                        .getSchema(), filterCond, false);

                if (inputConstraint != null)
                    inputConstraints.add(inputConstraint);
            }

            // if necessary, insert a negative example (i.e. a tuple that does
            // not pass the filter)
            if (outputData.size() == inputData.size()) { // all tuples pass the
                // filter; generate one
                // input that will not
                // pass the filter

                ExampleTuple inputConstraint = GenerateMatchingTuple(filter
                        .getSchema(), filterCond, true);
                if (inputConstraint != null)
                    inputConstraints.add(inputConstraint);

            }
View Full Code Here

                throw new RuntimeException(
                        "Internal error: incorrect number of fields in constraint tuple.");

            Tuple inputT = TupleFactory.getInstance().newTuple(
                    outputConstraint.size());
            ExampleTuple inputTuple = new ExampleTuple(inputT);

            try {
                for (int i = 0; i < inputTuple.size(); i++) {
                    Object d = outputConstraint.get(i);
                    if (d == null)
                        d = exampleTuple.get(i);
                    inputTuple.set(i, d);
                }
            } catch (ExecException e) {
                log
                        .error("Error visiting Load during Augmentation phase of Example Generator! "
                                + e.getMessage());
                throw new VisitorException(
                        "Error visiting Load during Augmentation phase of Example Generator! "
                                + e.getMessage());

            }
            if (!inputTuple.equals(exampleTuple))
                inputTuple.synthetic = true;

            newInputData.add(inputTuple);
        }
    }
View Full Code Here

    Tuple BackPropConstraint(Tuple outputConstraint, List<Integer> cols,
            Schema inputSchema, boolean cast) throws ExecException {
        Tuple inputConst = TupleFactory.getInstance().newTuple(
                inputSchema.getFields().size());

        Tuple inputConstraint = new ExampleTuple(inputConst);

        for (int outCol = 0; outCol < outputConstraint.size(); outCol++) {
            int inCol = cols.get(outCol);
            Object outVal = outputConstraint.get(outCol);
            Object inVal = inputConstraint.get(inCol);

            if (inVal == null && outVal != null) {
                // inputConstraint.set(inCol, outVal);
                inputConstraint.set(inCol, (cast) ? new DataByteArray(outVal
                        .toString().getBytes()) : outVal);

            } else {
                if (outVal != null) {
                    // unable to back-propagate, due to conflicting column
View Full Code Here

    //

    ExampleTuple GenerateMatchingTuple(Tuple constraint, LogicalPlan predicate,
            boolean invert) throws ExecException {
        Tuple t = TupleFactory.getInstance().newTuple(constraint.size());
        ExampleTuple tOut = new ExampleTuple(t);
        for (int i = 0; i < t.size(); i++)
            tOut.set(i, constraint.get(i));

        GenerateMatchingTupleHelper(tOut, (ExpressionOperator) predicate
                .getLeaves().get(0), invert);
        tOut.synthetic = true;
        return tOut;
View Full Code Here

 
  output.set(0, smallestTuple.get(1));
  for(int i = 1; i < size + 1; i++) {
      output.set(i, BagFactory.getInstance().newDefaultBag());
  }
  ExampleTuple tOut = null;
  if(lineageTracer != null) {
      tOut = new ExampleTuple(output);
      lineageTracer.insert(tOut);
  }
 
  boolean loop = true;
 
View Full Code Here

        && res.returnStatus != POStatus.STATUS_NULL)
    return res;

      if (res.result != null && (Boolean) res.result == true) {
    if(lineageTracer != null) {
        ExampleTuple tIn = (ExampleTuple) inp.result;
        lineageTracer.insert(tIn);
        lineageTracer.union(tIn, tIn);
    }
    return inp;
      }
View Full Code Here

            }

        }
       
        if(lineageTracer != null) {
            ExampleTuple tOut = new ExampleTuple();
            tOut.reference(out);
            lineageTracer.insert(tOut);
            for(int i = 0; i < data.length; i++) {
                lineageTracer.union(tOut, data[i]);
            }
            return tOut;
View Full Code Here

TOP

Related Classes of org.apache.pig.pen.util.ExampleTuple

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.