public Expression makeOptimizedFunctionCall( ExpressionVisitor visitor, ContextItemStaticInfo contextInfo, final Expression... arguments) throws XPathException { // See if we can deduce the answer from the cardinality int c = arguments[0].getCardinality(); if (c == StaticProperty.ALLOWS_ONE_OR_MORE) { return Literal.makeLiteral(BooleanValue.FALSE, arguments[0]); } else if (c == StaticProperty.ALLOWS_ZERO) { return Literal.makeLiteral(BooleanValue.TRUE, arguments[0]); } // Rewrite // empty(A|B) => empty(A) and empty(B) if (arguments[0] instanceof VennExpression && !visitor.isOptimizeForStreaming()) { VennExpression v = (VennExpression) arguments[0]; if (v.getOperator() == Token.UNION) { Expression e0 = SystemFunction.makeCall("empty", getRetainedStaticContext(), v.getLhsExpression()); Expression e1 = SystemFunction.makeCall("empty", getRetainedStaticContext(), v.getRhsExpression()); return new AndExpression(e0, e1).optimize(visitor, contextInfo); } } return null; }
public Expression makeOptimizedFunctionCall( ExpressionVisitor visitor, ContextItemStaticInfo contextInfo, final Expression... arguments) throws XPathException { // See if we can deduce the answer from the cardinality int c = arguments[0].getCardinality(); if (c == StaticProperty.ALLOWS_ONE_OR_MORE) { return Literal.makeLiteral(BooleanValue.FALSE, arguments[0]); } else if (c == StaticProperty.ALLOWS_ZERO) { return Literal.makeLiteral(BooleanValue.TRUE, arguments[0]); } // Rewrite // empty(A|B) => empty(A) and empty(B) if (arguments[0] instanceof VennExpression && !visitor.isOptimizeForStreaming()) { VennExpression v = (VennExpression) arguments[0]; if (v.getOperator() == Token.UNION) { Expression e0 = SystemFunction.makeCall("empty", getRetainedStaticContext(), v.getLhsExpression()); Expression e1 = SystemFunction.makeCall("empty", getRetainedStaticContext(), v.getRhsExpression()); return new AndExpression(e0, e1).optimize(visitor, contextInfo); } } return null; }
Expression e0 = SystemFunction.makeCall("empty", getRetainedStaticContext(), v.getLhsExpression()); Expression e1 = SystemFunction.makeCall("empty", getRetainedStaticContext(), v.getRhsExpression()); return new AndExpression(e0, e1).optimize(visitor, contextInfo);
Expression e0 = SystemFunction.makeCall("empty", getRetainedStaticContext(), v.getLhsExpression()); Expression e1 = SystemFunction.makeCall("empty", getRetainedStaticContext(), v.getRhsExpression()); return new AndExpression(e0, e1).optimize(visitor, contextInfo);