• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java NotExpression类的典型用法和代码示例

java 1次浏览

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

NotExpression类属于com.facebook.presto.sql.tree包,在下文中一共展示了NotExpression类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: toPredicate

点赞 3

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
private static Expression toPredicate(Domain domain, QualifiedNameReference reference)
{
    if (domain.getValues().isNone()) {
        return domain.isNullAllowed() ? new IsNullPredicate(reference) : FALSE_LITERAL;
    }

    if (domain.getValues().isAll()) {
        return domain.isNullAllowed() ? TRUE_LITERAL : new NotExpression(new IsNullPredicate(reference));
    }

    List<Expression> disjuncts = new ArrayList<>();

    disjuncts.addAll(domain.getValues().getValuesProcessor().transform(
            ranges -> extractDisjuncts(domain.getType(), ranges, reference),
            discreteValues -> extractDisjuncts(domain.getType(), discreteValues, reference),
            allOrNone -> {
                throw new IllegalStateException("Case should not be reachable");
            }));

    // Add nullability disjuncts
    if (domain.isNullAllowed()) {
        disjuncts.add(new IsNullPredicate(reference));
    }

    return combineDisjunctsWithDefault(disjuncts, TRUE_LITERAL);
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:27,
代码来源:DomainTranslator.java

示例2: normalize

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
public static Expression normalize(Expression expression)
{
    if (expression instanceof NotExpression) {
        NotExpression not = (NotExpression) expression;
        if (not.getValue() instanceof ComparisonExpression) {
            ComparisonExpression comparison = (ComparisonExpression) not.getValue();
            return new ComparisonExpression(negate(comparison.getType()), comparison.getLeft(), comparison.getRight());
        }
    }
    return expression;
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:12,
代码来源:ExpressionUtils.java

示例3: visitNotExpression

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Override
protected Object visitNotExpression(NotExpression node, Object context)
{
    Object value = process(node.getValue(), context);
    if (value == null) {
        return null;
    }

    if (value instanceof Expression) {
        return new NotExpression(toExpression(value, expressionTypes.get(node.getValue())));
    }

    return !(Boolean) value;
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:15,
代码来源:ExpressionInterpreter.java

示例4: visitNotExpression

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Override
protected Type visitNotExpression(NotExpression node, StackableAstVisitorContext<AnalysisContext> context)
{
    coerceType(context, node.getValue(), BOOLEAN, "Value of logical NOT expression");

    expressionTypes.put(node, BOOLEAN);
    return BOOLEAN;
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:9,
代码来源:ExpressionAnalyzer.java

示例5: testBetween

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Test
public void testBetween()
        throws Exception
{
    assertExpression("1 BETWEEN 2 AND 3", new BetweenPredicate(new LongLiteral("1"), new LongLiteral("2"), new LongLiteral("3")));
    assertExpression("1 NOT BETWEEN 2 AND 3", new NotExpression(new BetweenPredicate(new LongLiteral("1"), new LongLiteral("2"), new LongLiteral("3"))));
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:8,
代码来源:TestSqlParser.java

示例6: visitNotExpression

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Override
protected String visitNotExpression(NotExpression node, Void context)
{
    return "(NOT " + process(node.getValue(), null) + ")";
}
 

开发者ID:ajoabraham,
项目名称:hue,
代码行数:6,
代码来源:VeroGenExpFormatter.java

示例7: visitNotExpression

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Override
protected String visitNotExpression(NotExpression node, StackableAstVisitorContext<Integer> indent)
{
    return "(NOT " + process(node.getValue(), indent) + ")";
}
 

开发者ID:prestodb-rocks,
项目名称:presto-query-formatter,
代码行数:6,
代码来源:ExpressionFormatter.java

示例8: visitExpression

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Override
protected IComparison visitExpression(Expression node, QueryState state) {
	if( node instanceof LogicalBinaryExpression){
		LogicalBinaryExpression boolExp = (LogicalBinaryExpression)node;
		IComparison left = boolExp.getLeft().accept(this, state);
		IComparison right = boolExp.getRight().accept(this, state);
		return new BooleanComparison(left, right, boolExp.getType() == Type.AND);
	}else if( node instanceof ComparisonExpression){
		ComparisonExpression compareExp = (ComparisonExpression)node;
		Column column = new SelectParser().visitExpression(compareExp.getLeft(), state);
		Column leftCol = state.getHeading().getColumnByLabel(column.getLabel());
		if(leftCol == null){
			state.addException("Having reference "+column+" not found in SELECT clause");
			return null;
		}
		// right hand side is a concrete literal to compare with 
		if(compareExp.getRight() instanceof Literal){
			Object value;
			if(compareExp.getRight() instanceof LongLiteral) value = ((LongLiteral)compareExp.getRight()).getValue();
			else if(compareExp.getRight() instanceof BooleanLiteral) value = ((BooleanLiteral)compareExp.getRight()).getValue();
			else if(compareExp.getRight() instanceof DoubleLiteral) value = ((DoubleLiteral)compareExp.getRight()).getValue();
			else if(compareExp.getRight() instanceof StringLiteral) value = ((StringLiteral)compareExp.getRight()).getValue();
			else {
				state.addException("Unable to get value from "+compareExp.getRight());
				return null;
			}
			return new SimpleComparison(leftCol, compareExp.getType(), (Number)value);
		
			// right hand side refers to another column 	
		} else if(compareExp.getRight() instanceof DereferenceExpression || compareExp.getRight() instanceof QualifiedNameReference){
			String col2;
			if(compareExp.getLeft() instanceof DereferenceExpression){
				// parse columns like 'reference.field'
				col2 = SelectParser.visitDereferenceExpression((DereferenceExpression)compareExp.getRight());
			}else{
				col2 = ((QualifiedNameReference)compareExp.getRight()).getName().toString();
			}
			col2 = Heading.findOriginal(state.originalSql(), col2, "having.+", "\\W");
			Column rightCol = state.getHeading().getColumnByLabel(col2);
			if(rightCol == null){
				state.addException("column "+col2+" not found in SELECT clause");
				return null;
			}
			return new SimpleComparison(leftCol, compareExp.getType(), rightCol);
		}else { // unknown right hand side so
			state.addException("Unable to get value from "+compareExp.getRight());
			return null;
		}
		
	}else if( node instanceof NotExpression){
		state.addException("NOT is currently not supported, use '<>' instead");
	}else{
		state.addException("Unable to parse "+node+" ("+node.getClass().getName()+") is not a supported expression");
	}
	return null;
}
 

开发者ID:Anchormen,
项目名称:sql4es,
代码行数:57,
代码来源:HavingParser.java

示例9: visitNotExpression

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Override
protected RowExpression visitNotExpression(NotExpression node, Void context)
{
    return call(Signatures.notSignature(), BOOLEAN, process(node.getValue(), context));
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:6,
代码来源:SqlToRowExpressionTranslator.java

示例10: rewriteIsNotNullPredicate

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Override
public Expression rewriteIsNotNullPredicate(IsNotNullPredicate node, Void context, ExpressionTreeRewriter<Void> treeRewriter)
{
    Expression value = treeRewriter.rewrite(node.getValue(), context);
    return new NotExpression(new IsNullPredicate(value));
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:7,
代码来源:CanonicalizeExpressions.java

示例11: complementIfNecessary

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
private static Expression complementIfNecessary(Expression expression, boolean complement)
{
    return complement ? new NotExpression(expression) : expression;
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:5,
代码来源:DomainTranslator.java

示例12: visitNotExpression

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Override
protected ExtractionResult visitNotExpression(NotExpression node, Boolean complement)
{
    return process(node.getValue(), !complement);
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:6,
代码来源:DomainTranslator.java

示例13: visitNotExpression

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Override
protected Boolean visitNotExpression(NotExpression node, Void context)
{
    return process(node.getValue(), context);
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:6,
代码来源:AggregationAnalyzer.java

示例14: not

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
private static NotExpression not(Expression expression)
{
    return new NotExpression(expression);
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:5,
代码来源:TestDomainTranslator.java

示例15: isNotNull

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
private static Expression isNotNull(Symbol symbol)
{
    return new NotExpression(new IsNullPredicate(reference(symbol)));
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:5,
代码来源:TestDomainTranslator.java

示例16: visitLogicalNot

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Override
public Node visitLogicalNot(SqlBaseParser.LogicalNotContext context)
{
    return new NotExpression(getLocation(context), (Expression) visit(context.booleanExpression()));
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:6,
代码来源:AstBuilder.java

示例17: visitNotExpression

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Override
protected String visitNotExpression(NotExpression node, Boolean unmangleNames)
{
    return "(NOT " + process(node.getValue(), unmangleNames) + ")";
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:6,
代码来源:ExpressionFormatter.java

示例18: testPrecedenceAndAssociativity

点赞 2

import com.facebook.presto.sql.tree.NotExpression; //导入依赖的package包/类
@Test
public void testPrecedenceAndAssociativity()
        throws Exception
{
    assertExpression("1 AND 2 OR 3", new LogicalBinaryExpression(LogicalBinaryExpression.Type.OR,
            new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND,
                    new LongLiteral("1"),
                    new LongLiteral("2")),
            new LongLiteral("3")));

    assertExpression("1 OR 2 AND 3", new LogicalBinaryExpression(LogicalBinaryExpression.Type.OR,
            new LongLiteral("1"),
            new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND,
                    new LongLiteral("2"),
                    new LongLiteral("3"))));

    assertExpression("NOT 1 AND 2", new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND,
            new NotExpression(new LongLiteral("1")),
            new LongLiteral("2")));

    assertExpression("NOT 1 OR 2", new LogicalBinaryExpression(LogicalBinaryExpression.Type.OR,
            new NotExpression(new LongLiteral("1")),
            new LongLiteral("2")));

    assertExpression("-1 + 2", new ArithmeticBinaryExpression(ArithmeticBinaryExpression.Type.ADD,
            negative(new LongLiteral("1")),
            new LongLiteral("2")));

    assertExpression("1 - 2 - 3", new ArithmeticBinaryExpression(ArithmeticBinaryExpression.Type.SUBTRACT,
            new ArithmeticBinaryExpression(ArithmeticBinaryExpression.Type.SUBTRACT,
                    new LongLiteral("1"),
                    new LongLiteral("2")),
            new LongLiteral("3")));

    assertExpression("1 / 2 / 3", new ArithmeticBinaryExpression(ArithmeticBinaryExpression.Type.DIVIDE,
            new ArithmeticBinaryExpression(ArithmeticBinaryExpression.Type.DIVIDE,
                    new LongLiteral("1"),
                    new LongLiteral("2")),
            new LongLiteral("3")));

    assertExpression("1 + 2 * 3", new ArithmeticBinaryExpression(ArithmeticBinaryExpression.Type.ADD,
            new LongLiteral("1"),
            new ArithmeticBinaryExpression(ArithmeticBinaryExpression.Type.MULTIPLY,
                    new LongLiteral("2"),
                    new LongLiteral("3"))));
}
 

开发者ID:y-lan,
项目名称:presto,
代码行数:47,
代码来源:TestSqlParser.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)