本文整理汇总了Java中org.apache.pig.Expression.OpType类的典型用法代码示例。如果您正苦于以下问题:Java OpType类的具体用法?Java OpType怎么用?Java OpType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OpType类属于org.apache.pig.Expression包,在下文中一共展示了OpType类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: partitionFilterToWhereClauseString
import org.apache.pig.Expression.OpType; //导入依赖的package包/类
/**
* Return cql where clauses for the corresponding partition filter. Make sure the data format matches
* Only support the following Pig data types: int, long, float, double, boolean and chararray
* */
private String partitionFilterToWhereClauseString(Expression expression) throws IOException
{
Expression.BinaryExpression be = (Expression.BinaryExpression) expression;
OpType op = expression.getOpType();
String opString = op.toString();
switch (op)
{
case OP_EQ:
opString = " = ";
case OP_GE:
case OP_GT:
case OP_LE:
case OP_LT:
String name = be.getLhs().toString();
String value = be.getRhs().toString();
return String.format("%s %s %s", name, opString, value);
case OP_AND:
return String.format("%s AND %s", partitionFilterToWhereClauseString(be.getLhs()), partitionFilterToWhereClauseString(be.getRhs()));
default:
throw new IOException("Unsupported expression type: " + opString);
}
}
示例2: partitionFilterToWhereClauseString
import org.apache.pig.Expression.OpType; //导入依赖的package包/类
/**
* Return cql where clauses for the corresponding partition filter. Make sure the data format matches
* Only support the following Pig data types: int, long, float, double, boolean and chararray
* */
private String partitionFilterToWhereClauseString(Expression expression) throws IOException
{
Expression.BinaryExpression be = (Expression.BinaryExpression) expression;
OpType op = expression.getOpType();
String opString = op.toString();
switch (op)
{
case OP_EQ:
opString = " = ";
case OP_GE:
case OP_GT:
case OP_LE:
case OP_LT:
String name = be.getLhs().toString();
String value = be.getRhs().toString();
return String.format("%s %s %s", name, opString, value);
case OP_AND:
return String.format("%s AND %s", partitionFilterToWhereClauseString(be.getLhs()), partitionFilterToWhereClauseString(be.getRhs()));
default:
throw new IOException("Unsupported expression type: " + opString);
}
}
示例3: partitionFilterToWhereClauseString
import org.apache.pig.Expression.OpType; //导入依赖的package包/类
/**
* Return cql where clauses for the corresponding partition filter. Make sure the data format matches
* Only support the following Pig data types: int, long, float, double, boolean and chararray
* */
private String partitionFilterToWhereClauseString(Expression expression)
{
Expression.BinaryExpression be = (Expression.BinaryExpression) expression;
String name = be.getLhs().toString();
String value = be.getRhs().toString();
OpType op = expression.getOpType();
String opString = op.name();
switch (op)
{
case OP_EQ:
opString = " = ";
case OP_GE:
case OP_GT:
case OP_LE:
case OP_LT:
return String.format("%s %s %s", name, opString, value);
case OP_AND:
return String.format("%s AND %s", partitionFilterToWhereClauseString(be.getLhs()), partitionFilterToWhereClauseString(be.getRhs()));
default:
throw new RuntimeException("Unsupported expression type: " + opString);
}
}
示例4: partitionFilterToWhereClauseString
import org.apache.pig.Expression.OpType; //导入依赖的package包/类
/**
* Return cql where clauses for the corresponding partition filter. Make sure the data format matches
* Only support the following Pig data types: int, long, float, double, boolean and chararray
* */
private String partitionFilterToWhereClauseString(Expression expression) throws IOException
{
Expression.BinaryExpression be = (Expression.BinaryExpression) expression;
String name = be.getLhs().toString();
String value = be.getRhs().toString();
OpType op = expression.getOpType();
String opString = op.toString();
switch (op)
{
case OP_EQ:
opString = " = ";
case OP_GE:
case OP_GT:
case OP_LE:
case OP_LT:
return String.format("%s %s %s", name, opString, value);
case OP_AND:
return String.format("%s AND %s", partitionFilterToWhereClauseString(be.getLhs()), partitionFilterToWhereClauseString(be.getRhs()));
default:
throw new IOException("Unsupported expression type: " + opString);
}
}
示例5: getSupportedExpressionTypes
import org.apache.pig.Expression.OpType; //导入依赖的package包/类
@Override
public List<OpType> getSupportedExpressionTypes() {
List<OpType> types = new ArrayList<OpType>();
types.add(OpType.OP_EQ);
types.add(OpType.OP_NE);
types.add(OpType.OP_GT);
types.add(OpType.OP_GE);
types.add(OpType.OP_LT);
types.add(OpType.OP_LE);
types.add(OpType.OP_IN);
types.add(OpType.OP_BETWEEN);
types.add(OpType.OP_NULL);
types.add(OpType.OP_NOT);
types.add(OpType.OP_AND);
types.add(OpType.OP_OR);
return types;
}
示例6: getSearchArgument
import org.apache.pig.Expression.OpType; //导入依赖的package包/类
@VisibleForTesting
SearchArgument getSearchArgument(Expression expr) {
if (expr == null) {
return null;
}
Builder builder = SearchArgumentFactory.newBuilder();
boolean beginWithAnd = !(expr.getOpType().equals(OpType.OP_AND) || expr.getOpType().equals(OpType.OP_OR) || expr.getOpType().equals(OpType.OP_NOT));
if (beginWithAnd) {
builder.startAnd();
}
buildSearchArgument(expr, builder);
if (beginWithAnd) {
builder.end();
}
SearchArgument sArg = builder.build();
return sArg;
}
示例7: getPColCondition
import org.apache.pig.Expression.OpType; //导入依赖的package包/类
/**
* @return the condition on partition columns extracted from filter
*/
public Expression getPColCondition(){
if(!canPushDown || pColConditions.size() == 0)
return null;
Expression cond = pColConditions.get(0);
for(int i=1; i<pColConditions.size(); i++){
//if there is more than one condition expression
// connect them using "AND"s
cond = new Expression.BinaryExpression(cond, pColConditions.get(i),
OpType.OP_AND);
}
return cond;
}
示例8: visit
import org.apache.pig.Expression.OpType; //导入依赖的package包/类
@Override
public void visit() throws FrontendException {
super.visit();
if (supportedOpTypes.contains(OpType.OP_BETWEEN)) {
// TODO: Collapse multiple ORs into BETWEEN
} else if (supportedOpTypes.contains(OpType.OP_IN)) {
// TODO: Collapse multiple ORs into IN
}
}
示例9: isSupportedOpType
import org.apache.pig.Expression.OpType; //导入依赖的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;
}
}
示例10: oneTimeSetup
import org.apache.pig.Expression.OpType; //导入依赖的package包/类
@BeforeClass
public static void oneTimeSetup() throws Exception{
cluster = MiniGenericCluster.buildCluster();
Util.copyFromLocalToCluster(cluster, basedir + "orc-file-11-format.orc", basedir + "orc-file-11-format.orc");
Util.copyFromLocalToCluster(cluster, basedir + "charvarchar.orc", basedir + "charvarchar.orc");
createInputData();
if(Util.WINDOWS){
OUTPUT1 = OUTPUT1.replace("\\", "/");
OUTPUT2 = OUTPUT2.replace("\\", "/");
OUTPUT3 = OUTPUT3.replace("\\", "/");
OUTPUT4 = OUTPUT4.replace("\\", "/");
}
supportedOpTypes = new ArrayList<OpType>();
supportedOpTypes.add(OpType.OP_EQ);
supportedOpTypes.add(OpType.OP_NE);
supportedOpTypes.add(OpType.OP_GT);
supportedOpTypes.add(OpType.OP_GE);
supportedOpTypes.add(OpType.OP_LT);
supportedOpTypes.add(OpType.OP_LE);
supportedOpTypes.add(OpType.OP_IN);
supportedOpTypes.add(OpType.OP_BETWEEN);
supportedOpTypes.add(OpType.OP_NULL);
supportedOpTypes.add(OpType.OP_NOT);
supportedOpTypes.add(OpType.OP_AND);
supportedOpTypes.add(OpType.OP_OR);
Logger logger = Logger.getLogger(ColumnPruneVisitor.class);
logger.removeAllAppenders();
logger.setLevel(Level.INFO);
SimpleLayout layout = new SimpleLayout();
logFile = File.createTempFile("log", "");
FileAppender appender = new FileAppender(layout, logFile.toString(), false, false, 0);
logger.addAppender(appender);
}
示例11: getExpression
import org.apache.pig.Expression.OpType; //导入依赖的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;
}
示例12: getExpression
import org.apache.pig.Expression.OpType; //导入依赖的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());
}
}
示例13: PredicatePushDownFilterExtractor
import org.apache.pig.Expression.OpType; //导入依赖的package包/类
public PredicatePushDownFilterExtractor(LogicalExpressionPlan plan, List<String> predicateCols,
List<OpType> supportedOpTypes) {
super(plan);
this.predicateCols = predicateCols;
this.supportedOpTypes = supportedOpTypes;
}
示例14: getExpression
import org.apache.pig.Expression.OpType; //导入依赖的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;
}