Drizzled Public API Documentation

position.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2009 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <drizzled/join_table.h>
00023 
00024 namespace drizzled
00025 {
00026 namespace optimizer
00027 {
00028 
00033 class Position
00034 {
00035 public:
00036 
00037   Position()
00038     :
00039       records_read(0),
00040       read_time(0),
00041       table(NULL),
00042       key(NULL),
00043       ref_depend_map(0)
00044   {}
00045 
00046   Position(double in_records_read,
00047            double in_read_time,
00048            JoinTable *in_table,
00049            KeyUse *in_key,
00050            table_map in_ref_depend_map)
00051     :
00052       records_read(in_records_read),
00053       read_time(in_read_time),
00054       table(in_table),
00055       key(in_key),
00056       ref_depend_map(in_ref_depend_map)
00057   {}
00058 
00059   Position(const Position &rhs)
00060     :
00061       records_read(rhs.records_read),
00062       read_time(rhs.read_time),
00063       table(rhs.table),
00064       key(rhs.key),
00065       ref_depend_map(rhs.ref_depend_map)
00066   {}
00067 
00068   Position &operator=(const Position &rhs)
00069   {
00070     if (this == &rhs)
00071     {
00072       return *this;
00073     }
00074     records_read= rhs.records_read;
00075     read_time= rhs.read_time;
00076     table= rhs.table;
00077     key= rhs.key;
00078     ref_depend_map= rhs.ref_depend_map;
00079     return *this;
00080   }
00081 
00096   bool isConstTable() const
00097   {
00098     return (records_read < 2.0);
00099   }
00100 
00101   double getFanout() const
00102   {
00103     return records_read;
00104   }
00105 
00106   void setFanout(double in_records_read)
00107   {
00108     records_read= in_records_read;
00109   }
00110 
00111   double getCost() const
00112   {
00113     return read_time;
00114   }
00115 
00116   JoinTable *getJoinTable()
00117   {
00118     return table;
00119   }
00120 
00128   bool hasTableForSorting(Table *cmp_table) const
00129   {
00130     return (cmp_table != table->table);
00131   }
00132 
00133   bool examinePosition(table_map found_ref);
00134 
00135   KeyUse *getKeyUse()
00136   {
00137     return key;
00138   }
00139 
00140   table_map getRefDependMap()
00141   {
00142     return ref_depend_map;
00143   }
00144 
00145   void clearRefDependMap()
00146   {
00147     ref_depend_map= 0;
00148   }
00149 
00150 private:
00151 
00157   double records_read;
00158 
00164   double read_time;
00165 
00166   JoinTable *table;
00167 
00172   KeyUse *key;
00173 
00175   table_map ref_depend_map;
00176 
00177 };
00178 
00179 } /* end namespace optimizer */
00180 
00181 } /* end namespace drizzled */
00182