Package org.apache.flink.optimizer.costs
Class Costs
- java.lang.Object
-
- org.apache.flink.optimizer.costs.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:
- 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
- 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
-1as 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 doubleUNKNOWN
-
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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCosts(Costs other)Adds the given costs to these costs.voidaddCpuCost(double cost)Adds the given CPU cost to the current CPU cost for this Costs object.voidaddDiskCost(double bytes)Adds the costs for disk to the current disk costs for this Costs object.voidaddHeuristicCpuCost(double cost)Adds the given heuristic CPU cost to the current heuristic CPU cost for this Costs object.voidaddHeuristicDiskCost(double cost)Adds the heuristic costs for disk to the current heuristic disk costs for this Costs object.voidaddHeuristicNetworkCost(double cost)Adds the heuristic costs for network to the current heuristic network costs for this Costs object.voidaddNetworkCost(double bytes)Adds the costs for network to the current network costs for this Costs object.Costsclone()intcompareTo(Costs o)The order of comparison is: network first, then disk, then CPU.voiddivideBy(int factor)booleanequals(Object obj)doublegetCpuCost()Gets the cost for the CPU.doublegetDiskCost()Gets the costs for disk.doublegetHeuristicCpuCost()Gets the heuristic cost for the CPU.doublegetHeuristicDiskCost()Gets the heuristic costs for disk.doublegetHeuristicNetworkCost()Gets the heuristic network cost.doublegetNetworkCost()Gets the network cost.inthashCode()voidmultiplyWith(int factor)voidsetCpuCost(double cost)Sets the cost for the CPU.voidsetDiskCost(double bytes)Sets the costs for disk for this Costs object.voidsetHeuristicCpuCost(double cost)Sets the heuristic cost for the CPU.voidsetHeuristicDiskCost(double cost)Sets the heuristic costs for disk for this Costs object.voidsetHeuristicNetworkCost(double cost)Sets the heuristic network cost for this Costs object.voidsetNetworkCost(double bytes)Sets the network cost for this Costs object.voidsubtractCosts(Costs other)Subtracts the given costs from these costs.StringtoString()
-
-
-
Field Detail
-
UNKNOWN
public static final double UNKNOWN
- See Also:
- Constant Field Values
-
-
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)
-
compareTo
public int compareTo(Costs o)
The order of comparison is: network first, then disk, then CPU. The comparison here happens each time primarily after the heuristic costs, then after the quantifiable costs.- Specified by:
compareToin interfaceComparable<Costs>- See Also:
Comparable.compareTo(java.lang.Object)
-
-