lp.connect(B, C);
// D = filter
LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
ProjectExpression fy = new ProjectExpression(filterPlan, 0, 1, null);
ConstantExpression fc = new ConstantExpression(filterPlan, new Integer(0), new LogicalFieldSchema(null, null, DataType.INTEGER));
new EqualExpression(filterPlan, fy, fc);
LOFilter D = new LOFilter(lp, filterPlan);
D.neverUseForRealSetSchema(cschema);
lp.add(D);
lp.connect(C, D);
}
// Build a second similar plan to test equality
// A = load
LogicalPlan lp1 = new LogicalPlan();
{
LogicalSchema aschema = new LogicalSchema();
aschema.addField(new LogicalSchema.LogicalFieldSchema(
"x", null, DataType.INTEGER));
LOLoad A = new LOLoad(new FileSpec("/abc",
new FuncSpec(DummyLoad.class.getName(), new String[] {"x", "y"})), aschema, lp1, null);
lp1.add(A);
// B = load
LogicalSchema bschema = new LogicalSchema();
bschema.addField(new LogicalSchema.LogicalFieldSchema(
"y", null, DataType.INTEGER));
LOLoad B = new LOLoad(new FileSpec("/def",
new FuncSpec("PigStorage", "\t")), bschema, lp1, null);
lp1.add(B);
// C = join
LogicalSchema cschema = new LogicalSchema();
cschema.addField(new LogicalSchema.LogicalFieldSchema(
"x", null, DataType.INTEGER));
cschema.addField(new LogicalSchema.LogicalFieldSchema(
"y", null, DataType.INTEGER));
LogicalExpressionPlan aprojplan = new LogicalExpressionPlan();
new ProjectExpression(aprojplan, 0, 0, null);
LogicalExpressionPlan bprojplan = new LogicalExpressionPlan();
new ProjectExpression(bprojplan, 1, 0, null);
MultiMap<Integer, LogicalExpressionPlan> mm =
new MultiMap<Integer, LogicalExpressionPlan>();
mm.put(0, aprojplan);
mm.put(1, bprojplan);
LOJoin C = new LOJoin(lp1, mm, JOINTYPE.HASH, new boolean[] {true, true});
C.neverUseForRealSetSchema(cschema);
lp1.add(C);
lp1.connect(A, C);
lp1.connect(B, C);
// D = filter
LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
ProjectExpression fy = new ProjectExpression(filterPlan, 0, 1, null);
ConstantExpression fc = new ConstantExpression(filterPlan, new Integer(0), new LogicalFieldSchema(null, null, DataType.INTEGER));
new EqualExpression(filterPlan, fy, fc);
LOFilter D = new LOFilter(lp1, filterPlan);
D.neverUseForRealSetSchema(cschema);
lp1.add(D);
lp1.connect(C, D);