Package org.apache.pig.data

Examples of org.apache.pig.data.TupleFactory


        assertEquals("amy smith", t.get(3));
    }
   
    @Test
    public void testTOKENIZE() throws Exception {
        TupleFactory tf = TupleFactory.getInstance();
        Tuple t1 = tf.newTuple(1);
        t1.set(0, "123 456\"789");
        Tuple t2 = tf.newTuple(1);
        t2.set(0, null);
        Tuple t3 = tf.newTuple(0);
       
        TOKENIZE f = new TOKENIZE();
        DataBag b = f.exec(t1);
        assertTrue(b.size()==3);
        Iterator<Tuple> i = b.iterator();
View Full Code Here


    @Test
    public void testDIFF() throws Exception {
        // Test it in the case with two bags.
        BagFactory bf = BagFactory.getInstance();
        TupleFactory tf = TupleFactory.getInstance();

        DataBag b1 = bf.newDefaultBag();
        DataBag b2 = bf.newDefaultBag();
        for (int i = 0; i < 10; i++) b1.add(tf.newTuple(new Integer(i)));
        for (int i = 0; i < 10; i += 2) b2.add(tf.newTuple(new Integer(i)));
        Tuple t = tf.newTuple(2);
        t.set(0, b1);
        t.set(1, b2);
        DIFF d = new DIFF();
        DataBag result = d.exec(t);

        assertEquals(5, result.size());
        Iterator<Tuple> i = result.iterator();
        int[] values = new int[5];
        for (int j = 0; j < 5; j++) values[j] = (Integer)i.next().get(0);
        Arrays.sort(values);
        for (int j = 1; j < 10; j += 2) assertEquals(j, values[j/2]);

        // Test it in the case of two objects that are equals
        t = tf.newTuple(2);
        t.set(0, new Integer(1));
        t.set(1, new Integer(1));
        result = d.exec(t);
        assertEquals(0, result.size());

        // Test it in the case of two objects that are not equal
        t = tf.newTuple(2);
        t.set(0, new Integer(1));
        t.set(1, new Integer(2));
        result = d.exec(t);
        assertEquals(2, result.size());
    }
View Full Code Here

    }
   
    static public class MyBagFunction extends EvalFunc<DataBag>{
        @Override
        public DataBag exec(Tuple input) throws IOException {
            TupleFactory tf = TupleFactory.getInstance();
            DataBag output = BagFactory.getInstance().newDefaultBag();
            output.add(tf.newTuple("a"));
            output.add(tf.newTuple("a"));
            output.add(tf.newTuple("a"));
            return output;
        }
View Full Code Here

    static public class MapUDF extends EvalFunc<Map<String, Object>> {
        @Override
        public Map<String, Object> exec(Tuple input) throws IOException {

            TupleFactory tupleFactory = TupleFactory.getInstance();
            ArrayList<Object> objList = new ArrayList<Object>();
            objList.add(new Integer(1));
            objList.add(new Double(1.0));
            objList.add(new Float(1.0));
            objList.add(new String("World!"));
            Tuple tuple = tupleFactory.newTuple(objList);

            BagFactory bagFactory = BagFactory.getInstance();
            DataBag bag = bagFactory.newDefaultBag();
            bag.add(tuple);
View Full Code Here

    // Plan to test when result type is ByteArray and casting is requested
    // for example casting of values coming out of map lookup.
    POCast opWithInputTypeAsBA = new POCast(new OperatorKey("", r.nextLong()), -1);
    PhysicalPlan planToTestBACasts = constructPlan(opWithInputTypeAsBA);
   
    TupleFactory tf = TupleFactory.getInstance();
   
    {
      Tuple t = tf.newTuple();
      t.append((new Integer(r.nextInt())).toString());
      plan.attachInput(t);
      Integer i = Integer.valueOf(((String) t.get(0)));
      Result res = op.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK) {
        //System.out.println(res.result + " : " + i);
        assertEquals(i, res.result);
      }
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(i, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append((new Float(r.nextFloat())).toString());
      plan.attachInput(t);
      Float i = Float.valueOf(((String) t.get(0)));
      Result res = op.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK) {
        //System.out.println(res.result + " : " + i);
        assertEquals(i, res.result);
      }
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(i, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append((new Long(r.nextLong())).toString());
      plan.attachInput(t);
      Long i = Long.valueOf(((String) t.get(0)));
      Result res = op.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK) {
        //System.out.println(res.result + " : " + i);
        assertEquals(i, res.result);
      }
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(i, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append((new Double(r.nextDouble())).toString());
      plan.attachInput(t);
      Double i = Double.valueOf(((String) t.get(0)));
      Result res = op.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK) {
        //System.out.println(res.result + " : " + i);
        assertEquals(i, res.result);
      }
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(i, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      plan.attachInput(t);
      String str = (String) t.get(0);
      Result res = op.getNext(str);
      if(res.returnStatus == POStatus.STATUS_OK) {
        //System.out.println(res.result + " : " + str);
        assertEquals(str, res.result);
      }
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(str);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(str, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
   
      plan.attachInput(t);
      DataByteArray dba = new DataByteArray(((String)t.get(0)).getBytes());
      Result res = op.getNext(dba);
      if(res.returnStatus == POStatus.STATUS_OK) {
        //System.out.println(res.result + " : " + dba);
        assertEquals(dba, res.result);
      }
     
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(dba);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(dba, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      plan.attachInput(t);
      Map map = null;
      Result res = op.getNext(map);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      plan.attachInput(t);
      Result res = op.getNext(t);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      plan.attachInput(t);
      DataBag b = null;
      Result res = op.getNext(b);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
View Full Code Here

    plan.add(op);
    plan.connect(prj, op);
   
    prj.setResultType(DataType.BYTEARRAY);
   
    TupleFactory tf = TupleFactory.getInstance();
   
    // Plan to test when result type is ByteArray and casting is requested
    // for example casting of values coming out of map lookup.
    POCast opWithInputTypeAsBA = new POCast(new OperatorKey("", r.nextLong()), -1);
    PhysicalPlan planToTestBACasts = constructPlan(opWithInputTypeAsBA);
    {
      Tuple t = tf.newTuple();
      t.append(new DataByteArray((new Integer(r.nextInt())).toString().getBytes()));
      plan.attachInput(t);
      Integer i = Integer.valueOf(((DataByteArray) t.get(0)).toString());
      Result res = op.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK) {
        //System.out.println(res.result + " : " + i);
        assertEquals(i, res.result);
      }
     
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(i, res.result);

    }

    {
      Tuple t = tf.newTuple();
      t.append(new DataByteArray((new Float(r.nextFloat())).toString().getBytes()));
      plan.attachInput(t);
      Float i = Float.valueOf(((DataByteArray) t.get(0)).toString());
      Result res = op.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK) {
        //System.out.println(res.result + " : " + i);
        assertEquals(i, res.result);
      }
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(i, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(new DataByteArray((new Long(r.nextLong())).toString().getBytes()));
      plan.attachInput(t);
      Long i = Long.valueOf(((DataByteArray) t.get(0)).toString());
      Result res = op.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK) {
        //System.out.println(res.result + " : " + i);
        assertEquals(i, res.result);
      }
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(i, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(new DataByteArray((new Double(r.nextDouble())).toString().getBytes()));
      plan.attachInput(t);
      Double i = Double.valueOf(((DataByteArray) t.get(0)).toString());
      Result res = op.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK) {
        //System.out.println(res.result + " : " + i);
        assertEquals(i, res.result);
      }
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(i);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(i, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(new DataByteArray(GenRandomData.genRandString(r).getBytes()));
      plan.attachInput(t);
      String str = ((DataByteArray) t.get(0)).toString();
      Result res = op.getNext(str);
      if(res.returnStatus == POStatus.STATUS_OK) {
        //System.out.println(res.result + " : " + str);
        assertEquals(str, res.result);
      }
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(str);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(str, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(new DataByteArray(GenRandomData.genRandString(r).getBytes()));
     
      plan.attachInput(t);
      DataByteArray dba = (DataByteArray) t.get(0);
      Result res = op.getNext(dba);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
     
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(dba);
      if(res.returnStatus == POStatus.STATUS_OK)
        assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(new DataByteArray(GenRandomData.genRandString(r).getBytes()));
      plan.attachInput(t);
      Map map = null;
      Result res = op.getNext(map);
      //assertEquals(POStatus.STATUS_ERR, res.returnStatus);
      assertEquals(POStatus.STATUS_OK, res.returnStatus);
      assertEquals(null, res.result);
     
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(map);
      assertEquals(POStatus.STATUS_OK, res.returnStatus);
      assertEquals(null, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(new DataByteArray(GenRandomData.genRandString(r).getBytes()));
      plan.attachInput(t);
      Result res = op.getNext(t);
      //assertEquals(POStatus.STATUS_ERR, res.returnStatus);
      assertEquals(POStatus.STATUS_OK, res.returnStatus);
      assertEquals(null, res.result);
     
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(t);
      assertEquals(POStatus.STATUS_OK, res.returnStatus);
      assertEquals(null, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(new DataByteArray(GenRandomData.genRandString(r).getBytes()));
      plan.attachInput(t);
      DataBag b = null;
      Result res = op.getNext(b);
      //assertEquals(POStatus.STATUS_ERR, res.returnStatus);
View Full Code Here

     */
  @Test
  public void testByteArrayToOtherNoCast() throws IOException {
        POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
        PhysicalPlan plan = constructPlan(op);
        TupleFactory tf = TupleFactory.getInstance();
       
        {
            Tuple t = tf.newTuple();
            Integer input = new Integer(r.nextInt());
            t.append(input);
            plan.attachInput(t);
            Result res = op.getNext(new Integer(0));
            if(res.returnStatus == POStatus.STATUS_OK) {
                //System.out.println(res.result + " : " + i);
                assertEquals(input, res.result);
            }
        }
       
        {
            // create a new POCast each time since we
            // maintain a state variable per POCast object
            // indicating if cast is really required
            POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
            plan = constructPlan(newOp);
            Tuple t = tf.newTuple();
            Float input = new Float(r.nextFloat());
            t.append(input);
            plan.attachInput(t);
            Result res = newOp.getNext(new Float(0));
            if(res.returnStatus == POStatus.STATUS_OK) {
                //System.out.println(res.result + " : " + i);
                assertEquals(input, res.result);
            }
        }
       
        {
            // create a new POCast each time since we
            // maintain a state variable per POCast object
            // indicating if cast is really required
            POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
            plan = constructPlan(newOp);
            Tuple t = tf.newTuple();
            Long input = new Long(r.nextLong());
            t.append(input);
            plan.attachInput(t);
            Result res = newOp.getNext(new Long(0));
            if(res.returnStatus == POStatus.STATUS_OK) {
                //System.out.println(res.result + " : " + i);
                assertEquals(input, res.result);
            }
        }
       
        {
            // create a new POCast each time since we
            // maintain a state variable per POCast object
            // indicating if cast is really required
            POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
            plan = constructPlan(newOp);
            Tuple t = tf.newTuple();
            Double input = new Double(r.nextDouble());
            t.append(input);
            plan.attachInput(t);
            Result res = newOp.getNext(new Double(0));
            if(res.returnStatus == POStatus.STATUS_OK) {
                //System.out.println(res.result + " : " + i);
                assertEquals(input, res.result);
            }
        }
       
        {
            // create a new POCast each time since we
            // maintain a state variable per POCast object
            // indicating if cast is really required
            POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
            plan = constructPlan(newOp);
            Tuple t = tf.newTuple();
            Tuple input = GenRandomData.genRandSmallTuple("test", 1);
            t.append(input);
            plan.attachInput(t);
            Result res = newOp.getNext(tf.newTuple());
            if(res.returnStatus == POStatus.STATUS_OK) {
                //System.out.println(res.result + " : " + str);
                assertEquals(input, res.result);
            }
        }
       
        {
            // create a new POCast each time since we
            // maintain a state variable per POCast object
            // indicating if cast is really required
            POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
            plan = constructPlan(newOp);
            Tuple t = tf.newTuple();
            DataBag input = GenRandomData.genRandSmallTupDataBag(r, 10, 100);
            t.append(input);
            plan.attachInput(t);
            Result res = newOp.getNext(DefaultBagFactory.getInstance().newDefaultBag());
            if(res.returnStatus == POStatus.STATUS_OK) {
                //System.out.println(res.result + " : " + str);
                assertEquals(input, res.result);
            }
        }
       
        {
            // create a new POCast each time since we
            // maintain a state variable per POCast object
            // indicating if cast is really required
            POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
            plan = constructPlan(newOp);
            Tuple t = tf.newTuple();
            Map<String, Object> input = new HashMap<String, Object>();
            input.put("key1", "value1");
            input.put("key2", "value2");
            t.append(input);
            plan.attachInput(t);
View Full Code Here

    plan.add(op);
    plan.connect(prj, op);
   
    prj.setResultType(DataType.TUPLE);
   
    TupleFactory tf = TupleFactory.getInstance();
   
    //Plan to test when result type is ByteArray and casting is requested
    //for example casting of values coming out of map lookup.
    POCast opWithInputTypeAsBA = new POCast(new OperatorKey("", r.nextLong()), -1);
    PhysicalPlan planToTestBACasts = constructPlan(opWithInputTypeAsBA);
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      Tuple tNew = tf.newTuple();
      tNew.append(t);
      plan.attachInput(tNew);
      Map map = null;
      Result res = op.getNext(map);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      Tuple tNew = tf.newTuple();
      tNew.append(t);
      plan.attachInput(tNew);
      Result res = op.getNext(t);
      //System.out.println(res.result + " : " + t);
      assertEquals(t, res.result);
     
      planToTestBACasts.attachInput(tNew);
      res = opWithInputTypeAsBA.getNext(t);
      assertEquals(t, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      Tuple tNew = tf.newTuple();
      tNew.append(t);
      plan.attachInput(tNew);
      DataBag b = null;
      Result res = op.getNext(b);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      Tuple tNew = tf.newTuple();
      tNew.append(t);
      plan.attachInput(tNew);
      Integer i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      Tuple tNew = tf.newTuple();
      tNew.append(t);
      plan.attachInput(tNew);
      Long i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      Tuple tNew = tf.newTuple();
      tNew.append(t);
      plan.attachInput(tNew);
      Float i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      Tuple tNew = tf.newTuple();
      tNew.append(t);
      plan.attachInput(tNew);
      Double i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
       
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      Tuple tNew = tf.newTuple();
      tNew.append(t);
      plan.attachInput(tNew);
      String i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandString(r));
      Tuple tNew = tf.newTuple();
      tNew.append(t);
      plan.attachInput(tNew);
      DataByteArray i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
View Full Code Here

    plan.add(op);
    plan.connect(prj, op);
   
    prj.setResultType(DataType.BAG);
   
    TupleFactory tf = TupleFactory.getInstance();
   
    //Plan to test when result type is ByteArray and casting is requested
    //for example casting of values coming out of map lookup.
    POCast opWithInputTypeAsBA = new POCast(new OperatorKey("", r.nextLong()), -1);
    PhysicalPlan planToTestBACasts = constructPlan(opWithInputTypeAsBA);
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));
      plan.attachInput(t);
      Map map = null;
      Result res = op.getNext(map);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));
      plan.attachInput(t);
      Result res = op.getNext(t);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));
      plan.attachInput(t);
      DataBag b = (DataBag) t.get(0);
      Result res = op.getNext(b);
      //System.out.println(res.result + " : " + t);
      assertEquals(b, res.result);
     
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(b);
      assertEquals(b, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));
      plan.attachInput(t);
      Integer i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));
      plan.attachInput(t);
      Long i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));      
      plan.attachInput(t);
      Float i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));
      plan.attachInput(t);
      Double i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));
      plan.attachInput(t);
      String i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandSmallTupDataBag(r, 1, 100));
      plan.attachInput(t);
      DataByteArray i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
View Full Code Here

   
    // Plan to test when result type is ByteArray and casting is requested
    // for example casting of values coming out of map lookup.
    POCast opWithInputTypeAsBA = new POCast(new OperatorKey("", r.nextLong()), -1);
    PhysicalPlan planToTestBACasts = constructPlan(opWithInputTypeAsBA);
    TupleFactory tf = TupleFactory.getInstance();
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandMap(r, 10));
      plan.attachInput(t);
      Map map = (Map) t.get(0);
      Result res = op.getNext(map);
      //System.out.println(res.result + " : " + t);
      assertEquals(map, res.result);
        
      planToTestBACasts.attachInput(t);
      res = opWithInputTypeAsBA.getNext(map);
      assertEquals(map, res.result);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandMap(r, 10));
      plan.attachInput(t);
      Result res = op.getNext(t);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
     
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandMap(r, 10));
      plan.attachInput(t);
      DataBag b = null;
      Result res = op.getNext(b);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
     
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandMap(r, 10));
      Integer i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {    
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandMap(r, 10));
      Long i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandMap(r, 10));
      Float i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandMap(r, 10));
      Double i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandMap(r, 10));
      String i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
    }
   
    {
      Tuple t = tf.newTuple();
      t.append(GenRandomData.genRandMap(r, 10));
      plan.attachInput(t);
      DataByteArray i = null;
      Result res = op.getNext(i);
      assertEquals(POStatus.STATUS_ERR, res.returnStatus);
View Full Code Here

TOP

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

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.