// D = filter
LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
LOFilter D = new LOFilter(lp, filterPlan);
ProjectExpression fx = new ProjectExpression(filterPlan, 0, 0, D);
ConstantExpression fc0 = new ConstantExpression(filterPlan, new Integer(0), new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
EqualExpression eq1 = new EqualExpression(filterPlan, fx, fc0);
ProjectExpression fanotherx = new ProjectExpression(filterPlan, 0, 0, D);
ProjectExpression fa = new ProjectExpression(filterPlan, 0, 2, D);
EqualExpression eq2 = new EqualExpression(filterPlan, fanotherx, fa);
AndExpression and1 = new AndExpression(filterPlan, eq1, eq2);
ProjectExpression fb = new ProjectExpression(filterPlan, 0, 3, D);
ConstantExpression fc1 = new ConstantExpression(filterPlan, new Integer(1),new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
EqualExpression eq3 = new EqualExpression(filterPlan, fb, fc1);
AndExpression and2 = new AndExpression(filterPlan, and1, eq3);
ProjectExpression fanotherb = new ProjectExpression(filterPlan, 0, 3, D);
ProjectExpression fy = new ProjectExpression(filterPlan, 0, 1, D);
EqualExpression eq4 = new EqualExpression(filterPlan, fy, fanotherb);
new AndExpression(filterPlan, and2, eq4);
D.setAlias("D");
// Connect D to B, since the transform has happened.
lp.add(D);
lp.connect(C, D);
}
System.out.println(lp);
LogicalPlanOptimizer optimizer = new LogicalPlanOptimizer(lp, 500, null);
optimizer.optimize();
LogicalPlan expected = new LogicalPlan();
{
// A = load
LogicalSchema aschema = new LogicalSchema();
aschema.addField(new LogicalSchema.LogicalFieldSchema(
"x", null, DataType.BYTEARRAY));
aschema.addField(new LogicalSchema.LogicalFieldSchema(
"y", null, DataType.BYTEARRAY));
LOLoad A = new LOLoad(new FileSpec("bla", new FuncSpec("PigStorage", "\t")), aschema, expected, null);
expected.add(A);
// DA = filter
LogicalExpressionPlan DAfilterPlan = new LogicalExpressionPlan();
LOFilter DA = new LOFilter(expected, DAfilterPlan);
ProjectExpression fx = new ProjectExpression(DAfilterPlan, 0, 0, DA);
fx.neverUseForRealSetFieldSchema(new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
ConstantExpression fc0 = new ConstantExpression(DAfilterPlan, new Integer(0), new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
new EqualExpression(DAfilterPlan, fx, fc0);
DA.neverUseForRealSetSchema(aschema);
expected.add(DA);
expected.connect(A, DA);
// B = load
LogicalSchema bschema = new LogicalSchema();
bschema.addField(new LogicalSchema.LogicalFieldSchema(
"a", null, DataType.BYTEARRAY));
bschema.addField(new LogicalSchema.LogicalFieldSchema(
"b", null, DataType.BYTEARRAY));
LOLoad B = new LOLoad(new FileSpec("morebla", new FuncSpec("PigStorage", "\t")), bschema, expected, null);
expected.add(B);
// DB = filter
LogicalExpressionPlan DBfilterPlan = new LogicalExpressionPlan();
LOFilter DB = new LOFilter(expected, DBfilterPlan);
ProjectExpression fb = new ProjectExpression(DBfilterPlan, 0, 1, DB);
fb.neverUseForRealSetFieldSchema(new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
ConstantExpression fc1 = new ConstantExpression(DBfilterPlan, new Integer(1), new LogicalFieldSchema(null, null, DataType.BYTEARRAY));
new EqualExpression(DBfilterPlan, fb, fc1);
DB.neverUseForRealSetSchema(bschema);
expected.add(DB);
expected.connect(B, DB);