本文整理汇总了Java中org.apache.pig.newplan.logical.expression.LessThanExpression类的典型用法代码示例。如果您正苦于以下问题:Java LessThanExpression类的具体用法?Java LessThanExpression怎么用?Java LessThanExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LessThanExpression类属于org.apache.pig.newplan.logical.expression包,在下文中一共展示了LessThanExpression类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildSampleOp
import org.apache.pig.newplan.logical.expression.LessThanExpression; //导入依赖的package包/类
String buildSampleOp(SourceLocation loc, String alias, String inputAlias, double value,
SourceLocation valLoc)
throws ParserValidationException {
LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
// Generate a filter condition.
LogicalExpression konst = new ConstantExpression( filterPlan, value);
konst.setLocation( valLoc );
UserFuncExpression udf = new UserFuncExpression( filterPlan, new FuncSpec( RANDOM.class.getName() ) );
new LessThanExpression( filterPlan, udf, konst );
LOFilter filter = new LOFilter( plan, true );
return buildFilterOp( loc, filter, alias, inputAlias, filterPlan );
}
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:14,代码来源:LogicalPlanBuilder.java
示例2: isSupportedOpType
import org.apache.pig.newplan.logical.expression.LessThanExpression; //导入依赖的package包/类
@Override
protected boolean isSupportedOpType(BinaryExpression binOp) {
if(binOp instanceof AddExpression) {
return supportedOpTypes.contains(OpType.OP_PLUS );
} else if(binOp instanceof SubtractExpression) {
return supportedOpTypes.contains(OpType.OP_MINUS);
} else if(binOp instanceof MultiplyExpression) {
return supportedOpTypes.contains(OpType.OP_TIMES);
} else if(binOp instanceof DivideExpression) {
return supportedOpTypes.contains(OpType.OP_DIV);
} else if(binOp instanceof ModExpression) {
return supportedOpTypes.contains(OpType.OP_MOD);
} else if(binOp instanceof AndExpression) {
return supportedOpTypes.contains(OpType.OP_AND);
} else if(binOp instanceof OrExpression) {
return supportedOpTypes.contains(OpType.OP_OR);
} else if(binOp instanceof EqualExpression) {
return supportedOpTypes.contains(OpType.OP_EQ);
} else if(binOp instanceof NotEqualExpression) {
return supportedOpTypes.contains(OpType.OP_NE);
} else if(binOp instanceof GreaterThanExpression) {
return supportedOpTypes.contains(OpType.OP_GT);
} else if(binOp instanceof GreaterThanEqualExpression) {
return supportedOpTypes.contains(OpType.OP_GE);
} else if(binOp instanceof LessThanExpression) {
return supportedOpTypes.contains(OpType.OP_LT);
} else if(binOp instanceof LessThanEqualExpression) {
return supportedOpTypes.contains(OpType.OP_LE);
} else if(binOp instanceof RegexExpression) {
return supportedOpTypes.contains(OpType.OP_MATCH);
} else {
return false;
}
}
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:35,代码来源:PredicatePushDownFilterExtractor.java
示例3: buildSampleOp
import org.apache.pig.newplan.logical.expression.LessThanExpression; //导入依赖的package包/类
String buildSampleOp(SourceLocation loc, String alias, String inputAlias, double value,
SourceLocation valLoc)
throws ParserValidationException {
LogicalExpressionPlan filterPlan = new LogicalExpressionPlan();
// Generate a filter condition.
LogicalExpression konst = new ConstantExpression( filterPlan, value);
konst.setLocation( valLoc );
UserFuncExpression udf = new UserFuncExpression( filterPlan, new FuncSpec( RANDOM.class.getName() ) );
new LessThanExpression( filterPlan, udf, konst );
LOFilter filter = new LOFilter( plan, true );
return buildFilterOp( loc, filter, alias, inputAlias, filterPlan );
}
开发者ID:PonIC,项目名称:PonIC,代码行数:14,代码来源:LogicalPlanBuilder.java
示例4: getExpression
import org.apache.pig.newplan.logical.expression.LessThanExpression; //导入依赖的package包/类
public Expression getExpression(LogicalExpression op) throws FrontendException
{
if(op instanceof ConstantExpression) {
ConstantExpression constExpr =(ConstantExpression)op ;
return new Expression.Const( constExpr.getValue() );
} else if (op instanceof ProjectExpression) {
ProjectExpression projExpr = (ProjectExpression)op;
String fieldName = projExpr.getFieldSchema().alias;
return new Expression.Column(fieldName);
} else {
if( !( op instanceof BinaryExpression ) ) {
logInternalErrorAndSetFlag();
return null;
}
BinaryExpression binOp = (BinaryExpression)op;
if(binOp instanceof AddExpression) {
return getExpression( binOp, OpType.OP_PLUS );
} else if(binOp instanceof SubtractExpression) {
return getExpression(binOp, OpType.OP_MINUS);
} else if(binOp instanceof MultiplyExpression) {
return getExpression(binOp, OpType.OP_TIMES);
} else if(binOp instanceof DivideExpression) {
return getExpression(binOp, OpType.OP_DIV);
} else if(binOp instanceof ModExpression) {
return getExpression(binOp, OpType.OP_MOD);
} else if(binOp instanceof AndExpression) {
return getExpression(binOp, OpType.OP_AND);
} else if(binOp instanceof OrExpression) {
return getExpression(binOp, OpType.OP_OR);
} else if(binOp instanceof EqualExpression) {
return getExpression(binOp, OpType.OP_EQ);
} else if(binOp instanceof NotEqualExpression) {
return getExpression(binOp, OpType.OP_NE);
} else if(binOp instanceof GreaterThanExpression) {
return getExpression(binOp, OpType.OP_GT);
} else if(binOp instanceof GreaterThanEqualExpression) {
return getExpression(binOp, OpType.OP_GE);
} else if(binOp instanceof LessThanExpression) {
return getExpression(binOp, OpType.OP_LT);
} else if(binOp instanceof LessThanEqualExpression) {
return getExpression(binOp, OpType.OP_LE);
} else if(binOp instanceof RegexExpression) {
return getExpression(binOp, OpType.OP_MATCH);
} else {
logInternalErrorAndSetFlag();
}
}
return null;
}
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:50,代码来源:PColFilterExtractor.java
示例5: visit
import org.apache.pig.newplan.logical.expression.LessThanExpression; //导入依赖的package包/类
@Override
public void visit(LessThanExpression binOp)
throws FrontendException {
addCastsToCompareBinaryExp(binOp, false /*not equality op*/);
}
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:6,代码来源:TypeCheckingExpVisitor.java
示例6: visit
import org.apache.pig.newplan.logical.expression.LessThanExpression; //导入依赖的package包/类
@Override
public void visit(LessThanExpression op) throws FrontendException {
appendEdges( op );
}
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:5,代码来源:OptimizeLimitPlanPrinter.java
示例7: testExpressionTypeChecking11
import org.apache.pig.newplan.logical.expression.LessThanExpression; //导入依赖的package包/类
@Test
public void testExpressionTypeChecking11() throws Throwable {
// test whether conditional operators can accept two datetime operands
LogicalExpressionPlan plan = new LogicalExpressionPlan();
ConstantExpression constant0 = new ConstantExpression(plan, new DateTime(0L));
ConstantExpression constant1 = new ConstantExpression(plan, new DateTime("1970-01-01T00:00:00.000Z"));
ConstantExpression constant2 = new ConstantExpression(plan, new DateTime(1L));
ConstantExpression constant3 = new ConstantExpression(plan, new DateTime(2L));
ConstantExpression constant4 = new ConstantExpression(plan, new DataByteArray("1970-01-01T00:00:00.003Z"));
LessThanExpression lt1 = new LessThanExpression(plan, constant1, constant2);
LessThanEqualExpression lte1 = new LessThanEqualExpression(plan, constant1, constant2);
GreaterThanExpression gt1 = new GreaterThanExpression(plan, constant3, constant4);
GreaterThanEqualExpression gte1 = new GreaterThanEqualExpression(plan, constant3, constant4);
EqualExpression eq1 = new EqualExpression(plan, constant0, constant1);
NotEqualExpression neq1 = new NotEqualExpression(plan, constant0, constant2);
CompilationMessageCollector collector = new CompilationMessageCollector();
TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(
plan, collector, null);
expTypeChecker.visit();
plan.explain(System.out, "text", true);
printMessageCollector(collector);
// printTypeGraph(plan);
if (collector.hasError()) {
throw new Exception("Error during type checking");
}
// Induction check
assertEquals(DataType.BOOLEAN, lt1.getType());
assertEquals(DataType.BOOLEAN, lte1.getType());
assertEquals(DataType.BOOLEAN, gt1.getType());
assertEquals(DataType.BOOLEAN, gte1.getType());
assertEquals(DataType.BOOLEAN, eq1.getType());
assertEquals(DataType.BOOLEAN, neq1.getType());
// Cast insertion check
assertEquals(DataType.DATETIME, gt1.getRhs().getType());
assertEquals(DataType.DATETIME, gte1.getRhs().getType());
}
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:44,代码来源:TestTypeCheckingValidatorNewLP.java
示例8: 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
示例9: getExpression
import org.apache.pig.newplan.logical.expression.LessThanExpression; //导入依赖的package包/类
public Expression getExpression(LogicalExpression op) throws FrontendException
{
if(op == null) {
return null;
}
if(op instanceof ConstantExpression) {
ConstantExpression constExpr =(ConstantExpression)op ;
return new Expression.Const( constExpr.getValue() );
} else if (op instanceof ProjectExpression) {
ProjectExpression projExpr = (ProjectExpression)op;
String fieldName = projExpr.getFieldSchema().alias;
return new Expression.Column(fieldName);
} else if(op instanceof BinaryExpression) {
BinaryExpression binOp = (BinaryExpression)op;
if(binOp instanceof AddExpression) {
return getExpression( binOp, OpType.OP_PLUS );
} else if(binOp instanceof SubtractExpression) {
return getExpression(binOp, OpType.OP_MINUS);
} else if(binOp instanceof MultiplyExpression) {
return getExpression(binOp, OpType.OP_TIMES);
} else if(binOp instanceof DivideExpression) {
return getExpression(binOp, OpType.OP_DIV);
} else if(binOp instanceof ModExpression) {
return getExpression(binOp, OpType.OP_MOD);
} else if(binOp instanceof AndExpression) {
return getExpression(binOp, OpType.OP_AND);
} else if(binOp instanceof OrExpression) {
return getExpression(binOp, OpType.OP_OR);
} else if(binOp instanceof EqualExpression) {
return getExpression(binOp, OpType.OP_EQ);
} else if(binOp instanceof NotEqualExpression) {
return getExpression(binOp, OpType.OP_NE);
} else if(binOp instanceof GreaterThanExpression) {
return getExpression(binOp, OpType.OP_GT);
} else if(binOp instanceof GreaterThanEqualExpression) {
return getExpression(binOp, OpType.OP_GE);
} else if(binOp instanceof LessThanExpression) {
return getExpression(binOp, OpType.OP_LT);
} else if(binOp instanceof LessThanEqualExpression) {
return getExpression(binOp, OpType.OP_LE);
} else if(binOp instanceof RegexExpression) {
return getExpression(binOp, OpType.OP_MATCH);
} else {
LOG.error("Unsupported conversion of BinaryExpression to Expression: " + op.getName());
throw new FrontendException("Unsupported conversion of BinaryExpression to Expression: " + op.getName());
}
} else if(op instanceof UnaryExpression) {
UnaryExpression unaryOp = (UnaryExpression)op;
if(unaryOp instanceof IsNullExpression) {
return getExpression(unaryOp, OpType.OP_NULL);
} else if(unaryOp instanceof NotExpression) {
return getExpression(unaryOp, OpType.OP_NOT);
} else if(unaryOp instanceof CastExpression) {
return getExpression(unaryOp.getExpression());
} else {
LOG.error("Unsupported conversion of UnaryExpression to Expression: " + op.getName());
throw new FrontendException("Unsupported conversion of UnaryExpression to Expression: " + op.getName());
}
} else {
LOG.error("Unsupported conversion of LogicalExpression to Expression: " + op.getName());
throw new FrontendException("Unsupported conversion of LogicalExpression to Expression: " + op.getName());
}
}
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:64,代码来源:FilterExtractor.java
示例10: getExpression
import org.apache.pig.newplan.logical.expression.LessThanExpression; //导入依赖的package包/类
public Expression getExpression(LogicalExpression op) throws FrontendException
{
if(op instanceof ConstantExpression) {
ConstantExpression constExpr =(ConstantExpression)op ;
return new Expression.Const( constExpr.getValue() );
} else if (op instanceof ProjectExpression) {
ProjectExpression projExpr = (ProjectExpression)op;
String fieldName = projExpr.getFieldSchema().alias;
return new Expression.Column(fieldName);
} else {
if( !( op instanceof BinaryExpression ) ) {
logInternalErrorAndSetFlag();
return null;
}
BinaryExpression binOp = (BinaryExpression)op;
if(binOp instanceof AddExpression) {
return getExpression( binOp, OpType.OP_PLUS );
} else if(binOp instanceof SubtractExpression) {
return getExpression(binOp, OpType.OP_MINUS);
} else if(binOp instanceof MultiplyExpression) {
return getExpression(binOp, OpType.OP_TIMES);
} else if(binOp instanceof DivideExpression) {
return getExpression(binOp, OpType.OP_DIV);
} else if(binOp instanceof ModExpression) {
return getExpression(binOp, OpType.OP_MOD);
} else if(binOp instanceof AndExpression) {
return getExpression(binOp, OpType.OP_AND);
} else if(binOp instanceof OrExpression) {
return getExpression(binOp, OpType.OP_OR);
} else if(binOp instanceof EqualExpression) {
return getExpression(binOp, OpType.OP_EQ);
} else if(binOp instanceof NotEqualExpression) {
return getExpression(binOp, OpType.OP_NE);
} else if(binOp instanceof GreaterThanExpression) {
return getExpression(binOp, OpType.OP_GT);
} else if(binOp instanceof GreaterThanEqualExpression) {
return getExpression(binOp, OpType.OP_GE);
} else if(binOp instanceof LessThanExpression) {
return getExpression(binOp, OpType.OP_LT);
} else if(binOp instanceof LessThanEqualExpression) {
return getExpression(binOp, OpType.OP_LE);
} else {
logInternalErrorAndSetFlag();
}
}
return null;
}
开发者ID:PonIC,项目名称:PonIC,代码行数:48,代码来源:PColFilterExtractor.java
示例11: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论