当前位置: 首页>>代码示例>>Java>>正文


Java LessThanExpression.getLhs方法代码示例

本文整理汇总了Java中org.apache.pig.newplan.logical.expression.LessThanExpression.getLhs方法的典型用法代码示例。如果您正苦于以下问题:Java LessThanExpression.getLhs方法的具体用法?Java LessThanExpression.getLhs怎么用?Java LessThanExpression.getLhs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.pig.newplan.logical.expression.LessThanExpression的用法示例。


在下文中一共展示了LessThanExpression.getLhs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPlanwithBinCond

import org.apache.pig.newplan.logical.expression.LessThanExpression; //导入方法依赖的package包/类
@Test    
public void testPlanwithBinCond() throws Exception {
    String query = ("a = load 'd.txt' as (a:int, b:int);" +
    "b = foreach a generate ( a < b ? b : a );" +        
    "store b into 'empty';");  
    
    LogicalPlan newLogicalPlan = buildPlan(query);
    LogicalRelationalOperator ld =  (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
    assertEquals( LOLoad.class, ld.getClass() );
    LOLoad load = (LOLoad)ld;
    LogicalSchema ls = load.getSchema();
    
    PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
    
    PhysicalOperator pFE = phyPlan.getSuccessors( phyPlan.getRoots().get(0) ).get(0);
    assertEquals( POForEach.class, pFE.getClass() );
    POForEach pForEach = (POForEach)pFE;
    PhysicalPlan inputPln = pForEach.getInputPlans().get(0);
    
    assertEquals(1, ls.getField(0).uid);
    assertEquals(2, ls.getField(1).uid);
    
    LogicalRelationalOperator fe = 
        (LogicalRelationalOperator) newLogicalPlan.getSuccessors(load).get(0);
    assertEquals( LOForEach.class, fe.getClass() );
    LOForEach forEach = (LOForEach)fe;
    
    LogicalPlan innerPlan = 
        forEach.getInnerPlan();
    
    assertEquals( 1, innerPlan.getSinks().size() );        
    assertEquals( LOGenerate.class, innerPlan.getSinks().get(0).getClass() );
    LOGenerate gen = (LOGenerate)innerPlan.getSinks().get(0);
    assertEquals( 1, gen.getOutputPlans().size() );
    LogicalExpressionPlan genExp = gen.getOutputPlans().get(0);
    
    assertEquals( 1, genExp.getSources().size() );
    
    // Main Tests start here
    assertEquals( BinCondExpression.class, genExp.getSources().get(0).getClass() );
    BinCondExpression add = (BinCondExpression) genExp.getSources().get(0);
    assertEquals( LessThanExpression.class, add.getCondition().getClass() );
    LessThanExpression lessThan = (LessThanExpression) add.getCondition();
    assertEquals( ProjectExpression.class, lessThan.getLhs().getClass() );
    ProjectExpression prj1 = ((ProjectExpression)lessThan.getLhs());
    ProjectExpression prj2 = ((ProjectExpression)lessThan.getRhs());
    assertEquals( ls.getField(0).uid, prj1.getFieldSchema().uid );
    assertEquals( ProjectExpression.class, lessThan.getRhs().getClass() );
    assertEquals( ls.getField(1).uid, prj2.getFieldSchema().uid );
    
    assertEquals( ProjectExpression.class, add.getLhs().getClass() );
    ProjectExpression prj3 = ((ProjectExpression)add.getLhs());
    assertEquals( ls.getField(1).uid, prj3.getFieldSchema().uid );
    assertEquals( ProjectExpression.class, add.getRhs().getClass() );
    ProjectExpression prj4 = ((ProjectExpression)add.getRhs());
    assertEquals( ls.getField(0).uid, prj4.getFieldSchema().uid );
    
    
    assertEquals( 4, inputPln.getRoots().size() ); 
    for( PhysicalOperator p : inputPln.getRoots() ) {
        assertEquals( POProject.class, p.getClass() );
    }
    assertEquals( 1, inputPln.getLeaves().size() );
    assertEquals( POBinCond.class, inputPln.getLeaves().get(0).getClass() );
    POBinCond binCond = (POBinCond) inputPln.getLeaves().get(0);
    assertEquals( POProject.class, binCond.getLhs().getClass() );
    POProject prj_1 = (POProject)binCond.getLhs();
    assertEquals( 1, prj_1.getColumn() );
    assertEquals( POProject.class, binCond.getRhs().getClass() );
    POProject prj_2 = (POProject) binCond.getRhs();
    assertEquals( 0, prj_2.getColumn() );
    assertEquals( LessThanExpr.class, binCond.getCond().getClass() );
    LessThanExpr lessThan_p = (LessThanExpr) binCond.getCond();
    
    assertEquals( POProject.class, lessThan_p.getLhs().getClass() );
    POProject prj_3 = (POProject) lessThan_p.getLhs();
    assertEquals( 0, prj_3.getColumn() );
    assertEquals( POProject.class, lessThan_p.getRhs().getClass() );
    POProject prj_4 = (POProject) lessThan_p.getRhs();
    assertEquals( 1, prj_4.getColumn() );
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:82,代码来源:TestNewPlanLogToPhyTranslationVisitor.java

示例2: testPlanwithBinCond

import org.apache.pig.newplan.logical.expression.LessThanExpression; //导入方法依赖的package包/类
public void testPlanwithBinCond() throws Exception {
    String query = ("a = load 'd.txt' as (a:int, b:int);" +
    "b = foreach a generate ( a < b ? b : a );" +        
    "store b into 'empty';");  
    
    LogicalPlan newLogicalPlan = buildPlan(query);
    LogicalRelationalOperator ld =  (LogicalRelationalOperator)newLogicalPlan.getSources().get(0);
    assertEquals( LOLoad.class, ld.getClass() );
    LOLoad load = (LOLoad)ld;
    LogicalSchema ls = load.getSchema();
    
    PhysicalPlan phyPlan = translatePlan(newLogicalPlan);
    
    PhysicalOperator pFE = phyPlan.getSuccessors( phyPlan.getRoots().get(0) ).get(0);
    assertEquals( POForEach.class, pFE.getClass() );
    POForEach pForEach = (POForEach)pFE;
    PhysicalPlan inputPln = pForEach.getInputPlans().get(0);
    
    assertEquals(1, ls.getField(0).uid);
    assertEquals(2, ls.getField(1).uid);
    
    LogicalRelationalOperator fe = 
        (LogicalRelationalOperator) newLogicalPlan.getSuccessors(load).get(0);
    assertEquals( LOForEach.class, fe.getClass() );
    LOForEach forEach = (LOForEach)fe;
    
    LogicalPlan innerPlan = 
        forEach.getInnerPlan();
    
    assertEquals( 1, innerPlan.getSinks().size() );        
    assertEquals( LOGenerate.class, innerPlan.getSinks().get(0).getClass() );
    LOGenerate gen = (LOGenerate)innerPlan.getSinks().get(0);
    assertEquals( 1, gen.getOutputPlans().size() );
    LogicalExpressionPlan genExp = gen.getOutputPlans().get(0);
    
    assertEquals( 1, genExp.getSources().size() );
    
    // Main Tests start here
    assertEquals( BinCondExpression.class, genExp.getSources().get(0).getClass() );
    BinCondExpression add = (BinCondExpression) genExp.getSources().get(0);
    assertEquals( LessThanExpression.class, add.getCondition().getClass() );
    LessThanExpression lessThan = (LessThanExpression) add.getCondition();
    assertEquals( ProjectExpression.class, lessThan.getLhs().getClass() );
    ProjectExpression prj1 = ((ProjectExpression)lessThan.getLhs());
    ProjectExpression prj2 = ((ProjectExpression)lessThan.getRhs());
    assertEquals( ls.getField(0).uid, prj1.getFieldSchema().uid );
    assertEquals( ProjectExpression.class, lessThan.getRhs().getClass() );
    assertEquals( ls.getField(1).uid, prj2.getFieldSchema().uid );
    
    assertEquals( ProjectExpression.class, add.getLhs().getClass() );
    ProjectExpression prj3 = ((ProjectExpression)add.getLhs());
    assertEquals( ls.getField(1).uid, prj3.getFieldSchema().uid );
    assertEquals( ProjectExpression.class, add.getRhs().getClass() );
    ProjectExpression prj4 = ((ProjectExpression)add.getRhs());
    assertEquals( ls.getField(0).uid, prj4.getFieldSchema().uid );
    
    
    assertEquals( 4, inputPln.getRoots().size() ); 
    for( PhysicalOperator p : inputPln.getRoots() ) {
        assertEquals( POProject.class, p.getClass() );
    }
    assertEquals( 1, inputPln.getLeaves().size() );
    assertEquals( POBinCond.class, inputPln.getLeaves().get(0).getClass() );
    POBinCond binCond = (POBinCond) inputPln.getLeaves().get(0);
    assertEquals( POProject.class, binCond.getLhs().getClass() );
    POProject prj_1 = (POProject)binCond.getLhs();
    assertEquals( 1, prj_1.getColumn() );
    assertEquals( POProject.class, binCond.getRhs().getClass() );
    POProject prj_2 = (POProject) binCond.getRhs();
    assertEquals( 0, prj_2.getColumn() );
    assertEquals( LessThanExpr.class, binCond.getCond().getClass() );
    LessThanExpr lessThan_p = (LessThanExpr) binCond.getCond();
    
    assertEquals( POProject.class, lessThan_p.getLhs().getClass() );
    POProject prj_3 = (POProject) lessThan_p.getLhs();
    assertEquals( 0, prj_3.getColumn() );
    assertEquals( POProject.class, lessThan_p.getRhs().getClass() );
    POProject prj_4 = (POProject) lessThan_p.getRhs();
    assertEquals( 1, prj_4.getColumn() );
}
 
开发者ID:PonIC,项目名称:PonIC,代码行数:81,代码来源:TestNewPlanLogToPhyTranslationVisitor.java


注:本文中的org.apache.pig.newplan.logical.expression.LessThanExpression.getLhs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。