Examples of POSort


Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort

            popWalker();
        }
        currentPlan = currentPlans.pop();

        // get the physical operator for sort
        POSort poSort;
        if (sort.getUserFunc() == null) {
            poSort = new POSort(new OperatorKey(scope, nodeGen
                    .getNextNodeId(scope)), sort.getRequestedParallelisam(), null,
                    sortPlans, sort.getAscendingCols(), null);
        } else {
            POUserComparisonFunc comparator = new POUserComparisonFunc(new OperatorKey(
                    scope, nodeGen.getNextNodeId(scope)), sort
                    .getRequestedParallelisam(), null, sort.getUserFunc());
            poSort = new POSort(new OperatorKey(scope, nodeGen
                    .getNextNodeId(scope)), sort.getRequestedParallelisam(), null,
                    sortPlans, sort.getAscendingCols(), comparator);
        }
        poSort.setAlias(sort.getAlias());
        poSort.setLimit(sort.getLimit());
        // sort.setRequestedParallelism(s.getType());
        logToPhyMap.put(sort, poSort);
        currentPlan.add(poSort);
        List<Operator> op = sort.getPlan().getPredecessors(sort);
        PhysicalOperator from;
       
        if(op != null) {
            from = logToPhyMap.get(op.get(0));
        } else {
            int errCode = 2051;
            String msg = "Did not find a predecessor for Sort." ;
            throw new LogicalToPhysicalTranslatorException(msg, errCode, PigException.BUG);           
        }
       
        try {
            currentPlan.connect(from, poSort);
        } catch (PlanException e) {
            int errCode = 2015;
            String msg = "Invalid physical operators in the physical plan" ;
            throw new LogicalToPhysicalTranslatorException(msg, errCode, PigException.BUG, e);
        }

        poSort.setResultType(DataType.BAG);
        poSort.setSortInfo(sort.getSortInfo());
    }
View Full Code Here

Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort

    List<Boolean> mAscCols = new LinkedList<Boolean>();
    mAscCols.add(true);
    PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
    List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
    inputs.add(read);
    POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
        sortPlans, mAscCols, null);
   
    //verify
    Tuple t = null;
    Result res1 = sort.getNext(t);
    Result res2 = sort.getNext(t);

    while (res2.returnStatus != POStatus.STATUS_EOP) {
      Object i1 = ((Tuple) res1.result).get(0);
      Object i2 = ((Tuple) res2.result).get(0);
     
      //System.out.println("i1: " + i1.toString() + " i2: " + i2.toString());
      int i = DataType.compare(i1, i2);
      System.out.println("RESULT2=i : " + res2.result + " i = " + i);
      assertEquals(true, (i <= 0));
      res1 = res2;
      res2 = sort.getNext(t);
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort

    List<Boolean> mAscCols = new LinkedList<Boolean>();
    mAscCols.add(false);
    PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
    List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
    inputs.add(read);
    POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
        sortPlans, mAscCols, null);
    Tuple t = null;
    Result res1 = sort.getNext(t);
    // System.out.println(res1.result);
    Result res2 = sort.getNext(t);
    while (res2.returnStatus != POStatus.STATUS_EOP) {
      Object i1 = ((Tuple) res1.result).get(0);
      Object i2 = ((Tuple) res2.result).get(0);
      int i = DataType.compare(i1, i2);
      // System.out.println(res2.result + " i = " + i);
      assertEquals(true, (i >= 0));
      res1 = res2;
      res2 = sort.getNext(t);
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort

    List<Boolean> mAscCols = new LinkedList<Boolean>();
    mAscCols.add(true);
    PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
    List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
    inputs.add(read);
    POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
        sortPlans, mAscCols, null);
    Tuple t = null;
    Result res1 = sort.getNext(t);
    // System.out.println(res1.result);
    Result res2 = sort.getNext(t);
    while (res2.returnStatus != POStatus.STATUS_EOP) {
      Object i1 = ((Tuple) res1.result).get(1);
      Object i2 = ((Tuple) res2.result).get(1);
      int i = DataType.compare(i1, i2);
      assertEquals(true, (i <= 0));
      // System.out.println(res2.result);
      res1 = res2;
      res2 = sort.getNext(t);
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort

    List<Boolean> mAscCols = new LinkedList<Boolean>();
    mAscCols.add(false);
    PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
    List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
    inputs.add(read);
    POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
        sortPlans, mAscCols, null);
    Tuple t = null;
    Result res1 = sort.getNext(t);
    // System.out.println(res1.result);
    Result res2 = sort.getNext(t);
    while (res2.returnStatus != POStatus.STATUS_EOP) {
      Object i1 = ((Tuple) res1.result).get(1);
      Object i2 = ((Tuple) res2.result).get(1);
      int i = DataType.compare(i1, i2);
      assertEquals(true, (i >= 0));
      // System.out.println(res2.result);
      res1 = res2;
      res2 = sort.getNext(t);
    }
  }
View Full Code Here

Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort

        PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
        List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
        inputs.add(read);

        POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
                                 sortPlans, mAscCols, null);

        Tuple t = null;
        Result res ;
        // output line 1
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 1) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 10) ;
        // output line 2
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 2) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
        // output line 3
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 3) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
       
    }
View Full Code Here

Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort

        PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
        List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
        inputs.add(read);

        POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
                                 sortPlans, mAscCols, null);

        Tuple t = null;
        Result res ;
        // output line 1
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), null) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 10) ;
         // output line 2
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 1) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
        // output line 3
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 3) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
        // output line 4
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), null) ;
        Assert.assertEquals(((Tuple) res.result).get(1), null) ;
        // output line 5
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 1 );
        Assert.assertEquals(((Tuple) res.result).get(1), null) ;

     
    }
View Full Code Here

Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort

        PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
        List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
        inputs.add(read);

        POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
                                 sortPlans, mAscCols, null);

        Tuple t = null;
        Result res ;
        // output line 1
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 3) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 5) ;
        // output line 2
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 3) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
        // output line 3
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 1) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 2) ;

    }
View Full Code Here

Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort

        PORead read = new PORead(new OperatorKey("", r.nextLong()), input);
        List<PhysicalOperator> inputs = new LinkedList<PhysicalOperator>();
        inputs.add(read);

        POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
                                 sortPlans, mAscCols, null);

        Tuple t = null;
        Result res ;
        // output line 1
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 3) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
        // output line 2
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 1) ;
        Assert.assertEquals(((Tuple) res.result).get(1), null) ;
        // output line 3
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), 1) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 8) ;
        // output line 4
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), null) ;
        Assert.assertEquals(((Tuple) res.result).get(1), null) ;
        // output line 5
        res = sort.getNext(t);
        Assert.assertEquals(((Tuple) res.result).get(0), null) ;
        Assert.assertEquals(((Tuple) res.result).get(1), 10) ;


    }
View Full Code Here

Examples of org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POSort

    String funcName = WeirdComparator.class.getName() + "()";
    /*POUserFunc comparator = new POUserFunc(
        new OperatorKey("", r.nextLong()), -1, inputs, funcName);*/
    POUserComparisonFunc comparator = new POUserComparisonFunc(
        new OperatorKey("", r.nextLong()), -1, null, new FuncSpec(funcName));
    POSort sort = new POSort(new OperatorKey("", r.nextLong()), -1, inputs,
        null, null, comparator);
    Tuple t = null;
    Result res1 = sort.getNext(t);
    // System.out.println(res1.result);
    Result res2 = sort.getNext(t);
    while (res2.returnStatus != POStatus.STATUS_EOP) {
      int i1 = ((Integer) ((Tuple) res1.result).get(1) == null ? 0 : (Integer) ((Tuple) res1.result).get(1));
      int i2 = ((Integer) ((Tuple) res2.result).get(1) == null ? 0 : (Integer) ((Tuple) res2.result).get(1));
      int i = (i1 - 50) * (i1 - 50) - (i2 - 50) * (i2 - 50);
      assertEquals(true, (i <= 0));
      System.out.println(i + " : " + res2.result);
      res1 = res2;
      res2 = sort.getNext(t);
    }
    
    }
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.