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


Java Expression.getOpType方法代码示例

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


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

示例1: partitionFilterToWhereClauseString

import org.apache.pig.Expression; //导入方法依赖的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);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:CqlNativeStorage.java

示例2: partitionFilterToWhereClauseString

import org.apache.pig.Expression; //导入方法依赖的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);
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:27,代码来源:CqlStorage.java

示例3: getHCatComparisonString

import org.apache.pig.Expression; //导入方法依赖的package包/类
private String getHCatComparisonString(Expression expr) {
  if (expr instanceof BinaryExpression) {
    // call getHCatComparisonString on lhs and rhs, and and join the
    // results with OpType string

    // we can just use OpType.toString() on all Expression types except
    // Equal, NotEqualt since Equal has '==' in toString() and
    // we need '='
    String opStr = null;
    switch (expr.getOpType()) {
    case OP_EQ:
      opStr = " = ";
      break;
    default:
      opStr = expr.getOpType().toString();
    }
    BinaryExpression be = (BinaryExpression) expr;
    return "(" + getHCatComparisonString(be.getLhs()) +
      opStr +
      getHCatComparisonString(be.getRhs()) + ")";
  } else {
    // should be a constant or column
    return expr.toString();
  }
}
 
开发者ID:cloudera,项目名称:RecordServiceClient,代码行数:26,代码来源:HCatRSLoader.java

示例4: partitionFilterToWhereClauseString

import org.apache.pig.Expression; //导入方法依赖的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);
    }
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:27,代码来源:CqlStorage.java

示例5: partitionFilterToWhereClauseString

import org.apache.pig.Expression; //导入方法依赖的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);
    }
}
 
开发者ID:wso2,项目名称:wso2-cassandra,代码行数:27,代码来源:CqlStorage.java

示例6: filterToIndexExpressions

import org.apache.pig.Expression; //导入方法依赖的package包/类
/** get a list of Cassandra IndexExpression from Pig expression */
private List<IndexExpression> filterToIndexExpressions(Expression expression) throws IOException
{
    List<IndexExpression> indexExpressions = new ArrayList<IndexExpression>();
    Expression.BinaryExpression be = (Expression.BinaryExpression)expression;
    ByteBuffer name = ByteBuffer.wrap(be.getLhs().toString().getBytes());
    ByteBuffer value = ByteBuffer.wrap(be.getRhs().toString().getBytes());
    switch (expression.getOpType())
    {
        case OP_EQ:
            indexExpressions.add(new IndexExpression(name, IndexOperator.EQ, value));
            break;
        case OP_GE:
            indexExpressions.add(new IndexExpression(name, IndexOperator.GTE, value));
            break;
        case OP_GT:
            indexExpressions.add(new IndexExpression(name, IndexOperator.GT, value));
            break;
        case OP_LE:
            indexExpressions.add(new IndexExpression(name, IndexOperator.LTE, value));
            break;
        case OP_LT:
            indexExpressions.add(new IndexExpression(name, IndexOperator.LT, value));
            break;
        case OP_AND:
            indexExpressions.addAll(filterToIndexExpressions(be.getLhs()));
            indexExpressions.addAll(filterToIndexExpressions(be.getRhs()));
            break;
        default:
            throw new IOException("Unsupported expression type: " + expression.getOpType().name());
    }
    return indexExpressions;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:34,代码来源:CassandraStorage.java

示例7: filterToIndexExpressions

import org.apache.pig.Expression; //导入方法依赖的package包/类
/** get a list of Cassandra IndexExpression from Pig expression */
private List<IndexExpression> filterToIndexExpressions(Expression expression)
{
    List<IndexExpression> indexExpressions = new ArrayList<IndexExpression>();
    Expression.BinaryExpression be = (Expression.BinaryExpression)expression;
    ByteBuffer name = ByteBuffer.wrap(be.getLhs().toString().getBytes());
    ByteBuffer value = ByteBuffer.wrap(be.getRhs().toString().getBytes());
    switch (expression.getOpType())
    {
        case OP_EQ:
            indexExpressions.add(new IndexExpression(name, IndexOperator.EQ, value));
            break;
        case OP_GE:
            indexExpressions.add(new IndexExpression(name, IndexOperator.GTE, value));
            break;
        case OP_GT:
            indexExpressions.add(new IndexExpression(name, IndexOperator.GT, value));
            break;
        case OP_LE:
            indexExpressions.add(new IndexExpression(name, IndexOperator.LTE, value));
            break;
        case OP_LT:
            indexExpressions.add(new IndexExpression(name, IndexOperator.LT, value));
            break;
        case OP_AND:
            indexExpressions.addAll(filterToIndexExpressions(be.getLhs()));
            indexExpressions.addAll(filterToIndexExpressions(be.getRhs()));
            break;
        default:
            throw new RuntimeException("Unsupported expression type: " + expression.getOpType().name());
    }
    return indexExpressions;
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:34,代码来源:CassandraStorage.java

示例8: getExpressionValue

import org.apache.pig.Expression; //导入方法依赖的package包/类
private Object getExpressionValue(Expression expr) {
    switch(expr.getOpType()) {
    case TERM_COL:
        return ((Column) expr).getName();
    case TERM_CONST:
        return getSearchArgObjValue(((Const) expr).getValue());
    default:
        throw new RuntimeException("Unsupported expression type: " + expr.getOpType() + " in " + expr);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:11,代码来源:OrcStorage.java

示例9: buildFilter

import org.apache.pig.Expression; //导入方法依赖的package包/类
private FilterPredicate buildFilter(Expression e) {
  OpType op = e.getOpType();

  if (e instanceof BinaryExpression) {
    Expression lhs = ((BinaryExpression) e).getLhs();
    Expression rhs = ((BinaryExpression) e).getRhs();

    switch (op) {
      case OP_AND:
        return and(buildFilter(lhs), buildFilter(rhs));
      case OP_OR:
        return or(buildFilter(lhs), buildFilter(rhs));
      case OP_BETWEEN:
        BetweenExpression between = (BetweenExpression) rhs;
        return and(
            buildFilter(OpType.OP_GE, (Column) lhs, (Const) between.getLower()),
            buildFilter(OpType.OP_LE, (Column) lhs, (Const) between.getUpper()));
      case OP_IN:
        FilterPredicate current = null;
        for (Object value : ((InExpression) rhs).getValues()) {
          FilterPredicate next = buildFilter(OpType.OP_EQ, (Column) lhs, (Const) value);
          if (current != null) {
            current = or(current, next);
          } else {
            current = next;
          }
        }
        return current;
    }

    if (lhs instanceof Column && rhs instanceof Const) {
      return buildFilter(op, (Column) lhs, (Const) rhs);
    } else if (lhs instanceof Const && rhs instanceof Column) {
      return buildFilter(op, (Column) rhs, (Const) lhs);
    }
  } else if (e instanceof UnaryExpression && op == OpType.OP_NOT) {
    return LogicalInverseRewriter.rewrite(
        not(buildFilter(((UnaryExpression) e).getExpression())));
  }

  throw new RuntimeException("Could not build filter for expression: " + e);
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:43,代码来源:ParquetLoader.java

示例10: buildSearchArgument

import org.apache.pig.Expression; //导入方法依赖的package包/类
private void buildSearchArgument(Expression expr, Builder builder) {
    if (expr instanceof BinaryExpression) {
        Expression lhs = ((BinaryExpression) expr).getLhs();
        Expression rhs = ((BinaryExpression) expr).getRhs();
        switch (expr.getOpType()) {
        case OP_AND:
            builder.startAnd();
            buildSearchArgument(lhs, builder);
            buildSearchArgument(rhs, builder);
            builder.end();
            break;
        case OP_OR:
            builder.startOr();
            buildSearchArgument(lhs, builder);
            buildSearchArgument(rhs, builder);
            builder.end();
            break;
        case OP_EQ:
            builder.equals(getColumnName(lhs), getExpressionValue(rhs));
            break;
        case OP_NE:
            builder.startNot();
            builder.equals(getColumnName(lhs), getExpressionValue(rhs));
            builder.end();
            break;
        case OP_LT:
            builder.lessThan(getColumnName(lhs), getExpressionValue(rhs));
            break;
        case OP_LE:
            builder.lessThanEquals(getColumnName(lhs), getExpressionValue(rhs));
            break;
        case OP_GT:
            builder.startNot();
            builder.lessThanEquals(getColumnName(lhs), getExpressionValue(rhs));
            builder.end();
            break;
        case OP_GE:
            builder.startNot();
            builder.lessThan(getColumnName(lhs), getExpressionValue(rhs));
            builder.end();
            break;
        case OP_BETWEEN:
            BetweenExpression between = (BetweenExpression) rhs;
            builder.between(getColumnName(lhs), getSearchArgObjValue(between.getLower()),  getSearchArgObjValue(between.getUpper()));
        case OP_IN:
            InExpression in = (InExpression) rhs;
            builder.in(getColumnName(lhs), getSearchArgObjValues(in.getValues()).toArray());
        default:
            throw new RuntimeException("Unsupported binary expression type: " + expr.getOpType() + " in " + expr);
        }
    } else if (expr instanceof UnaryExpression) {
        Expression unaryExpr = ((UnaryExpression) expr).getExpression();
        switch (expr.getOpType()) {
        case OP_NULL:
            builder.isNull(getColumnName(unaryExpr));
            break;
        case OP_NOT:
            builder.startNot();
            buildSearchArgument(unaryExpr, builder);
            builder.end();
            break;
        default:
            throw new RuntimeException("Unsupported unary expression type: " +
                    expr.getOpType() + " in " + expr);
        }
    } else {
        throw new RuntimeException("Unsupported expression type: " + expr.getOpType() + " in " + expr);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:70,代码来源:OrcStorage.java


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