Examples of Datum


Examples of org.apache.pig.data.Datum

                if (!(groupLabel instanceof Tuple)) throw new RuntimeException("Unexpected group label type.");
                Tuple groupLabelTuple = (Tuple) groupLabel;
                       
                for (int outCol = 0; outCol < groupCols.size(); outCol++) {
                    int inCol = groupCols.get(outCol);
                    Datum outVal = groupLabelTuple.getField(outCol);
                    inputConstraint.setField(inCol, outVal);
                }
            }
        }
        return inputConstraint;
View Full Code Here

Examples of org.apache.pig.data.Datum

        Tuple inputConstraint = new ExampleTuple();
        inputConstraint.copyFrom(inputConst);

        for (int outCol = 0; outCol < outputConstraint.arity(); outCol++) {
            int inCol = cols.get(outCol);
            Datum outVal = outputConstraint.getField(outCol);
            Datum inVal = inputConstraint.getField(inCol);
           
            if (inVal == null) {
                inputConstraint.setField(inCol, outVal);
            } else {
                if (outVal != null) {
View Full Code Here

Examples of org.apache.pig.data.Datum

   
    static void GenerateMatchingTupleHelper(Tuple t, CompCond pred, boolean invert) throws IOException {
       
        // decide if the eval functions on the two sides of the predicate are simple enough for us to deal with
        boolean leftIsConst = false, rightIsConst = false;
        Datum leftConst = null, rightConst = null;
        int leftCol = -1, rightCol = -1;
        if (pred.left instanceof ConstSpec) {
            leftIsConst = true;
            leftConst = ((ConstSpec) pred.left).atom;
        } else {
            if (!(pred.left instanceof ProjectSpec && ((ProjectSpec) pred.left).numCols() == 1)) return// too hard, give up
            leftCol = ((ProjectSpec) pred.left).getCol(0);
            Datum d = t.getField(leftCol);
            if (d != null) {
                leftIsConst = true;
                leftConst = d;
            }
        }
        if (pred.right instanceof ConstSpec) {
            rightIsConst = true;
            rightConst = ((ConstSpec) pred.right).atom;
        } else {
            if (!(pred.right instanceof ProjectSpec && ((ProjectSpec) pred.right).numCols() == 1)) return// too hard, give up
            rightCol = ((ProjectSpec) pred.right).getCol(0);
            Datum d = t.getField(rightCol);
            if (d != null) {
                rightIsConst = true;
                rightConst = d;
            }
        }
View Full Code Here

Examples of org.apache.pig.data.Datum

       
        while (true) { // loop until we find a tuple we're allowed to output (or we hit the end)

            // find the smallest group among all inputs (this is the group we should make a tuple
            // out of)
            Datum smallestGroup = null;
            for (int i = 0; i < inputs.length; i++) {
                if (sortedInputs[i].size() > 0) {
                    Datum g = (sortedInputs[i].get(0))[0];
                    if (smallestGroup == null || g.compareTo(smallestGroup)<0)
                        smallestGroup = g;
                }
            }

            if (smallestGroup == null)
                return null; // we hit the end of the groups, so we're done

            // find all tuples in each input pertaining to the group of interest, and combine the
            // data into a single tuple
           
            Tuple output;
            ExampleTuple tOut = new ExampleTuple();
            if (outputType == LogicalOperator.AMENDABLE) output = new AmendableTuple(1 + inputs.length, smallestGroup);
            else output = new Tuple(1 + inputs.length);

            // set first field to the group tuple
            output.setField(0, smallestGroup);
            tOut.copyFrom(output);
            if (lineageTracer != null) lineageTracer.insert(tOut);

            boolean done = true;
            for (int i = 0; i < inputs.length; i++) {
                DataBag b = BagFactory.getInstance().newDefaultBag();

                while (sortedInputs[i].size() > 0) {
                    Datum g = sortedInputs[i].get(0)[0];

                    Tuple t = (Tuple) sortedInputs[i].get(0)[1];

                    if (g.compareTo(smallestGroup) < 0) {
                        sortedInputs[i].remove(0); // discard this tuple
                    } else if (g.equals(smallestGroup)) {
                        b.add(t);
                        //if (lineageTracer != null) lineageTracer.union(t, output);   // update lineage
                        if (lineageTracer != null) {
                          if(((ExampleTuple)t).isSynthetic()) tOut.makeSynthetic();
                          lineageTracer.union(t, tOut);   // update lineage
View Full Code Here

Examples of org.apache.pig.data.Datum

            output.setValue(sum(input));
        }
    }

    static protected long count(Tuple input) throws IOException {
        Datum values = input.getField(0);       
        if (values instanceof DataBag)
            return ((DataBag)values).size();
        else if (values instanceof DataMap)
            return ((DataMap)values).cardinality();
        else
            throw new IOException("Cannot count a " + values.getClass().getSimpleName());
    }
View Full Code Here

Examples of org.apache.pig.data.Datum

    static String ShortenField(Tuple t) {
      StringBuffer str = new StringBuffer();
      int noFields = t.arity();
      str.append("(");
      if(noFields > 3) {
        Datum d = t.getField(0);
     
      str.append(ShortenField(d) + ", ..., ");
      d = t.getField(noFields - 1);
     
      str.append(ShortenField(d));
       
      } else {
        for(int i = 0; i < noFields; ++i) {
          Datum d;
        d = t.getField(i);
       
        if(i != (noFields - 1)) {
          str.append(ShortenField(d) + ", ");
        } else {
View Full Code Here

Examples of org.apache.pig.data.Datum

  public void exec(Tuple input, DataAtom output) throws IOException {
    output.setValue(toRadian(input));
  }
 
  protected double toRadian(Tuple input) throws IOException{
    Datum temp = input.getField(0);
    double retVal;
    if(!(temp instanceof DataAtom)){
      throw new IOException("invalid input format. ");
    }
    else{
View Full Code Here

Examples of org.apache.pig.data.Datum

  public void exec(Tuple input, DataAtom output) throws IOException {
    output.setValue(cbrt(input));
  }
 
  protected double cbrt(Tuple input) throws IOException{
    Datum temp = input.getField(0);
    double retVal;
    if(!(temp instanceof DataAtom)){
      throw new IOException("invalid input format. ");
    }
    else{
View Full Code Here

Examples of org.apache.rat.api.MetaData.Datum

        }
        Arrays.sort(this.approvedLicenseNames);
    }

    public void reportLicenseApprovalClaim(final Document subject, final boolean isAcceptable) {
        final Datum datum;
        if (isAcceptable) {
            datum = MetaData.RAT_APPROVED_LICENSE_DATIM_TRUE;
        } else {
            datum = MetaData.RAT_APPROVED_LICENSE_DATIM_FALSE;
        }
View Full Code Here

Examples of org.apache.tajo.datum.Datum

    init();
  }

  @Override
  public boolean getBoolean(int fieldId) throws SQLException {
    Datum datum = cur.get(fieldId - 1);
    handleNull(datum);
    return datum.asBool();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.