PigContext pc = new PigContext();
@Before
public void setUp() throws Exception {
pc.connect();
GenPhyOp.setPc(pc);
POLoad ld1 = GenPhyOp.topLoadOp();
String curDir = System.getProperty("user.dir");
String inpDir = curDir + File.separatorChar + "test/org/apache/pig/test/data/InputFiles/";
FileSpec fSpec = new FileSpec("file:"+ inpDir +"passwd", new FuncSpec(PigStorage.class.getName() , new String[]{":"}));
ld1.setLFile(fSpec);
POLoad ld2 = GenPhyOp.topLoadOp();
ld2.setLFile(fSpec);
POFilter fl1 = GenPhyOp.topFilterOpWithProj(1, 50, GenPhyOp.LTE);
POFilter fl2 = GenPhyOp.topFilterOpWithProj(1, 50, GenPhyOp.GT);
int[] flds = {0,2};
Tuple sample = new DefaultTuple();
sample.append(new String("S"));
sample.append(new String("x"));
sample.append(new Integer("10"));
sample.append(new Integer("20"));
sample.append(new String("S"));
sample.append(new String("x"));
sample.append(new String("S"));
sample.append(new String("x"));
POForEach fe1 = GenPhyOp.topForEachOPWithPlan(flds , sample);
POForEach fe2 = GenPhyOp.topForEachOPWithPlan(flds , sample);
sp = GenPhyOp.topUnionOp();
PhysicalPlan plan = new PhysicalPlan();
plan.add(ld1);
plan.add(ld2);
plan.add(fl1);
plan.add(fl2);
plan.add(fe1);
plan.add(fe2);
plan.add(sp);
plan.connect(ld1, fe1);
plan.connect(fe1, fl1);
plan.connect(ld2, fe2);
plan.connect(fe2, fl2);
plan.connect(fl1, sp);
plan.connect(fl2, sp);
/*PlanPrinter ppp = new PlanPrinter(plan);
ppp.visit();*/
POLoad ld3 = GenPhyOp.topLoadOp();
ld3.setLFile(fSpec);
DataBag fullBag = DefaultBagFactory.getInstance().newDefaultBag();
Tuple t=null;
for(Result res=ld3.getNext(t);res.returnStatus!=POStatus.STATUS_EOP;res=ld3.getNext(t)){
fullBag.add((Tuple)res.result);
}
int[] fields = {0,2};
expBag = TestHelper.projectBag(fullBag, fields);