/** * Static method to optimize a set of with-param elements * * @param params the set of parameters to be optimized * @param visitor the expression visitor * @param contextItemType static information about the context item type and existence * @throws XPathException if a static error is found */ public static void optimize(ExpressionVisitor visitor, WithParam[] params, ContextItemStaticInfo contextItemType) throws XPathException { if (params != null) { for (WithParam param : params) { param.selectOp.optimize(visitor, contextItemType); param.computeEvaluator(); } } }
/** * Static method to optimize a set of with-param elements * * @param params the set of parameters to be optimized * @param visitor the expression visitor * @param contextItemType static information about the context item type and existence * @throws XPathException if a static error is found */ public static void optimize(ExpressionVisitor visitor, WithParam[] params, ContextItemStaticInfo contextItemType) throws XPathException { if (params != null) { for (WithParam param : params) { param.selectOp.optimize(visitor, contextItemType); param.computeEvaluator(); } } }
/** * Perform optimisation of an expression and its subexpressions. * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expression visitor * @param contextInfo the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws XPathException if an error is discovered during this phase * (typically a type error) */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); return this; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { Configuration config = visitor.getConfiguration(); selectOp.optimize(visitor, contextInfo); regexOp.optimize(visitor, contextInfo); flagsOp.optimize(visitor, contextInfo); if (matchingOp != null) { matchingOp.optimize(visitor, config.makeContextItemStaticInfo(BuiltInAtomicType.STRING, false)); } if (nonMatchingOp != null) { nonMatchingOp.optimize(visitor, config.makeContextItemStaticInfo(BuiltInAtomicType.STRING, false)); } List<String> warnings = new ArrayList<>(); precomputeRegex(config, warnings); for (String w : warnings) { visitor.getStaticContext().issueWarning(w, getLocation()); } return this; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { selectOp.optimize(visitor, contextInfo); initiallyOp.optimize(visitor, contextInfo); ContextItemStaticInfo cit2 = visitor.getConfiguration().makeContextItemStaticInfo(getSelectExpression().getItemType(), false); cit2.setContextSettingExpression(getSelectExpression()); actionOp.optimize(visitor, cit2); onCompletionOp.optimize(visitor, ContextItemStaticInfo.ABSENT); if (Literal.isEmptySequence(getSelectExpression())) { return getSelectExpression(); } if (Literal.isEmptySequence(getActionExpression())) { return getActionExpression(); } return this; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { selectOp.optimize(visitor, contextInfo); initiallyOp.optimize(visitor, contextInfo); ContextItemStaticInfo cit2 = visitor.getConfiguration().makeContextItemStaticInfo(getSelectExpression().getItemType(), false); cit2.setContextSettingExpression(getSelectExpression()); actionOp.optimize(visitor, cit2); onCompletionOp.optimize(visitor, ContextItemStaticInfo.ABSENT); if (Literal.isEmptySequence(getSelectExpression())) { return getSelectExpression(); } if (Literal.isEmptySequence(getActionExpression())) { return getActionExpression(); } return this; }
/** * Optimize the expression */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { // Very conservative optimization for the time being Expression sequence0 = getSequence(); getSequenceOp().optimize(visitor, contextItemType); Expression action0 = getAction(); getActionOp().optimize(visitor, contextItemType); if (sequence0 != getSequence() || action0 != getAction()) { // it's now worth re-attempting the "where" clause optimizations return optimize(visitor, contextItemType); } return this; }
/** * Optimize the expression */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { // Very conservative optimization for the time being Expression sequence0 = getSequence(); getSequenceOp().optimize(visitor, contextItemType); Expression action0 = getAction(); getActionOp().optimize(visitor, contextItemType); if (sequence0 != getSequence() || action0 != getAction()) { // it's now worth re-attempting the "where" clause optimizations return optimize(visitor, contextItemType); } return this; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (Literal.isConstantOne(getSubscript())) { return FirstItemExpression.makeFirstItemExpression(getBaseExpression()); } return this; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (Literal.isConstantOne(getSubscript())) { return FirstItemExpression.makeFirstItemExpression(getBaseExpression()); } return this; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { WithParam.optimize(visitor, actualParams, contextInfo); WithParam.optimize(visitor, tunnelParams, contextInfo); selectOp.typeCheck(visitor, contextInfo); // More info available second time around selectOp.optimize(visitor, contextInfo); if (Literal.isEmptySequence(getSelect())) { return getSelect(); } return this; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { WithParam.optimize(visitor, actualParams, contextInfo); WithParam.optimize(visitor, tunnelParams, contextInfo); selectOp.typeCheck(visitor, contextInfo); // More info available second time around selectOp.optimize(visitor, contextInfo); if (Literal.isEmptySequence(getSelect())) { return getSelect(); } return this; }
@Override /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { conditionOp.optimize(visitor, contextItemType); if (Literal.hasEffectiveBooleanValue(getCondition(), true)) { return getDocumentSorter(); } else if (Literal.hasEffectiveBooleanValue(getCondition(), false)) { return getDocumentSorter().getBaseExpression(); } return this; }
@Override /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { conditionOp.optimize(visitor, contextItemType); if (Literal.hasEffectiveBooleanValue(getCondition(), true)) { return getDocumentSorter(); } else if (Literal.hasEffectiveBooleanValue(getCondition(), false)) { return getDocumentSorter().getBaseExpression(); } return this; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (getBaseExpression() instanceof Literal) { GroundedValue<?> value = iterate(visitor.getStaticContext().makeEarlyEvaluationContext()).materialize(); return Literal.makeLiteral(value, this); } return this; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (getBaseExpression() instanceof Literal) { GroundedValue<?> value = iterate(visitor.getStaticContext().makeEarlyEvaluationContext()).materialize(); return Literal.makeLiteral(value, this); } return this; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { selectOp.optimize(visitor, contextItemType); if (Literal.isEmptySequence(getSelect())) { return getSelect(); } adoptChildExpression(getSelect()); if (getSelect().getItemType().isPlainType()) { return getSelect(); } return this; }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { selectOp.optimize(visitor, contextItemType); if (Literal.isEmptySequence(getSelect())) { return getSelect(); } adoptChildExpression(getSelect()); if (getSelect().getItemType().isPlainType()) { return getSelect(); } return this; }