Package org.apache.pig.data

Examples of org.apache.pig.data.DataAtom


            for(int i=0;i<input.arity();i++){
                for(int j=i+1;j<input.arity();j++){
                    DataBag first = input.getBagField(i);
                    DataBag second = input.getBagField(j);
                    output.appendField(computeAll(first, second));
                    output.appendField(new DataAtom(first.size()));
                   
                }
            }
           
            } catch(RuntimeException t) {
View Full Code Here


                + numvals
                + "'using org.apache.pig.test.RangeSlicer()) all) generate COUNT($1);";
        pigServer.registerQuery(query);
        Iterator<Tuple> it = pigServer.openIterator("vals");
        Tuple cur = it.next();
        DataAtom val = cur.getAtomField(0);
        assertEquals(numvals, (int) val.longVal());
    }
View Full Code Here

       
        if (!(d1 instanceof DataAtom) || !(d2 instanceof DataAtom)){
            throw new RuntimeException("Builtin functions cannot be used to compare non-atomic values. Use a filter function instead.");
        }
       
        DataAtom da1 = (DataAtom)d1;
        DataAtom da2 = (DataAtom)d2;
       
       
        char op1 = op.charAt(0);
        char op2 = op.length() >= 2 ? op.charAt(1) : '0';
        char op3 = op.length() == 3 ? op.charAt(2) : '0';
       
        switch (op1) {
            // numeric ops first
        case '=':
            if (op2 == '=') {
                return da1.numval().equals(da2.numval());
            } else {
                throw new RuntimeException("Internal error: Invalid filter operator: " + op);
            }
        case '<':
            if (op2 == '=') {
                return da1.numval().compareTo(da2.numval()) <= 0;
            } else {
                return da1.numval().compareTo(da2.numval()) < 0;
            }
        case '>':
            if (op2 == '=') {
                return da1.numval().compareTo(da2.numval()) >= 0;
            } else {
                return da1.numval().compareTo(da2.numval()) > 0;
            }
        case '!':
            if (op2 == '=') {
                return !da1.numval().equals(da2.numval());
            } else {
                throw new RuntimeException("Internal error: Invalid filter operator: " + op);
            }
            // now string ops
        case 'e':
View Full Code Here

        this.constant = constant.toString();
        init();
    }
   
    private void init(){
        atom = new DataAtom(constant);
    }
View Full Code Here

    while (it2.hasNext()) {
      String hour = it2.next();
      Long count = pairs.get(hour);
      if ( count > mean ) {
        Tuple t = new Tuple();
        t.appendField(new DataAtom(hour));
        t.appendField(new DataAtom( ((double) count - mean) / standardDeviation )); // the score
        t.appendField(new DataAtom(count));
        t.appendField(new DataAtom(mean));
        arg1.add(t);
      }
    }
   
  }
View Full Code Here

        // test excution
        String data = "Hello World!";
        String expected = "HELLO WORLD!";

        DataAtom field = new DataAtom(data);
        Tuple input = new Tuple(field);
        DataAtom output = new DataAtom();

        func.exec(input, output);
        assertTrue(output.strval().equals(expected));

        // test schema creation
        String fieldName = "field1";
        AtomSchema fieldSchema = new AtomSchema(fieldName);
        TupleSchema tupleSchema = new TupleSchema();
View Full Code Here

    }
   
    @Override
    public void exec(Tuple input, DataBag output) throws IOException{
        for (int i=0; i<numGroups; i++){
            output.add(new Tuple(new DataAtom(i)));
        }
    }
View Full Code Here

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

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

  
   public void testASIN() throws Exception {
          EvalFunc<DataAtom> ASIN = new ASIN();
          Tuple tup = new Tuple(1);
          tup.setField(0, 0.5);
          DataAtom output = new DataAtom();
          ASIN.exec(tup, output);
          double expected = Math.asin(0.5);
          double actual = (new Double(output.strval())).doubleValue();
          assertEquals(actual, expected, delta);
      }
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.