include/AggTableImpl.h

00001 /***************************************************************************
00002  *   Copyright (C) 2007 by www.databasecache.com                           *
00003  *   Contact: praba_tuty@databasecache.com                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
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   ***************************************************************************/
00016 #ifndef AGGTABLE_IMPL_H
00017 #define AGGTABLE_IMPL_H
00018 #include<os.h>
00019 #include<DataType.h>
00020 #include<Transaction.h>
00021 #include<Database.h>
00022 #include<Index.h>
00023 #include<CatalogTables.h>
00024 #include<Info.h>
00025 #include<Debug.h>
00026 #include<DatabaseManagerImpl.h>
00027 #include<Predicate.h>
00028 enum AggType
00029 {
00030     AGG_MIN = 1,
00031     AGG_MAX,
00032     AGG_SUM,
00033     AGG_AVG,
00034     AGG_COUNT
00035 };
00036 class AggFldDef
00037 {
00038     public:
00039     char fldName[IDENTIFIER_LENGTH];
00040     DataType type;
00041     int length;
00042     void *bindBuf;
00043     void *appBuf;
00044     AggType atype;
00045     bool alreadyBinded;
00046 };
00047 
00048 
00049 class AggTableImpl:public Table
00050 {
00051     private:
00052     char tblName_[IDENTIFIER_LENGTH];
00053     void *curTuple; //holds the current tuple ptr. moved during fetch() calls
00054     List fldList;
00055     AggFldDef groupFld; 
00056     Table *tableHdl;
00057     List aggNodes; //change this list to some other data structure
00058     ListIterator aggNodeIter;
00059 
00060     int aggNodeSize;
00061     DbRetVal copyValuesToBindBuffer(void *tuple);
00062 
00063     public:
00064     AggTableImpl();
00065     virtual ~AggTableImpl();
00066 
00067     DbRetVal getFieldInfo(const char *fieldName,  FieldInfo *&info)
00068         { return ErrBadCall; }
00069 
00070     void* insertOrGet(); 
00071     void setTable(Table *impl){ tableHdl = impl;}
00072     void closeScan();
00073 
00074     //binding
00075     DbRetVal bindFld(const char *name, void *val);
00076     DbRetVal bindFld(const char *name, AggType aggType, void *val);
00077     DbRetVal setGroup(const char *name, void *val);
00078 
00079     void setCondition(Condition *p){}
00080     void markFldNull(const char *name){}
00081     void markFldNull(int colpos){}
00082     bool isFldNull(const char *name){return false;}
00083     bool isFldNull(int colpos){return false;}
00084     void clearFldNull(const char *name){}
00085     void clearFldNull(int colpos){}
00086     DbRetVal insertTuple() { return ErrBadCall; }
00087     DbRetVal updateTuple() { return ErrBadCall; }
00088     DbRetVal deleteTuple() { return ErrBadCall; }
00089     int deleteWhere() { return ErrBadCall; }
00090     int truncate() { return ErrBadCall; }
00091     long spaceUsed() { return 0; }
00092     int pagesUsed() { return 0; }
00093     DbRetVal lock(bool shared) { return ErrBadCall; }
00094     DbRetVal unlock(){ return ErrBadCall; }
00095     DbRetVal setUndoLogging(bool flag) { return ErrBadCall; }
00096     void printSQLIndexString(){ };
00097     char* getName() { return tableHdl->getName(); }
00098     List getFieldNameList(){ List list; return list;}
00099 
00100     DbRetVal execute();
00101     void* fetch();
00102     void* fetch(DbRetVal &rv);
00103     void* fetchNoBind();
00104     void* fetchNoBind(DbRetVal &rv);
00105     DbRetVal close();
00106 
00107     long numTuples();
00108     void printInfo();
00109 
00110 };
00111 
00112 
00113 #endif

CSQL Project Page