Package org.apache.pig.data

Examples of org.apache.pig.data.DataAtom


  
   public void testtoRadians() throws Exception{
       EvalFunc<DataAtom> toRadians = new toRadians();
          Tuple tup = new Tuple(1);
          tup.setField(0, 0.5);
          DataAtom output = new DataAtom();
          toRadians.exec(tup, output);
          double expected = Math.toRadians(0.5);
          double actual = (new Double(output.strval())).doubleValue();
          assertEquals(actual, expected, delta);
   }
View Full Code Here


  
   public void testULP() throws Exception{
       EvalFunc<DataAtom> ULP = new ULP();
          Tuple tup = new Tuple(1);
          tup.setField(0, 0.5);
          DataAtom output = new DataAtom();
          ULP.exec(tup, output);
          double expected = Math.ulp(0.5);
          double actual = (new Double(output.strval())).doubleValue();
          assertEquals(actual, expected, delta);
   }
View Full Code Here

                                             DataCollector endOfPipe) {
        return new DataCollector(endOfPipe){
            private Datum getPlaceHolderForFuncOutput(){
                Type returnType = func.getReturnType();
                if (returnType == DataAtom.class)
                    return new DataAtom();
                else if (returnType == Tuple.class)
                    return new Tuple();
                else if (returnType == DataBag.class)
                    return new FakeDataBag(successor);
                else if (returnType == DataMap.class)
View Full Code Here

  private static Tuple[] getTuples(String[] queries) {
    Tuple[] tuples = new Tuple[queries.length];
    for (int i = 0; i < tuples.length; i++) {
      tuples[i] = new Tuple();
      tuples[i].appendField(new DataAtom(queries[i]));
    }
    return tuples;
  }
View Full Code Here

  public static String[] testDataAtomEvals(EvalFunc<DataAtom> eval, Tuple[] tuples) {
   
    List<String> res = new ArrayList<String>();
    try {
      for (Tuple t : tuples) {
        DataAtom atom = new DataAtom();
        eval.exec(t, atom);
        System.out.println("Converted: " + t + " to (" + atom + ")");
        res.add(atom.strval());
      }
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }
View Full Code Here

    testDataAtomEvals(eval2, getTuples(timestamps));

    DataBag bag = new DefaultDataBag();
   
    Tuple t1 = new Tuple();
    t1.appendField(new DataAtom("word"));
    t1.appendField(new DataAtom("02"));
    t1.appendField(new DataAtom(2));
    bag.add(t1);
   
    Tuple t2 = new Tuple();
    t2.appendField(new DataAtom("word"));
    t2.appendField(new DataAtom("05"));
    t2.appendField(new DataAtom(2));
    bag.add(t2);

    Tuple t3 = new Tuple();
    t3.appendField(new DataAtom("word"));
    t3.appendField(new DataAtom("04"));
    t3.appendField(new DataAtom(3));
    bag.add(t3);

    Tuple t4 = new Tuple();
    t4.appendField(new DataAtom("word"));
    t4.appendField(new DataAtom("06"));
    t4.appendField(new DataAtom(4));
    bag.add(t4);

    Tuple[] t = new Tuple[1];
    t[0] = new Tuple();
    t[0].appendField(bag);
View Full Code Here

    String[] words = TutorialUtil.splitToWords(query);
    Set<String> ngrams = new HashSet<String>();
    TutorialUtil.makeNGram(words, ngrams, _ngramSizeLimit);
    for (String ngram : ngrams) {
      Tuple t = new Tuple();
      t.appendField(new DataAtom(ngram));
      arg1.add(t);
    }
  }
View Full Code Here

            matcher.reset(line);
            if (matcher.find()) {
                ArrayList<Datum> list = new ArrayList<Datum>();

                for (int i = 1; i <= matcher.groupCount(); i++) {
                    list.add(new DataAtom(matcher.group(i)));
                }
                return new Tuple(list);
            }
        }
        return null;
View Full Code Here

        return string;
    }

    public static void examineTuple(ArrayList<String[]> expectedData, Tuple tuple, int tupleCount) {
        for (int i = 0; i < tuple.arity(); i++) {
            DataAtom dataAtom = tuple.getAtomField(i);
            String expected = expectedData.get(tupleCount)[i];
            String actual = dataAtom.toString();
            assertEquals(expected, actual);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.data.DataAtom

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.