Skip to content

Commit

Permalink
Merge pull request #296 from LiUSemWeb/ExtendCostModelToConsiderVocab…
Browse files Browse the repository at this point in the history
…ularyMapping

Extend cost model to consider vocabulary mapping
  • Loading branch information
hartig authored May 3, 2023
2 parents 35a0444 + 562c1c9 commit b61b463
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public LogicalOptimizerImpl() {

//// Uncomment the following line to apply vocabulary mappings of
//// federation members during query planning. Note that applying
//// vocabulary mappings is only supported by the naive algorithm
//// currently since the cost model needs to be extended to consider
//// vocabulary mappings is not supported by the evolutionary algorithm
//// currently since the rewriting rules need to be extended to consider
//// operators PhysicalOpLocalToGlobal and PhysicalOpGlobalToLocal.
// heuristics.add( new ApplyVocabularyMappings(false) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import se.liu.ida.hefquin.engine.federation.access.FederationAccessManager;
import se.liu.ida.hefquin.engine.queryplan.logical.LogicalOperator;
import se.liu.ida.hefquin.engine.queryplan.logical.UnaryLogicalOp;
import se.liu.ida.hefquin.engine.queryplan.logical.impl.LogicalOpJoin;
import se.liu.ida.hefquin.engine.queryplan.logical.impl.LogicalOpMultiwayUnion;
import se.liu.ida.hefquin.engine.queryplan.logical.impl.LogicalOpRequest;
import se.liu.ida.hefquin.engine.queryplan.logical.impl.LogicalOpUnion;
import se.liu.ida.hefquin.engine.queryplan.logical.impl.*;
import se.liu.ida.hefquin.engine.queryplan.physical.PhysicalOperatorForLogicalOperator;
import se.liu.ida.hefquin.engine.queryplan.physical.PhysicalPlan;
import se.liu.ida.hefquin.engine.queryplan.utils.PhysicalPlanFactory;
Expand Down Expand Up @@ -48,13 +45,16 @@ else if ( rootOp instanceof LogicalOpJoin ){
// The join cardinality is the minimum cardinality of subPlans
worker = new WorkerForJoin( this, plan.getSubPlan(0), plan.getSubPlan(1) );
}
else if ( rootOp instanceof UnaryLogicalOp ) {
else if ( rootOp instanceof LogicalOpTPAdd || rootOp instanceof LogicalOpBGPAdd || rootOp instanceof LogicalOpGPAdd ) {
worker = new WorkerForJoin( this, plan.getSubPlan(0), PhysicalPlanFactory.extractRequestAsPlan((UnaryLogicalOp) rootOp));
}
else if ( rootOp instanceof LogicalOpMultiwayUnion || rootOp instanceof LogicalOpUnion ) {
// The estimated cardinality is the sum up cardinality of subPlans
worker = new WorkerForUnion( this, plan );
}
else if ( rootOp instanceof LogicalOpLocalToGlobal || rootOp instanceof LogicalOpGlobalToLocal ) {
return _initiateCardinalityEstimation( plan.getSubPlan(0) );
}
else {
throw new IllegalArgumentException("The type of the root operator of the given plan is currently not supported (" + rootOp.getClass().getName() + ").");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ else if ( rootOp instanceof LogicalOpGPAdd ) {
final PhysicalPlan reqGP = PhysicalPlanFactory.extractRequestAsPlan( (LogicalOpGPAdd) rootOp );
return _initiateJoinCardinalityEstimation( plan.getSubPlan(0), reqGP, v );
}
else if ( rootOp instanceof LogicalOpLocalToGlobal || rootOp instanceof LogicalOpGlobalToLocal ){
return _initiateCardinalityEstimation( plan.getSubPlan(0), v );
}
else if ( rootOp instanceof LogicalOpJoin ) {
return _initiateJoinCardinalityEstimation( plan.getSubPlan(0), plan.getSubPlan(1), v );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ else if ( (fm instanceof TPFServer) || (fm instanceof BRTPFServer) ){
else
throw new IllegalArgumentException("Unsupported type of federation member: " + fm.getClass().getName() );
}
else if ( rootOp instanceof BasePhysicalOpBinaryJoin || rootOp instanceof PhysicalOpBinaryUnion || rootOp instanceof PhysicalOpMultiwayUnion ) {
else if ( rootOp instanceof BasePhysicalOpBinaryJoin
|| rootOp instanceof PhysicalOpBinaryUnion
|| rootOp instanceof PhysicalOpMultiwayUnion
|| rootOp instanceof PhysicalOpLocalToGlobal
|| rootOp instanceof PhysicalOpGlobalToLocal ) {
return CompletableFuture.completedFuture(0);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public CompletableFuture<Integer> initiateCostEstimation( final PhysicalPlan pla
final int numberOfJoinVars;
final CompletableFuture<Integer> futureIntResSize;

if ( lop instanceof UnaryLogicalOp ) {
if ( lop instanceof LogicalOpTPAdd || lop instanceof LogicalOpBGPAdd || lop instanceof LogicalOpGPAdd ) {
SPARQLGraphPattern pattern;
if (lop instanceof LogicalOpTPAdd) {
pattern = ((LogicalOpTPAdd) lop).getTP();
Expand Down Expand Up @@ -72,7 +72,11 @@ else if ( req instanceof SPARQLRequest ) {
numberOfJoinVars = 0; // irrelevant for request operators
futureIntResSize = null; // irrelevant for request operators
}
else if ( lop instanceof LogicalOpJoin || lop instanceof LogicalOpUnion || lop instanceof LogicalOpMultiwayUnion ) {
else if ( lop instanceof LogicalOpJoin
|| lop instanceof LogicalOpUnion
|| lop instanceof LogicalOpMultiwayUnion
|| lop instanceof LogicalOpLocalToGlobal
|| lop instanceof LogicalOpGlobalToLocal ) {
numberOfTerms = 0; // irrelevant for join operators
numberOfJoinVars = 0; // irrelevant for join operators
futureIntResSize = null; // irrelevant for join operators
Expand All @@ -98,7 +102,11 @@ else if ( pop instanceof PhysicalOpBindJoinWithFILTER
if ( pop instanceof PhysicalOpRequest ) {
costValue = numberOfTerms;
}
else if ( pop instanceof BasePhysicalOpBinaryJoin || pop instanceof PhysicalOpBinaryUnion || pop instanceof PhysicalOpMultiwayUnion ) {
else if ( pop instanceof BasePhysicalOpBinaryJoin
|| pop instanceof PhysicalOpBinaryUnion
|| pop instanceof PhysicalOpMultiwayUnion
|| pop instanceof PhysicalOpLocalToGlobal
|| pop instanceof PhysicalOpGlobalToLocal ) {
costValue = 0;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ else if ( fm instanceof TPFServer || fm instanceof BRTPFServer) {
throw createIllegalArgumentException(fm);
}
}
else if ( lop instanceof LogicalOpJoin || lop instanceof LogicalOpUnion || lop instanceof LogicalOpMultiwayUnion ) {
else if ( lop instanceof LogicalOpJoin
|| lop instanceof LogicalOpUnion
|| lop instanceof LogicalOpMultiwayUnion
|| lop instanceof LogicalOpLocalToGlobal
|| lop instanceof LogicalOpGlobalToLocal) {
return CompletableFuture.completedFuture(0);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ else if ( req instanceof SPARQLRequest ) {
numberOfJoinVars = 0; // irrelevant for request operators
futureIntResSize = null; // irrelevant for request operators
}
else if ( lop instanceof LogicalOpJoin || lop instanceof LogicalOpUnion || lop instanceof LogicalOpMultiwayUnion ) {
else if ( lop instanceof LogicalOpJoin
|| lop instanceof LogicalOpUnion
|| lop instanceof LogicalOpMultiwayUnion
|| lop instanceof LogicalOpLocalToGlobal
|| lop instanceof LogicalOpGlobalToLocal
) {
numberOfVars = 0; // irrelevant for join operators
numberOfJoinVars = 0; // irrelevant for join operators
futureIntResSize = null; // irrelevant for join operators
Expand Down Expand Up @@ -113,7 +118,11 @@ else if ( pop instanceof PhysicalOpBindJoinWithFILTER
else if ( pop instanceof PhysicalOpRequest ) {
costValue = numberOfVars;
}
else if ( pop instanceof BasePhysicalOpBinaryJoin || pop instanceof PhysicalOpBinaryUnion || pop instanceof PhysicalOpMultiwayUnion ) {
else if ( pop instanceof BasePhysicalOpBinaryJoin
|| pop instanceof PhysicalOpBinaryUnion
|| pop instanceof PhysicalOpMultiwayUnion
|| pop instanceof PhysicalOpGlobalToLocal
|| pop instanceof PhysicalOpLocalToGlobal ) {
costValue = 0;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ else if ( fm instanceof TPFServer || fm instanceof BRTPFServer) {
throw createIllegalArgumentException(fm);
}
}
else if ( lop instanceof LogicalOpJoin || lop instanceof LogicalOpUnion || lop instanceof LogicalOpMultiwayUnion ) {
else if ( lop instanceof LogicalOpJoin
|| lop instanceof LogicalOpUnion
|| lop instanceof LogicalOpMultiwayUnion
|| lop instanceof LogicalOpLocalToGlobal
|| lop instanceof LogicalOpGlobalToLocal) {
return CompletableFuture.completedFuture(0);
}
else {
Expand Down

0 comments on commit b61b463

Please sign in to comment.