Class TransformImplicitLeftJoin
- java.lang.Object
-
- org.apache.jena.sparql.algebra.TransformCopy
-
- org.apache.jena.sparql.algebra.optimize.TransformImplicitLeftJoin
-
- All Implemented Interfaces:
Transform
public class TransformImplicitLeftJoin extends TransformCopy
Optimizer for transforming implicit joins. These covers queries like the following:
SELECT * WHERE { ?s a ?type1 . OPTIONAL { ?t a ?type2 . FILTER(?s = ?t) } }
Clearly this is a trivial example but doing this optimization can have big performance gains since it can completely eliminate cross products that we would otherwise be required to evaluate. The optimization where applicable results in a query of the following form:
SELECT * WHERE { ?s a ?type1 . OPTIONAL { ?s a ?type1 . BIND(?s AS ?t) } }
This does not handle the simpler case of implicit joins where
OPTIONAL
is not involved, for that seeTransformFilterImplicitJoin
Applicability
This optimization aims to eliminate implicit left joins of the form
?x = ?y
orSAMETERM(?x, ?y)
, the latter can almost always be safely eliminated while the former may only be eliminated in the case where we can guarantee that at least one of the variables is a non-literal e.g. it occurs in the subject/predicate position. In the case where this is not true the optimization may not be made since we cannot assume that we can map value equality to term equality by making the optimization.
-
-
Field Summary
-
Fields inherited from class org.apache.jena.sparql.algebra.TransformCopy
COPY_ALWAYS, COPY_ONLY_ON_CHANGE
-
-
Constructor Summary
Constructors Constructor Description TransformImplicitLeftJoin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Op
transform(OpLeftJoin opLeftJoin, Op left, Op right)
-
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, transform, transform, transform
-
-
-
-
Method Detail
-
transform
public Op transform(OpLeftJoin opLeftJoin, Op left, Op right)
- Specified by:
transform
in interfaceTransform
- Overrides:
transform
in classTransformCopy
-
-