felix.optimizer
Class CostModel

java.lang.Object
  extended by felix.optimizer.CostModel

public class CostModel
extends java.lang.Object

An object of the cost model used by the optimizer. This class works as a bridge from PostgreSQL's optimizer to Felix's optimizer.

Author:
Ce Zhang

Nested Class Summary
 class CostModel.resultTuple
          Class for a set of different costs.
 
Field Summary
 double memoryTradeOff
           
 double postgreUnit
          The ratio of postgreSQL's unit cost to page IO cost.
 
Constructor Summary
CostModel(Felix _felix)
          The constructor of CostModel.
 
Method Summary
 void close()
          Close the database connection used by CostModel.
 double getCost(java.lang.String sql)
          Return the cost of the given sql query.
 double getFullMatCost(tuffy.ra.ConjunctiveQuery q, double numberOfBB, double numberOfBF, double numberOfFF, java.util.HashSet<java.lang.String> whichToBound)
          Return the cost of Fully-Materialization plan for q.
 double getFullViewCost(tuffy.ra.ConjunctiveQuery q, double numberOfBB, double numberOfBF, double numberOfFF, java.util.HashSet<java.lang.String> whichToBound)
          Return the cost of Fully-View plan for q.
 CostModel.resultTuple getJoinCostBetweenTwoMaterializedTable(tuffy.mln.Literal head, tuffy.ra.ConjunctiveQuery q1, tuffy.ra.ConjunctiveQuery q2, double numberOfBB, double numberOfBF, double numberOfFF, java.util.HashSet<java.lang.String> whichToBound)
          Return the cost of Hybrid-Materialization plan for query {head :- q1.head, q2.head}.
 CostModel.resultTuple getNewEmptyResultTuple()
          Return a new CostModel.resultTuple.
 void getPostgreUnit()
          Estimate postgreUnit.
 double getRows(java.lang.String sql)
          Return the number of rows returned by the given sql query.
 double getTableSize(java.lang.String tableName)
          Return the number of rows of the given table.
 double getTableWidth(java.lang.String tableName)
          Return the width (in bits) of the given table.
 double getWidth(java.lang.String sql)
          Return the width (in bits) returned by the given sql query.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

postgreUnit

public double postgreUnit
The ratio of postgreSQL's unit cost to page IO cost. This is estimated by some sample queries.


memoryTradeOff

public double memoryTradeOff
Constructor Detail

CostModel

public CostModel(Felix _felix)
The constructor of CostModel. This function will load the evidence file if it is not loaded before.

Parameters:
_felix -
Method Detail

getTableSize

public double getTableSize(java.lang.String tableName)
Return the number of rows of the given table.

Parameters:
tableName -
Returns:

getTableWidth

public double getTableWidth(java.lang.String tableName)
Return the width (in bits) of the given table.

Parameters:
tableName -
Returns:

getNewEmptyResultTuple

public CostModel.resultTuple getNewEmptyResultTuple()
Return a new CostModel.resultTuple.

Returns:

getCost

public double getCost(java.lang.String sql)
Return the cost of the given sql query.

Parameters:
sql -
Returns:

getRows

public double getRows(java.lang.String sql)
Return the number of rows returned by the given sql query.

Parameters:
sql -
Returns:

getWidth

public double getWidth(java.lang.String sql)
Return the width (in bits) returned by the given sql query.

Parameters:
sql -
Returns:

getPostgreUnit

public void getPostgreUnit()
Estimate postgreUnit.


close

public void close()
Close the database connection used by CostModel.


getFullMatCost

public double getFullMatCost(tuffy.ra.ConjunctiveQuery q,
                             double numberOfBB,
                             double numberOfBF,
                             double numberOfFF,
                             java.util.HashSet<java.lang.String> whichToBound)
Return the cost of Fully-Materialization plan for q.

Parameters:
q -
numberOfBB -
numberOfBF -
numberOfFF -
whichToBound -
Returns:

getFullViewCost

public double getFullViewCost(tuffy.ra.ConjunctiveQuery q,
                              double numberOfBB,
                              double numberOfBF,
                              double numberOfFF,
                              java.util.HashSet<java.lang.String> whichToBound)
Return the cost of Fully-View plan for q.

Parameters:
q -
numberOfBB -
numberOfBF -
numberOfFF -
whichToBound -
Returns:

getJoinCostBetweenTwoMaterializedTable

public CostModel.resultTuple getJoinCostBetweenTwoMaterializedTable(tuffy.mln.Literal head,
                                                                    tuffy.ra.ConjunctiveQuery q1,
                                                                    tuffy.ra.ConjunctiveQuery q2,
                                                                    double numberOfBB,
                                                                    double numberOfBF,
                                                                    double numberOfFF,
                                                                    java.util.HashSet<java.lang.String> whichToBound)
Return the cost of Hybrid-Materialization plan for query {head :- q1.head, q2.head}.

Parameters:
q -
numberOfBB -
numberOfBF -
numberOfFF -
whichToBound -
Returns: