Package org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators

Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject


    }
   
    POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
    LoadFunc load = new TestLoader();
    op.setFuncSpec(new FuncSpec(load.getClass().getName()));
    POProject prj = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
    PhysicalPlan plan = new PhysicalPlan();
    plan.add(prj);
    plan.add(op);
    plan.connect(prj, op);
   
    prj.setResultType(DataType.FLOAT);
   
    // 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);
View Full Code Here


    }
   
    POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
    LoadFunc load = new TestLoader();
    op.setFuncSpec(new FuncSpec(load.getClass().getName()));
    POProject prj = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
    PhysicalPlan plan = new PhysicalPlan();
    plan.add(prj);
    plan.add(op);
    plan.connect(prj, op);
   
    prj.setResultType(DataType.DOUBLE);
   
    // 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);
View Full Code Here

  @Test
  public void testStringToOther() throws IOException {
    POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
    LoadFunc load = new TestLoader();
    op.setFuncSpec(new FuncSpec(load.getClass().getName()));
    POProject prj = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
    PhysicalPlan plan = new PhysicalPlan();
    plan.add(prj);
    plan.add(op);
    plan.connect(prj, op);
   
    prj.setResultType(DataType.CHARARRAY);

    // 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);
View Full Code Here

  @Test
  public void testByteArrayToOther() throws IOException {
    POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
    LoadFunc load = new TestLoader();
    op.setFuncSpec(new FuncSpec(load.getClass().getName()));
    POProject prj = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
    PhysicalPlan plan = new PhysicalPlan();
    plan.add(prj);
    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.
View Full Code Here

  }
 
  private PhysicalPlan constructPlan(POCast op) throws IOException {
        LoadFunc load = new TestLoader();
        op.setFuncSpec(new FuncSpec(load.getClass().getName()));
        POProject prj = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
        PhysicalPlan plan = new PhysicalPlan();
        plan.add(prj);
        plan.add(op);
        plan.connect(prj, op);
        prj.setResultType(DataType.BYTEARRAY);
        return plan;
  }
View Full Code Here

 
  @Test
  public void testTupleToOther() throws IOException {
    POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
    op.setFuncSpec(new FuncSpec(PigStorage.class.getName()));
    POProject prj = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
    PhysicalPlan plan = new PhysicalPlan();
    plan.add(prj);
    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.
View Full Code Here

 
  @Test
  public void testBagToOther() throws IOException {
    POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
    op.setFuncSpec(new FuncSpec(PigStorage.class.getName()));
    POProject prj = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
    PhysicalPlan plan = new PhysicalPlan();
    plan.add(prj);
    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.
View Full Code Here

 
  @Test
  public void testMapToOther() throws IOException {
    POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
    op.setFuncSpec(new FuncSpec(PigStorage.class.getName()));
    POProject prj = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
    PhysicalPlan plan = new PhysicalPlan();
    plan.add(prj);
    plan.add(op);
    plan.connect(prj, op);
    prj.setResultType(DataType.MAP);
   
    // 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);
View Full Code Here

      }
     
    }
   
    POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
    POProject prj = new POProject(new OperatorKey("", r.nextLong()), -1, 0);
    PhysicalPlan plan = new PhysicalPlan();      
    plan.add(prj);
    plan.add(op);
    plan.connect(prj, op);
   
    prj.setResultType(DataType.INTEGER);     
   
    for(Iterator<Tuple> it = bag.iterator(); it.hasNext(); ) {
      Tuple t = it.next();
      plan.attachInput(t);
      if(t.get(0) == null) {
       
        Integer result  = (Integer)op.getNext((Integer)null).result;
        assertEquals( null, result);

      }
     
    }
   
    prj.setResultType(DataType.FLOAT);
   
    for(Iterator<Tuple> it = bag.iterator(); it.hasNext(); ) {
      Tuple t = it.next();
      plan.attachInput(t);
      if(t.get(0) == null) {
       
        Integer result  = (Integer)op.getNext((Integer)null).result;
        assertEquals( null, result);

      }
     
    }
   
    prj.setResultType(DataType.DOUBLE);
   
    for(Iterator<Tuple> it = bag.iterator(); it.hasNext(); ) {
      Tuple t = it.next();
      plan.attachInput(t);
      if(t.get(0) == null) {
       
        Double result = (Double) op.getNext((Double) null).result;
      assertEquals(null, result);

      }
    }
   
    prj.setResultType(DataType.CHARARRAY);
   
    for(Iterator<Tuple> it = bag.iterator(); it.hasNext(); ) {
      Tuple t = it.next();
      plan.attachInput(t);
      if(t.get(0) == null) {
       
        String result  = (String)op.getNext((String)null).result;
        assertEquals( null, result);

      }
     
    }
   
    prj.setResultType(DataType.BYTEARRAY);
   
    TupleFactory tf = TupleFactory.getInstance();
   
    {
      Tuple t = tf.newTuple();
View Full Code Here

       
        // we did not see a Non algebraic or a distinct so far
        // proceed to check leaves
        PhysicalOperator leaf = leaves.get(0);
        if (leaf instanceof POProject) {
            POProject proj = (POProject)leaf;
            // Check that it's a simple project.  We can't currently handle
            // things like group.$0, because that requires resetting types on
            // the reduce side.
            if (pp.getPredecessors(proj) != null) return ExprType.NOT_ALGEBRAIC;

            // Check if it's a projection of bag. Currently we can't use combiner
            // for statement like c = foreach b generate group, SUM(a), a;
            // where a is a bag.
            if (proj.getResultType() == DataType.BAG) return ExprType.NOT_ALGEBRAIC;
           
            // Check to see if this is a projection of the grouping column.
            // If so, it will be a projection of col 0 and will have no
            // predecessors (to avoid things like group.$0, which isn't what we
            // want).
            List<Integer> cols = proj.getColumns();
            if (cols != null && cols.size() == 1 && cols.get(0) == 0 &&
                    pp.getPredecessors(proj) == null) {
                mKeyField = field;
                keyFieldPositions[field] = true;
                mKeyType = proj.getResultType();
            } else {
                // It can't be a flatten except on the grouping column
                if (toBeFlattened) return ExprType.NOT_ALGEBRAIC;
            }
            return ExprType.SIMPLE_PROJECT;
View Full Code Here

TOP

Related Classes of org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject

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.