public class TransformEliminateAssignments extends TransformCopy
There are two classes of assignments that we can try and in-line/eliminate:
Both of these changes can only happen inside of projections as otherwise we
have to assume that the user may need the resulting variable and thus we
leave the assignment alone. Assignments to be in-lined must also be
deterministic i.e. moving their placement in the query and thus the possible
solutions they might operate must not change their outputs. Whether an
expression is deterministic is defined by ExprLib.isStable(Expr).
In-lining must also respect variable scope, it is possible with a nested query to have an assignment in-lined out through a projection that projects it provided that the projection is appropriately modified.
There are also various other conditions on assignments that might be eligible for in-lining:
UNION,
OPTIONAL etc.) because then in-lining would change semantics because
an expression that previously was only valid for part of the query might
become valid for a larger part of the queryEXISTS or NOT EXISTS in a
filterDISTINCT or REDUCED
because the assignment would be relevant for the purposes of distinctnessPlease see JENA-780 for more information on this.
Assignments may be in-lined in the following places:
FILTER ExpressionsBIND and Project ExpressionsORDER BY Expressions if aggressive in-lining is enabled or the
assigned expression is a constant
In the case of ORDER BY we only in-line assignments when aggressive
mode is set unless the assignment is a constant value. This is because during
order by evaluation expressions may be recomputed multiple times and so
in-lining may actually hurt performance in those cases unless the expression
to be in-lined is itself a constant.
COPY_ALWAYS, COPY_ONLY_ON_CHANGE| Modifier and Type | Method and Description |
|---|---|
static Op |
eliminate(Op op) |
static Op |
eliminate(Op op,
boolean aggressive) |
Op |
transform(OpExt opExt) |
Op |
transform(OpExtend opExtend,
Op subOp) |
Op |
transform(OpFilter opFilter,
Op subOp) |
Op |
transform(OpGroup opGroup,
Op subOp) |
Op |
transform(OpOrder opOrder,
Op subOp) |
Op |
transform(OpTopN opTop,
Op subOp) |
transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transformpublic Op transform(OpExt opExt)
transform in interface Transformtransform in class TransformCopypublic Op transform(OpFilter opFilter, Op subOp)
transform in interface Transformtransform in class TransformCopypublic Op transform(OpExtend opExtend, Op subOp)
transform in interface Transformtransform in class TransformCopypublic Op transform(OpOrder opOrder, Op subOp)
transform in interface Transformtransform in class TransformCopypublic Op transform(OpTopN opTop, Op subOp)
transform in interface Transformtransform in class TransformCopyLicenced under the Apache License, Version 2.0