Exemple #1
0
 /**
  * Estimate the cardinality of a join. The cardinality of a join is the number of tuples produced
  * by the join.
  *
  * @param j A LogicalJoinNode representing the join operation being performed.
  * @param card1 Cardinality of the left-hand table in the join
  * @param card2 Cardinality of the right-hand table in the join
  * @param t1pkey Is the left-hand table a primary-key table?
  * @param t2pkey Is the right-hand table a primary-key table?
  * @param stats The table stats, referenced by table names, not alias
  * @return The cardinality of the join
  */
 public int estimateJoinCardinality(
     LogicalJoinNode j,
     int card1,
     int card2,
     boolean t1pkey,
     boolean t2pkey,
     Map<String, TableStats> stats) {
   if (j instanceof LogicalSubplanJoinNode) {
     // A LogicalSubplanJoinNode represents a subquery.
     // You do not need to implement proper support for these for Project 3.
     return card1;
   } else {
     return estimateTableJoinCardinality(
         j.p,
         j.t1Alias,
         j.t2Alias,
         j.f1PureName,
         j.f2PureName,
         card1,
         card2,
         t1pkey,
         t2pkey,
         stats,
         p.getTableAliasToIdMapping());
   }
 }
Exemple #2
0
 /**
  * Estimate the cardinality of a join. The cardinality of a join is the number of tuples produced
  * by the join.
  *
  * @param j A LogicalJoinNode representing the join operation being performed.
  * @param card1 Cardinality of the left-hand table in the join
  * @param card2 Cardinality of the right-hand table in the join
  * @param t1pkey Is the left-hand table a primary-key table?
  * @param t2pkey Is the right-hand table a primary-key table?
  * @param stats The table stats, referenced by table names, not alias
  * @return The cardinality of the join
  */
 public int estimateJoinCardinality(
     LogicalJoinNode j,
     int card1,
     int card2,
     boolean t1pkey,
     boolean t2pkey,
     Map<String, TableStats> stats) {
   if (j instanceof LogicalSubplanJoinNode) {
     // A LogicalSubplanJoinNode represents a subquery.
     // Don't worry about implementing a more sophisticated estimate than the one below.
     return card1;
   } else {
     return estimateTableJoinCardinality(
         j.p,
         j.t1Alias,
         j.t2Alias,
         j.f1PureName,
         j.f2PureName,
         card1,
         card2,
         t1pkey,
         t2pkey,
         stats,
         p.getTableAliasToIdMapping());
   }
 }