Class DynamicPlanner
- java.lang.Object
-
- org.aksw.limes.core.execution.planning.planner.Planner
-
- org.aksw.limes.core.execution.planning.planner.DynamicPlanner
-
-
Constructor Summary
Constructors Constructor Description DynamicPlanner(ACache s, ACache t)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateDependencies(LinkSpecification spec)Create/Update dependency between a recently executed specification and an other specification.doublegetAtomicMappingSizes(String measure, double threshold)Computes atomic mapping sizes for a measure.doublegetAtomicRuntimeCosts(String measure, double threshold)Computes atomic costs for a metric expression.NestedPlangetBestConjunctivePlan(LinkSpecification spec, NestedPlan left, NestedPlan right, double selectivity)Find the least costly plan for a link specification with AND operator.NestedPlangetBestDifferencePlan(LinkSpecification spec, NestedPlan left, NestedPlan right, double selectivity)Find the least costly plan for a link specification with MINUS operator.StringgetDependency(LinkSpecification spec)Returns specification to whom the input specification parameter is dependent upon, if any.doublegetFilterCosts(List<String> measures, int mappingSize)Computes costs for a filtering instruction.LinkSpecificationgetLinkSpec(NestedPlan plan)Returns the specification from which the input plan was generated.NestedPlangetPlan(LinkSpecification spec)Returns the corresponding plan of a specification.Map<String,NestedPlan>getPlans()voidinit(LinkSpecification spec)Initialize plans and specifications fields.booleanisExecuted(LinkSpecification spec)Checks if the plan of the specified link specification is executed.booleanisStatic()Returns the status of the planner.LinkSpecificationnormalize(LinkSpecification spec)Normalization of input link specification.NestedPlanplan(LinkSpecification spec)Generates a NestedPlan for a link specification.NestedPlanplan(LinkSpecification spec, ACache source, ACache target, AMapping sourceMapping, AMapping targetMapping)Generates a instructionList based on the optimality assumption used in databases.voidupdatePlan(LinkSpecification spec, double rt, double selectivity, double msize)Updates the characteristics of a plan once it is executed.
-
-
-
Method Detail
-
getPlans
public Map<String,NestedPlan> getPlans()
-
init
public void init(LinkSpecification spec)
Initialize plans and specifications fields.- Parameters:
spec- The input link specification
-
createDependencies
public void createDependencies(LinkSpecification spec)
Create/Update dependency between a recently executed specification and an other specification. A specification L2 is dependent on an executed specification L1 if L1 and L2 have the same metric expression and L1 threshold is lower that L2's threshold. Using this definition, L2 is a sub-sumption of L1. Therefore, the execution of the initial specification L is speeded-up. Instead of fully executing L2, dynamic planner informs the execution engine about the dependency between L2 and L1, and the execution engine retrieves the mapping of L1 from the results buffer and creates a temporary filtering instruction in order to get L2's mapping from L1's mapping. If L2 is dependent on L1 but it is already dependent on another specification L3, then if L1's threshold must be higher than L3' threshold in order to replace the previous L2-L3 dependency.- Parameters:
spec- The recently executed specification
-
getDependency
public String getDependency(LinkSpecification spec)
Returns specification to whom the input specification parameter is dependent upon, if any.- Parameters:
spec- The dependent specification- Returns:
- a string representation of specification that spec depends upon
-
getAtomicRuntimeCosts
public double getAtomicRuntimeCosts(String measure, double threshold)
Computes atomic costs for a metric expression. If the metric expression of is not supported by the framework, it throws an InvalidMeasureException exception.- Parameters:
measure- Measure of metric expressionthreshold- Threshold of metric expression- Returns:
- runtime, estimated runtime cost of the metric expression
-
getAtomicMappingSizes
public double getAtomicMappingSizes(String measure, double threshold)
Computes atomic mapping sizes for a measure. If the metric expression of is not supported by the framework, it throws an InvalidMeasureException exception.- Parameters:
measure- Measure of metric expressionthreshold- Threshold of metric expression- Returns:
- estimated size of returned mapping
-
isExecuted
public boolean isExecuted(LinkSpecification spec)
Checks if the plan of the specified link specification is executed.- Parameters:
spec- The input link specification- Returns:
- true if the plan is executed, or false otherwise
-
getFilterCosts
public double getFilterCosts(List<String> measures, int mappingSize)
Computes costs for a filtering instruction. If the metric expression of the filtering instruction is not supported by the framework, it throws an InvalidMeasureException exception.- Parameters:
measures- Set of expressions used to filtermappingSize- Size of mapping- Returns:
- estimated runtime cost of filteringInstruction(s)
-
getPlan
public NestedPlan getPlan(LinkSpecification spec)
Returns the corresponding plan of a specification.- Parameters:
spec- The link specification- Returns:
- the plan of the input specification
-
getLinkSpec
public LinkSpecification getLinkSpec(NestedPlan plan)
Returns the specification from which the input plan was generated.- Parameters:
plan- The nested plan- Returns:
- the spec of the input plan
-
updatePlan
public void updatePlan(LinkSpecification spec, double rt, double selectivity, double msize)
Updates the characteristics of a plan once it is executed.- Parameters:
spec- The link specification from which the plan was generatedrt- The real runtime of the planselectivity- The real selectivity of the planmsize- The real mapping size returned when the plan is executed
-
plan
public NestedPlan plan(LinkSpecification spec)
Generates a NestedPlan for a link specification.- Parameters:
spec- Input link specification- Returns:
- a NestedPlan of the input link specification
-
plan
public NestedPlan plan(LinkSpecification spec, ACache source, ACache target, AMapping sourceMapping, AMapping targetMapping)
Generates a instructionList based on the optimality assumption used in databases. If the input link specification has an AND or a MINUS operator, then the plan function will find the least costly plan from a set of alternatives (seegetBestConjunctivePlan(org.aksw.limes.core.io.ls.LinkSpecification, org.aksw.limes.core.execution.planning.plan.NestedPlan, org.aksw.limes.core.execution.planning.plan.NestedPlan, double),getBestDifferencePlan(org.aksw.limes.core.io.ls.LinkSpecification, org.aksw.limes.core.execution.planning.plan.NestedPlan, org.aksw.limes.core.execution.planning.plan.NestedPlan, double)resp.).- Parameters:
spec- Input link specificationsource- Source cachetarget- Target cachesourceMapping- Size of source mappingtargetMapping- Size of target mapping- Returns:
- a NestedPlan for the input link specification
-
getBestDifferencePlan
public NestedPlan getBestDifferencePlan(LinkSpecification spec, NestedPlan left, NestedPlan right, double selectivity)
Find the least costly plan for a link specification with MINUS operator. Computes all possible nested plans given the children plans. If none of the children plans are executed or only the left child plan is executed, then the functions chooses either to (1) Execute both children plans, perform difference and filter the resulting mapping using the threshold of the link specification, or (2) Execute the plan of the left child, use the right child measure expression as a filer and then filter the resulting mapping using the threshold of the link specification. If the right child plan is executed, then the least costly plan is (1). The selection of the best alternative is based upon runtime estimations obtained for each of the atomic measure expressions included in the children specifications.- Parameters:
spec- The link specificationleft- Left child nested planright- Right child nested planselectivity- The overall selectivity- Returns:
- the resulting nested plan for the input spec, that is least costly
-
getBestConjunctivePlan
public NestedPlan getBestConjunctivePlan(LinkSpecification spec, NestedPlan left, NestedPlan right, double selectivity)
Find the least costly plan for a link specification with AND operator. Computes all possible nested plans given the children plans. If none of the children plans are executed then the functions chooses either to (1) Execute both children plans, perform intersection and filter the resulting mapping using the threshold of the link specification, or (2) Execute the plan of the left child, use the right child measure expression as a filer and then filter the resulting mapping using the threshold of the link specification, or (3) Execute the plan of the right child, use the left child measure expression as a filer and then filter the resulting mapping using the threshold of the link specification. If the left child plan is executed, then the least costly plan is either (1) or (2). If the right child plan is executed, then the least costly plan is either (1) or (3). If both children plans are executed then the least costly plan is (1). The selection of the best alternative is based upon runtime estimations obtained for each of the atomic measure expressions included in the children specifications.- Parameters:
spec- The link specificationleft- Left child nested planright- Right child nested planselectivity- The overall selectivity- Returns:
- the resulting nested plan for the input spec, that is least costly
-
isStatic
public boolean isStatic()
Returns the status of the planner.- Returns:
- false
-
normalize
public LinkSpecification normalize(LinkSpecification spec)
Normalization of input link specification. In case of XOR operator, the output specification uses the extended form of XOR (i.e. XOR(cosine(x.name,y.name)|0.5, overlap(x.label,y.label)|0.6)> =0.8 will transformed into MINUS(OR(cosine(x.name,y.name)|0.5, overlap(x.label,y.label)|0.6)|0.8, AND(cosine(x.name,y.name)|0.5, overlap(x.label,y.label)|0.6)|0.8) )>=0.8- Parameters:
spec- The normalized link specification- Returns:
- the normalized link specification
-
-