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


Java Expression类代码示例

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


Expression类属于org.apache.pig包,在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getSupportedExpressionTypes

import org.apache.pig.Expression; //导入依赖的package包/类
@Override
public List<Expression.OpType> getSupportedExpressionTypes() {
  OpType supportedTypes [] = {
      OpType.OP_EQ,
      OpType.OP_NE,
      OpType.OP_GT,
      OpType.OP_GE,
      OpType.OP_LT,
      OpType.OP_LE,
      OpType.OP_AND,
      OpType.OP_OR,
      //OpType.OP_BETWEEN, // not implemented in Pig yet
      //OpType.OP_IN,      // not implemented in Pig yet
      OpType.OP_NOT
  };

  return Arrays.asList(supportedTypes);
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:19,代码来源:ParquetLoader.java

示例7: getSearchArgument

import org.apache.pig.Expression; //导入依赖的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;
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:18,代码来源:OrcStorage.java

示例8: setPartitionFilter

import org.apache.pig.Expression; //导入依赖的package包/类
/** set partition filter */
public void setPartitionFilter(Expression partitionFilter) throws IOException
{
    UDFContext context = UDFContext.getUDFContext();
    Properties property = context.getUDFProperties(AbstractCassandraStorage.class);
    property.setProperty(PARTITION_FILTER_SIGNATURE, indexExpressionsToString(filterToIndexExpressions(partitionFilter)));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:CassandraStorage.java

示例9: 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

示例10: setPartitionFilter

import org.apache.pig.Expression; //导入依赖的package包/类
@Override
public void setPartitionFilter(Expression partitionFilter) throws IOException {
  // convert the partition filter expression into a string expected by
  // hcat and pass it in setLocation()

  partitionFilterString = getHCatComparisonString(partitionFilter);

  // store this in the udf context so we can get it later
  storeInUDFContext(signature,
    PARTITION_FILTER, partitionFilterString);
}
 
开发者ID:cloudera,项目名称:RecordServiceClient,代码行数:12,代码来源:HCatRSLoader.java

示例11: setPartitionFilter

import org.apache.pig.Expression; //导入依赖的package包/类
/** set partition filter */
public void setPartitionFilter(Expression partitionFilter)
{
    UDFContext context = UDFContext.getUDFContext();
    Properties property = context.getUDFProperties(AbstractCassandraStorage.class);
    property.setProperty(PARTITION_FILTER_SIGNATURE, indexExpressionsToString(filterToIndexExpressions(partitionFilter)));
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:8,代码来源:CassandraStorage.java

示例12: 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

示例13: getPColCondition

import org.apache.pig.Expression; //导入依赖的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;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:16,代码来源:PColFilterExtractor.java

示例14: transform

import org.apache.pig.Expression; //导入依赖的package包/类
@Override
    public void transform(OperatorPlan matched) throws FrontendException {
    	subPlan = new OperatorSubPlan( currentPlan );

    	setupColNameMaps();
    	
    	// PIG-1871: Don't throw exception if partition filters cannot be pushed up. 
    	// Perform transformation on a copy of the filter plan, and replace the 
    	// original filter plan only if the transformation is successful 
    	// (i.e. partition filter can be pushed down) 
    	LogicalExpressionPlan filterExpr = loFilter.getFilterPlan();
    	LogicalExpressionPlan filterExprCopy = filterExpr.deepCopy();
    	
    	PColFilterExtractor pColFilterFinder = new PColFilterExtractor(
    	        filterExprCopy, getMappedKeys( partitionKeys ) );
    	pColFilterFinder.visit();
    	Expression partitionFilter = pColFilterFinder.getPColCondition();
    	
    	if(partitionFilter != null) {
    		// the column names in the filter may be the ones provided by
    		// the user in the schema in the load statement - we may need
    		// to replace them with partition column names as given by
    		// LoadFunc.getSchema()
    		updateMappedColNames(partitionFilter);
    		try {
	loadMetadata.setPartitionFilter(partitionFilter);
} catch (IOException e) {
	throw new FrontendException( e );
}
    		if(pColFilterFinder.isFilterRemovable()) {  
    			currentPlan.removeAndReconnect( loFilter );
    		} else {
    		    loFilter.setFilterPlan(filterExprCopy);
    		}
    	}
    }
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:37,代码来源:PartitionFilterOptimizer.java

示例15: updateMappedColNames

import org.apache.pig.Expression; //导入依赖的package包/类
private void updateMappedColNames(Expression expr) {
    if(expr instanceof BinaryExpression) {
        updateMappedColNames(((BinaryExpression) expr).getLhs());
        updateMappedColNames(((BinaryExpression) expr).getRhs());
    } else if (expr instanceof Column) {
        Column col = (Column) expr;
        col.setName(reverseColNameMap.get(col.getName()));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:10,代码来源:PartitionFilterOptimizer.java


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