### Question:
SortExec extends UnaryPhysicalExec { @Override abstract public Tuple next() throws IOException; SortExec(TaskAttemptContext context, Schema inSchema,
                  Schema outSchema, PhysicalExec child, SortSpec [] sortSpecs); SortSpec[] getSortSpecs(); Comparator<Tuple> getComparator(); @Override abstract Tuple next();  }### Answer:
@Test public final void testNext() throws IOException, PlanningException { FileFragment[] frags = StorageManager.splitNG(conf, "default.employee", employeeMeta, tablePath, Integer.MAX_VALUE); Path workDir = CommonTestingUtil.getTestDir("target/test-data/TestSortExec"); TaskAttemptContext ctx = new TaskAttemptContext(conf, LocalTajoTestingUtility .newQueryUnitAttemptId(), new FileFragment[] { frags[0] }, workDir); ctx.setEnforcer(new Enforcer()); Expr context = analyzer.parse(QUERIES[0]); LogicalPlan plan = planner.createPlan(LocalTajoTestingUtility.createDummySession(), context); LogicalNode rootNode = optimizer.optimize(plan); PhysicalPlanner phyPlanner = new PhysicalPlannerImpl(conf, sm); PhysicalExec exec = phyPlanner.createPlan(ctx, rootNode); Tuple tuple; Datum preVal = null; Datum curVal; exec.init(); while ((tuple = exec.next()) != null) { curVal = tuple.get(0); if (preVal != null) { assertTrue(preVal.lessThanEqual(curVal).asBool()); } preVal = curVal; } exec.close(); }
@Test public final void testNext() throws IOException, PlanningException { FileFragment[] frags = StorageManager.splitNG(conf, "employee", employeeMeta, tablePath, Integer.MAX_VALUE); Path workDir = CommonTestingUtil.getTestDir("target/test-data/TestSortExec"); TaskAttemptContext ctx = new TaskAttemptContext(conf, LocalTajoTestingUtility .newQueryUnitAttemptId(), new FileFragment[] { frags[0] }, workDir); ctx.setEnforcer(new Enforcer()); Expr context = analyzer.parse(QUERIES[0]); LogicalPlan plan = planner.createPlan(context); LogicalNode rootNode = optimizer.optimize(plan); PhysicalPlanner phyPlanner = new PhysicalPlannerImpl(conf, sm); PhysicalExec exec = phyPlanner.createPlan(ctx, rootNode); Tuple tuple; Datum preVal = null; Datum curVal; exec.init(); while ((tuple = exec.next()) != null) { curVal = tuple.get(0); if (preVal != null) { assertTrue(preVal.lessThanEqual(curVal).asBool()); } preVal = curVal; } exec.close(); }
@Test public final void testNext() throws IOException, PlanningException { FileFragment[] frags = FileStorageManager.splitNG(conf, "default.employee", employeeMeta, tablePath, Integer.MAX_VALUE); Path workDir = CommonTestingUtil.getTestDir(TajoTestingCluster.DEFAULT_TEST_DIRECTORY + "/TestSortExec"); TaskAttemptContext ctx = new TaskAttemptContext(new QueryContext(conf), LocalTajoTestingUtility .newTaskAttemptId(), new FileFragment[] { frags[0] }, workDir); ctx.setEnforcer(new Enforcer()); Expr context = analyzer.parse(QUERIES[0]); LogicalPlan plan = planner.createPlan(LocalTajoTestingUtility.createDummyContext(conf), context); LogicalNode rootNode = optimizer.optimize(plan); PhysicalPlanner phyPlanner = new PhysicalPlannerImpl(conf); PhysicalExec exec = phyPlanner.createPlan(ctx, rootNode); Tuple tuple; Datum preVal = null; Datum curVal; exec.init(); while ((tuple = exec.next()) != null) { curVal = tuple.get(0); if (preVal != null) { assertTrue(preVal.lessThanEqual(curVal).asBool()); } preVal = curVal; } exec.close(); }