本文整理汇总了Java中org.apache.pig.newplan.logical.relational.LogicalPlan.getSources方法的典型用法代码示例。如果您正苦于以下问题:Java LogicalPlan.getSources方法的具体用法?Java LogicalPlan.getSources怎么用?Java LogicalPlan.getSources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pig.newplan.logical.relational.LogicalPlan
的用法示例。
在下文中一共展示了LogicalPlan.getSources方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFilterConstantConditionCogroupOuter
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
public void testFilterConstantConditionCogroupOuter() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa);" +
"B = load 'anotherfile' as (name, age, preference);" +
"C = cogroup A by $0, B by $0 outer;" +
"D = filter C by 1 == 1;" +
"E = STORE D into 'dummy';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator loadA = null;
Operator loadB = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) ) {
loadA = loads.get( 0 );
loadB = loads.get( 1 );
} else {
loadA = loads.get( 1 );
loadB = loads.get( 0 );
}
Operator filterA = newLogicalPlan.getSuccessors(loadA).get( 0 );
Assert.assertTrue( filterA instanceof LOFilter );
Operator filterB = newLogicalPlan.getSuccessors(loadB).get( 0 );
Assert.assertTrue( filterB instanceof LOFilter );
Operator cogrpA = newLogicalPlan.getSuccessors( filterA ).get( 0 );
Assert.assertTrue( cogrpA instanceof LOCogroup );
Operator cogrpB = newLogicalPlan.getSuccessors( filterB ).get( 0 );
Assert.assertTrue( cogrpB instanceof LOCogroup );
Assert.assertTrue( cogrpB == cogrpA );
Operator store = newLogicalPlan.getSuccessors(cogrpA).get( 0 );
Assert.assertTrue( store instanceof LOStore );
}
示例2: testForeachFRJoin1
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
public void testForeachFRJoin1() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa:(letter_grade, point_score));" +
"B = load 'anotherfile' as (name, age, preference:(course_name, instructor));" +
"C = foreach B generate $0, $1, flatten($2);" +
"D = join A by $0, C by $0 using 'replicated';" +
"E = limit D 10;" +
"store E into 'output';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator op = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "B" ) )
op = loads.get( 0 );
else
op = loads.get( 1 );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( !OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOJoin );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOLimit );
}
示例3: testForeachCross1
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
public void testForeachCross1() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa:(letter_grade, point_score));" +
"B = load 'anotherfile' as (name, age, preference:(course_name, instructor));" +
"C = foreach B generate $0, $1, flatten($2);" +
"D = cross A, C;" +
"E = limit D 10;" +
"store E into 'output';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator op = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "B" ) )
op = loads.get( 0 );
else
op = loads.get( 1 );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( !OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOCross );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOLimit );
}
示例4: testForeachUDFCross
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
/**
* This is a valid, positive test case. Optimization should go thru.
*/
@Test
public void testForeachUDFCross() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa:(letter_grade, point_score));" +
"B = foreach A generate $0, flatten($1), " + Identity.class.getName() + "($2) ;" +
"C = load 'anotherfile' as (name, age, preference:(course_name, instructor));" +
"D = cross B, C;" +
"E = limit D 10;" +
"store E into 'output';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator op = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) )
op = loads.get( 0 );
else
op = loads.get( 1 );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( !OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOCross );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOLimit );
}
示例5: testForeachFlattenAddedColumnCross
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
/**
* This actually is a valid case, even though the optimization may not provide any performance benefit. However, detecting
* such a case requires more coding. Thus, we allow optimization to go thru in this case.
*/
@Test
public void testForeachFlattenAddedColumnCross() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa:(letter_grade, point_score));" +
"B = foreach A generate $0, $1, flatten(1);" +
"C = load 'anotherfile' as (name, age, preference:(course_name, instructor));" +
"D = cross B, C;" +
"E = limit D 10;" +
"store E into 'output';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator op = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) )
op = loads.get( 0 );
else
op = loads.get( 1 );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( !OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOCross );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOLimit );
}
示例6: testFilterConstantConditionCogroup
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
public void testFilterConstantConditionCogroup() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa);" +
"B = load 'anotherfile' as (name, age, preference);" +
"C = cogroup A by $0, B by $0;" +
"D = filter C by 1 == 1;" +
"E = STORE D into 'dummy';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator loadA = null;
Operator loadB = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) ) {
loadA = loads.get( 0 );
loadB = loads.get( 1 );
} else {
loadA = loads.get( 1 );
loadB = loads.get( 0 );
}
Operator filterA = newLogicalPlan.getSuccessors(loadA).get( 0 );
Assert.assertTrue( filterA instanceof LOFilter );
Operator filterB = newLogicalPlan.getSuccessors(loadB).get( 0 );
Assert.assertTrue( filterB instanceof LOFilter );
Operator cogrpA = newLogicalPlan.getSuccessors( filterA ).get( 0 );
Assert.assertTrue( cogrpA instanceof LOCogroup );
Operator cogrpB = newLogicalPlan.getSuccessors( filterB ).get( 0 );
Assert.assertTrue( cogrpB instanceof LOCogroup );
Assert.assertTrue( cogrpB == cogrpA );
Operator store = newLogicalPlan.getSuccessors(cogrpA).get( 0 );
Assert.assertTrue( store instanceof LOStore );
}
示例7: testForeachFRJoin
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
public void testForeachFRJoin() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa:(letter_grade, point_score));" +
"B = foreach A generate $0, $1, flatten($2);" +
"C = load 'anotherfile' as (name, age, preference);" +
"D = join B by $0, C by $0 using 'replicated';" +
"E = limit D 10;" +
"store E into 'output';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator op = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) )
op = loads.get( 0 );
else
op = loads.get( 1 );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( !OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOJoin );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOLimit );
}
示例8: testFilterUDFCogroup
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
public void testFilterUDFCogroup() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa);" +
"B = load 'anotherfile' as (name, age, preference);" +
"C = cogroup A by $0, B by $0;" +
"D = filter C by " + MyFilterFunc.class.getName() + "($1) ;" +
"E = STORE D into 'dummy';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator loadA = null;
Operator loadB = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) ) {
loadA = loads.get( 0 );
loadB = loads.get( 1 );
} else {
loadA = loads.get( 1 );
loadB = loads.get( 0 );
}
Operator cogroupA = newLogicalPlan.getSuccessors(loadA).get( 0 );
Assert.assertTrue( cogroupA instanceof LOCogroup );
Operator cogroupB = newLogicalPlan.getSuccessors(loadB).get( 0 );
Assert.assertTrue( cogroupB instanceof LOCogroup );
Operator filter = newLogicalPlan.getSuccessors( cogroupA ).get( 0 );
Assert.assertTrue( filter instanceof LOFilter );
filter = newLogicalPlan.getSuccessors( cogroupB ).get( 0 );
Assert.assertTrue( cogroupB instanceof LOCogroup );
Assert.assertTrue( cogroupB == cogroupA );
Operator store = newLogicalPlan.getSuccessors(filter).get( 0 );
Assert.assertTrue( store instanceof LOStore );
}
示例9: testFilterUDFCogroupOuter
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
public void testFilterUDFCogroupOuter() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa);" +
"B = load 'anotherfile' as (name, age, preference);" +
"C = cogroup A by $0, B by $0 outer;" +
"D = filter C by " + MyFilterFunc.class.getName() + "() ;" +
"E = STORE D into 'dummy';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator loadA = null;
Operator loadB = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) ) {
loadA = loads.get( 0 );
loadB = loads.get( 1 );
} else {
loadA = loads.get( 1 );
loadB = loads.get( 0 );
}
Operator cogroupA = newLogicalPlan.getSuccessors(loadA).get( 0 );
Assert.assertTrue( cogroupA instanceof LOCogroup );
Operator cogroupB = newLogicalPlan.getSuccessors(loadB).get( 0 );
Assert.assertTrue( cogroupB instanceof LOCogroup );
Operator filter = newLogicalPlan.getSuccessors( cogroupA ).get( 0 );
Assert.assertTrue( filter instanceof LOFilter );
filter = newLogicalPlan.getSuccessors( cogroupB ).get( 0 );
Assert.assertTrue( filter instanceof LOFilter );
Assert.assertTrue( cogroupB == cogroupA );
Operator store = newLogicalPlan.getSuccessors(filter).get( 0 );
Assert.assertTrue( store instanceof LOStore );
}
示例10: testFilterCogroup
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
public void testFilterCogroup() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa);" +
"B = load 'anotherfile' as (name, age, preference);" +
"C = cogroup A by $0, B by $0;" +
"D = filter C by $0 < 'name';" +
"E = STORE D into 'dummy';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator loadA = null;
Operator loadB = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) ) {
loadA = loads.get( 0 );
loadB = loads.get( 1 );
} else {
loadA = loads.get( 1 );
loadB = loads.get( 0 );
}
Operator filterA = newLogicalPlan.getSuccessors(loadA).get( 0 );
Assert.assertTrue( filterA instanceof LOFilter );
Operator filterB = newLogicalPlan.getSuccessors(loadB).get( 0 );
Assert.assertTrue( filterB instanceof LOFilter );
Operator cogrpA = newLogicalPlan.getSuccessors( filterA ).get( 0 );
Assert.assertTrue( cogrpA instanceof LOCogroup );
Operator cogrpB = newLogicalPlan.getSuccessors( filterB ).get( 0 );
Assert.assertTrue( cogrpB instanceof LOCogroup );
Assert.assertTrue( cogrpB == cogrpA );
Operator store = newLogicalPlan.getSuccessors(cogrpA).get( 0 );
Assert.assertTrue( store instanceof LOStore );
}
示例11: testFilterCogroupOuter
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
public void testFilterCogroupOuter() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa);" +
"B = load 'anotherfile' as (name, age, preference);" +
"C = cogroup A by $0, B by $0 outer;" +
"D = filter C by $0 < 'name';" +
"E = STORE D into 'dummy';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator loadA = null;
Operator loadB = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) ) {
loadA = loads.get( 0 );
loadB = loads.get( 1 );
} else {
loadA = loads.get( 1 );
loadB = loads.get( 0 );
}
Operator filterA = newLogicalPlan.getSuccessors(loadA).get( 0 );
Assert.assertTrue( filterA instanceof LOFilter );
Operator filterB = newLogicalPlan.getSuccessors(loadB).get( 0 );
Assert.assertTrue( filterB instanceof LOFilter );
Operator cogrpA = newLogicalPlan.getSuccessors( filterA ).get( 0 );
Assert.assertTrue( cogrpA instanceof LOCogroup );
Operator cogrpB = newLogicalPlan.getSuccessors( filterB ).get( 0 );
Assert.assertTrue( cogrpB instanceof LOCogroup );
Assert.assertTrue( cogrpB == cogrpA );
Operator store = newLogicalPlan.getSuccessors(cogrpA).get( 0 );
Assert.assertTrue( store instanceof LOStore );
}
示例12: testFilterConstantConditionFRJoin
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
// Constant filter condition, the filter will be pushed up to the first branch of join.
public void testFilterConstantConditionFRJoin() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa);" +
"B = load 'anotherfile' as (name, age, preference);" +
"C = join A by $0, B by $0 using 'replicated';" +
"D = filter C by 1 == 1;" +
"E = STORE D into 'dummy';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator op = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) )
op = loads.get( 0 );
else
op = loads.get( 1 );
op = newLogicalPlan.getSuccessors(op).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
op = newLogicalPlan.getSuccessors(op).get( 0 );
Assert.assertTrue( op instanceof LOFilter );
op = newLogicalPlan.getSuccessors(op).get( 0 );
Assert.assertTrue( op instanceof LOJoin );
op = newLogicalPlan.getSuccessors(op).get( 0 );
Assert.assertTrue( op instanceof LOStore );
}
示例13: testFilterFRJoin1
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
@Test
public void testFilterFRJoin1() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa);" +
"B = load 'anotherfile' as (name, age, preference);" +
"C = join A by $0, B by $0 using 'replicated';" +
"D = filter C by $4 < 'name';" +
"E = limit D 10;" +
"F = STORE E into 'dummy';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator op = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "B" ) )
op = loads.get( 0 );
else
op = loads.get( 1 );
op = newLogicalPlan.getSuccessors(op).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
op = newLogicalPlan.getSuccessors(op).get( 0 );
Assert.assertTrue( op instanceof LOFilter );
op = newLogicalPlan.getSuccessors(op).get( 0 );
Assert.assertTrue( op instanceof LOJoin );
op = newLogicalPlan.getSuccessors(op).get( 0 );
Assert.assertTrue( op instanceof LOLimit );
}
示例14: testForeachCastInnerJoin
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
/**
* Cast doesn't prevent optimization.
*/
@Test
public void testForeachCastInnerJoin() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa:(letter_grade, point_score));" +
"B = foreach A generate $0, (int)$1, flatten($2);" +
"C = load 'anotherfile' as (name, age, preference:(course_name, instructor));" +
"D = join B by $0, C by $0;" +
"E = limit D 10;" +
"store E into 'output';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator op = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) )
op = loads.get( 0 );
else
op = loads.get( 1 );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( !OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOJoin );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOLimit );
}
示例15: testForeachFlattenAddedColumnFRJoin
import org.apache.pig.newplan.logical.relational.LogicalPlan; //导入方法依赖的package包/类
/**
* Valid positive test case, even though the benefit from the optimization is questionable. However, putting in additinal check for
* this condition requires extra coding.
*/
@Test
public void testForeachFlattenAddedColumnFRJoin() throws Exception {
String query = "A = load 'myfile' as (name, age, gpa:(letter_grade, point_score));" +
"B = foreach A generate $0, $1, flatten(1);" +
"C = load 'anotherfile' as (name, age, preference:(course_name, instructor));" +
"D = join B by $0, C by $0 using 'replicated';" +
"E = limit D 10;" +
"store E into 'output';";
LogicalPlan newLogicalPlan = migrateAndOptimizePlan( query );
List<Operator> loads = newLogicalPlan.getSources();
Assert.assertTrue( loads.size() == 2 );
Assert.assertTrue( loads.get( 0 ) instanceof LOLoad );
Assert.assertTrue( loads.get( 1 ) instanceof LOLoad );
Operator op = null;
if( ((LOLoad)loads.get( 0 )).getAlias().equals( "A" ) )
op = loads.get( 0 );
else
op = loads.get( 1 );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( !OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOJoin );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOForEach );
Assert.assertTrue( OptimizerUtils.hasFlatten( (LOForEach)op ) );
op = newLogicalPlan.getSuccessors( op ).get( 0 );
Assert.assertTrue( op instanceof LOLimit );
}