BadgerDB
/afs/cs.wisc.edu/u/n/w/nwilliam/private/workspace/Quut/src/catalog.h
00001 
00008 #pragma once
00009 
00010 #include "filescan.h"
00011 
00012 namespace badgerdb {
00013 
00017 #define RELCATNAME    "relcat"
00018 
00022 #define ATTRCATNAME   "attrcat"
00023 
00027 #define MAXNAMESIZE   32
00028 
00032 #define MAXSTRINGLEN  255
00033 
00034 
00038 typedef struct
00039 {
00043   char relName[MAXNAMESIZE];
00044 
00048   int attrCnt;
00049   
00053   int indexCnt;
00054 } RelDesc;
00055 
00056 
00064 typedef struct {
00068   char relName[MAXNAMESIZE];
00069 
00073   char attrName[MAXNAMESIZE];
00074 
00078   int  attrType;
00079 
00083   int  attrLen;
00084 
00090   void *attrValue;                         
00091 } attrInfo; 
00092 
00093 
00097 class RelCatalog : public FileScan {
00098  public:
00102   RelCatalog(BufMgr *bufferMgr);
00103 
00107   void getInfo(const std::string &relation, RelDesc &reldesc);
00108 
00112   void addInfo(RelDesc &reldesc);
00113 
00117   void removeInfo(const std::string & relation);
00118 
00122   void createRel(const std::string &relation, int attrCnt, const attrInfo attrList[]);
00123 
00127   void destroyRel(const std::string & relation);
00128 
00132   void addIndex(const std::string &relation, const std::string &attrName);
00133 
00137   void dropIndex(const std::string &relation, const std::string &attrName);
00138 
00142   void help(const std::string &rName);          // relation may be NULL
00143 
00147   ~RelCatalog();
00148 };
00149 
00150 
00154 typedef struct {
00158   char relName[MAXNAMESIZE];
00159 
00163   char attrName[MAXNAMESIZE];
00164 
00168   int attrOffset;
00169 
00173   int attrType;
00174 
00178   int attrLen;
00179 
00183   int indexed;
00184 } AttrDesc;
00185 
00186 
00190 class AttrCatalog : public FileScan
00191 {
00192  friend class RelCatalog;
00193 
00194  public:
00198   AttrCatalog(BufMgr *bufferMgr);
00199 
00203   void getInfo(const std::string &relation, const std::string &attrName, AttrDesc &attrdesc);
00204 
00208   void addInfo(AttrDesc &attrdesc);
00209 
00213   void removeInfo(const std::string &relation, const std::string &attrName);
00214 
00218   void getRelInfo(const std::string &relation, int &attrCnt, AttrDesc *&attrs);
00219 
00223   void dropRelation(const std::string &relation);
00224   
00228   void addIndex(const std::string &relation, const std::string &attrName);
00229 
00233   void dropIndex(const std::string &relation, const std::string &attrName);
00234 
00238   ~AttrCatalog();
00239 };
00240 
00241 }
00242 
00243 extern badgerdb::RelCatalog *relCat;
00244 extern badgerdb::AttrCatalog *attrCat;
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends