Class TransformEliminateAssignments
- All Implemented Interfaces:
Transform
There are two classes of assignments that we can try and in-line/eliminate:
- Assignments where the assigned variable is used only once in a subsequent expression can be in-lined
- Assignments where the assigned value is never used elsewhere can be eliminated
Eligibility for In-lining
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:
- They cannot occur inside a n-ary operator (e.g. join,
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 query - They cannot be in-lined into an
EXISTS
orNOT EXISTS
in a filter - They cannot be in-lined out of a
DISTINCT
orREDUCED
because the assignment would be relevant for the purposes of distinctness
Please see JENA-780 for more information on this.
In-lining Application
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.
-
Field Summary
Fields inherited from class org.apache.jena.sparql.algebra.TransformCopy
COPY_ALWAYS, COPY_ONLY_ON_CHANGE
-
Method Summary
Methods inherited from class org.apache.jena.sparql.algebra.TransformCopy
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, transform, transform, transform
-
Method Details
-
eliminate
-
eliminate
-
transform
- Specified by:
transform
in interfaceTransform
- Overrides:
transform
in classTransformCopy
-
transform
- Specified by:
transform
in interfaceTransform
- Overrides:
transform
in classTransformCopy
-
transform
- Specified by:
transform
in interfaceTransform
- Overrides:
transform
in classTransformCopy
-
transform
- Specified by:
transform
in interfaceTransform
- Overrides:
transform
in classTransformCopy
-
transform
- Specified by:
transform
in interfaceTransform
- Overrides:
transform
in classTransformCopy
-
transform
- Specified by:
transform
in interfaceTransform
- Overrides:
transform
in classTransformCopy
-