com.hp.hpl.jena.sparql.algebra.optimize
Class TransformPromoteTableEmpty
java.lang.Object
com.hp.hpl.jena.sparql.algebra.TransformCopy
com.hp.hpl.jena.sparql.algebra.optimize.TransformPromoteTableEmpty
- All Implemented Interfaces:
- Transform
public class TransformPromoteTableEmpty
- extends TransformCopy
Optimizer that ensures that table empty is promoted as high
up a query as is possible
table empty is an operator that may be introduced into the
algebra by other optimizations and represents the case where the optimizer
can a priori determine that some portion of a query will produce no results.
The classic example of this are FILTER clauses that may be determined
to always return false and thus negate the need to evaluate their inner
operations.
Other optimizers introduce table empty at the point in the
query where they are optimizing, often its presence in a query may render a
larger portion of even the entire query superfluous so this optimizer is
designed to promote it up through the query as necessary.
As detailed below this is not guaranteed to eliminate all portions of a query
rather it aims to eliminate portions where not doing so can cause expensive
and unnecessary evaluation to happen e.g. evaluating the left hand side of a
join (which may itself be a deeply nested operator) only to join it with
table empty and thus discard all the work that had been done.
Table Empty Promotions
The optimizer makes the following promotions:
- Graph over table empty => table empty
- Assign/Extend over table empty => table empty
- Join where either side is table empty => table empty
- Left Join:
- If LHS is table empty => table empty
- If RHS is table empty => LHS
- Union:
- If both sides are table empty => table empty
- If one side is table empty => other side
- Minus:
- If LHS is table empty => table empty
- If RHS is table empty => LHS
All other operators are left untouched either because it cannot be promoted
through them or because doing so has no clear benefit since applying them
over table empty should be minimal work anyway.
|
Method Summary |
Op |
transform(OpAssign opAssign,
Op subOp)
|
Op |
transform(OpExtend opExtend,
Op subOp)
|
Op |
transform(OpGraph opGraph,
Op subOp)
|
Op |
transform(OpJoin opJoin,
Op left,
Op right)
|
Op |
transform(OpLeftJoin opLeftJoin,
Op left,
Op right)
|
Op |
transform(OpMinus opMinus,
Op left,
Op right)
|
Op |
transform(OpUnion opUnion,
Op left,
Op right)
|
| Methods inherited from class com.hp.hpl.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 |
TransformPromoteTableEmpty
public TransformPromoteTableEmpty()
transform
public Op transform(OpGraph opGraph,
Op subOp)
- Specified by:
transform in interface Transform- Overrides:
transform in class TransformCopy
transform
public Op transform(OpAssign opAssign,
Op subOp)
- Specified by:
transform in interface Transform- Overrides:
transform in class TransformCopy
transform
public Op transform(OpExtend opExtend,
Op subOp)
- Specified by:
transform in interface Transform- Overrides:
transform in class TransformCopy
transform
public Op transform(OpJoin opJoin,
Op left,
Op right)
- Specified by:
transform in interface Transform- Overrides:
transform in class TransformCopy
transform
public Op transform(OpLeftJoin opLeftJoin,
Op left,
Op right)
- Specified by:
transform in interface Transform- Overrides:
transform in class TransformCopy
transform
public Op transform(OpMinus opMinus,
Op left,
Op right)
- Specified by:
transform in interface Transform- Overrides:
transform in class TransformCopy
transform
public Op transform(OpUnion opUnion,
Op left,
Op right)
- Specified by:
transform in interface Transform- Overrides:
transform in class TransformCopy
Licenced under the Apache License, Version 2.0