Class DynamicPlanner

  • All Implemented Interfaces:
    IPlanner

    public class DynamicPlanner
    extends Planner
    Implements the Dynamic planner class. It receives a link specification as input and generates a mutable NestedPlan.
    Version:
    1.0
    Author:
    Kleanthi Georgala (georgala@informatik.uni-leipzig.de)
    • Constructor Detail

      • DynamicPlanner

        public DynamicPlanner​(ACache s,
                              ACache t)
    • Method Detail

      • 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 expression
        threshold - 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 expression
        threshold - 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 filter
        mappingSize - 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 generated
        rt - The real runtime of the plan
        selectivity - The real selectivity of the plan
        msize - 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
      • 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 specification
        left - Left child nested plan
        right - Right child nested plan
        selectivity - 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 specification
        left - Left child nested plan
        right - Right child nested plan
        selectivity - 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