Class MergeRequests
java.lang.Object
se.liu.ida.hefquin.engine.queryproc.impl.loptimizer.heuristics.MergeRequests
- All Implemented Interfaces:
HeuristicForLogicalOptimization
Merges subplans that consist of multiple requests to the same federation
member if such a merge is possible. Merging of requests is avoided for
cases in which the graph pattern of the merged request consists of two
unconnected sub-patterns (because that would lead to retrieving the
cross product of the results of these two sub-patterns).
In particular, a join over two requests is merged into a single request
operator if i) the two requests are triple pattern requests (which can be
merged into a BGP request and the federation member supports BGP requests,
or ii) one of the two requests is a BGP request and the other one also a
BGP request or a triple pattern request.
Another possibility for merging is a join over two arbitrary SPARQL pattern
requests for a SPARQL endpoint. For SPARQL endpoints, this heuristic even
tries to push other operators into requests (filters, unions, optional).
The aforementioned join-related merge is performed not only for binary join
operators but also for gpAdd operators over request operators, as well as
for pairs of requests under a multi-join. In the latter case, the multi-join
operator is replaced by the merged request operator only if there are no other
subplans under that multi-join operator.
The merging is applied recursively in a bottom-up fashion, which means that,
after performing one merge step, another one may become available and will be
done.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(LogicalPlan inputPlan) apply(LogicalPlan inputPlan, QueryProcContext ctxt2) Applies this heuristics to the given plan and returns the resulting, potentially rewritten plan.protected booleancontainsJoinVariable(SPARQLGraphPattern pattern1, SPARQLGraphPattern pattern2) Checks whether the expected variables of the two patterns have at least one variable in common.protected LogicalPlancreatePlanWithSingleRequestOp(SPARQLGraphPattern p, boolean mayReduce, FederationMember fm) protected SPARQLGraphPatternmergePatternWithMinusPatterns(SPARQLGraphPattern pattern, SPARQLGraphPattern... minusPatterns) protected SPARQLGraphPatternmergePatternWithOptPatterns(SPARQLGraphPattern pattern, SPARQLGraphPattern... optPatterns) protected List<LogicalPlan> mergeSPARQLRequestsViaJoin(FederationMember fm, boolean mayReduce, List<LogicalPlan> reqPlans) Merges request plans whose patterns share variables.protected SPARQLGraphPatternmergeSPARQLRequestsViaUnion(List<LogicalPlan> reqPlans) Assumes that the given list contains at least two plans and that all plans in the list consist only of a request operator.protected voidseparateSubPlansOfMultiwayOps(List<LogicalPlan> subPlans, Map<FederationMember, List<LogicalPlan>> reqOnlyPlansPerFedMember, List<LogicalPlan> nonReqSubPlans)
-
Constructor Details
-
MergeRequests
public MergeRequests()
-
-
Method Details
-
apply
Description copied from interface:HeuristicForLogicalOptimizationApplies this heuristics to the given plan and returns the resulting, potentially rewritten plan.- Specified by:
applyin interfaceHeuristicForLogicalOptimization
-
apply
-
mergeSPARQLRequestsViaUnion
Assumes that the given list contains at least two plans and that all plans in the list consist only of a request operator. -
mergeSPARQLRequestsViaJoin
protected List<LogicalPlan> mergeSPARQLRequestsViaJoin(FederationMember fm, boolean mayReduce, List<LogicalPlan> reqPlans) Merges request plans whose patterns share variables. Patterns that are connected through shared variables are merged when the resulting pattern is supported by the federation member. Assumes that all plans in the list consist only of a request operator and that all of these request operators are for the federation member given as the first argument of this method.- Parameters:
fm- the target federation membermayReduce- whether the resulting request plans may be reducedreqPlans- the request plans to merge- Returns:
- the resulting request plans, with joinable patterns merged, or
nullif no merging was possible
-
mergePatternWithOptPatterns
protected SPARQLGraphPattern mergePatternWithOptPatterns(SPARQLGraphPattern pattern, SPARQLGraphPattern... optPatterns) -
mergePatternWithMinusPatterns
protected SPARQLGraphPattern mergePatternWithMinusPatterns(SPARQLGraphPattern pattern, SPARQLGraphPattern... minusPatterns) -
createPlanWithSingleRequestOp
protected LogicalPlan createPlanWithSingleRequestOp(SPARQLGraphPattern p, boolean mayReduce, FederationMember fm) -
separateSubPlansOfMultiwayOps
protected void separateSubPlansOfMultiwayOps(List<LogicalPlan> subPlans, Map<FederationMember, List<LogicalPlan>> reqOnlyPlansPerFedMember, List<LogicalPlan> nonReqSubPlans) -
containsJoinVariable
Checks whether the expected variables of the two patterns have at least one variable in common.- Parameters:
pattern1- the first SPARQL graph patternpattern2- the second SPARQL graph pattern- Returns:
- true if the patterns share at least one expected variable, false otherwise
-