Class Costs

  • All Implemented Interfaces:
    Cloneable, Comparable<Costs>

    public class Costs
    extends Object
    implements Comparable<Costs>, Cloneable
    Simple class to represent the costs of an operation. The costs are currently tracking, network, I/O and CPU costs.

    Costs are composed of two parts of cost contributors:

    1. Quantifiable costs. Those costs are used when estimates are available and track a quantifiable measure, such as the number of bytes for network or I/O
    2. Heuristic costs. Those costs are used when no estimates are available. They can be used to track that an operator used a special operation which is heuristically considered more expensive than another operation.

    The quantifiable costs may frequently be unknown, which is represented by a -1 as a value for the unknown components of the cost. In that case, all operations' costs are unknown and hence it is not decidable which operation to favor during pruning. In that case, the heuristic costs should contain a value to make sure that operators with different strategies are comparable, even in the absence of estimates. The heuristic costs are hence the system's mechanism of realizing pruning heuristics that favor some operations over others.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double UNKNOWN  
    • Constructor Summary

      Constructors 
      Constructor Description
      Costs()
      Default constructor.
      Costs​(double networkCost, double diskCost)
      Creates a new costs object using the given values for the network and storage cost.
      Costs​(double networkCost, double diskCost, double cpuCost)
      Creates a new costs object using the given values for the network and storage cost.
    • Constructor Detail

      • Costs

        public Costs()
        Default constructor. Initializes all costs to 0;
      • Costs

        public Costs​(double networkCost,
                     double diskCost)
        Creates a new costs object using the given values for the network and storage cost.
        Parameters:
        networkCost - The network cost, in bytes to be transferred.
        diskCost - The cost for disk, in bytes to be written and read.
      • Costs

        public Costs​(double networkCost,
                     double diskCost,
                     double cpuCost)
        Creates a new costs object using the given values for the network and storage cost.
        Parameters:
        networkCost - The network cost, in bytes to be transferred.
        diskCost - The cost for disk, in bytes to be written and read.
        cpuCost - The cost for CPU operations.
    • Method Detail

      • getNetworkCost

        public double getNetworkCost()
        Gets the network cost.
        Returns:
        The network cost, in bytes to be transferred.
      • setNetworkCost

        public void setNetworkCost​(double bytes)
        Sets the network cost for this Costs object.
        Parameters:
        bytes - The network cost to set, in bytes to be transferred.
      • addNetworkCost

        public void addNetworkCost​(double bytes)
        Adds the costs for network to the current network costs for this Costs object.
        Parameters:
        bytes - The network cost to add, in bytes to be transferred.
      • getDiskCost

        public double getDiskCost()
        Gets the costs for disk.
        Returns:
        The disk cost, in bytes to be written and read.
      • setDiskCost

        public void setDiskCost​(double bytes)
        Sets the costs for disk for this Costs object.
        Parameters:
        bytes - The disk cost to set, in bytes to be written and read.
      • addDiskCost

        public void addDiskCost​(double bytes)
        Adds the costs for disk to the current disk costs for this Costs object.
        Parameters:
        bytes - The disk cost to add, in bytes to be written and read.
      • getCpuCost

        public double getCpuCost()
        Gets the cost for the CPU.
        Returns:
        The CPU Cost.
      • setCpuCost

        public void setCpuCost​(double cost)
        Sets the cost for the CPU.
        Parameters:
        cost - The CPU Cost.
      • addCpuCost

        public void addCpuCost​(double cost)
        Adds the given CPU cost to the current CPU cost for this Costs object.
        Parameters:
        cost - The CPU cost to add.
      • getHeuristicNetworkCost

        public double getHeuristicNetworkCost()
        Gets the heuristic network cost.
        Returns:
        The heuristic network cost, in bytes to be transferred.
      • setHeuristicNetworkCost

        public void setHeuristicNetworkCost​(double cost)
        Sets the heuristic network cost for this Costs object.
        Parameters:
        cost - The heuristic network cost to set, in bytes to be transferred.
      • addHeuristicNetworkCost

        public void addHeuristicNetworkCost​(double cost)
        Adds the heuristic costs for network to the current heuristic network costs for this Costs object.
        Parameters:
        cost - The heuristic network cost to add.
      • getHeuristicDiskCost

        public double getHeuristicDiskCost()
        Gets the heuristic costs for disk.
        Returns:
        The heuristic disk cost.
      • setHeuristicDiskCost

        public void setHeuristicDiskCost​(double cost)
        Sets the heuristic costs for disk for this Costs object.
        Parameters:
        cost - The heuristic disk cost to set.
      • addHeuristicDiskCost

        public void addHeuristicDiskCost​(double cost)
        Adds the heuristic costs for disk to the current heuristic disk costs for this Costs object.
        Parameters:
        cost - The heuristic disk cost to add.
      • getHeuristicCpuCost

        public double getHeuristicCpuCost()
        Gets the heuristic cost for the CPU.
        Returns:
        The heuristic CPU Cost.
      • setHeuristicCpuCost

        public void setHeuristicCpuCost​(double cost)
        Sets the heuristic cost for the CPU.
        Parameters:
        cost - The heuristic CPU Cost.
      • addHeuristicCpuCost

        public void addHeuristicCpuCost​(double cost)
        Adds the given heuristic CPU cost to the current heuristic CPU cost for this Costs object.
        Parameters:
        cost - The heuristic CPU cost to add.
      • addCosts

        public void addCosts​(Costs other)
        Adds the given costs to these costs. If for one of the different cost components (network, disk), the costs are unknown, the resulting costs will be unknown.
        Parameters:
        other - The costs to add.
      • subtractCosts

        public void subtractCosts​(Costs other)
        Subtracts the given costs from these costs. If the given costs are unknown, then these costs are remain unchanged.
        Parameters:
        other - The costs to subtract.
      • multiplyWith

        public void multiplyWith​(int factor)
      • divideBy

        public void divideBy​(int factor)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object