1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 ***************************************************************************/
16 #ifndef AGGTABLE_IMPL_H
17 #define AGGTABLE_IMPL_H
20 #include<Transaction.h>
23 #include<CatalogTables.h>
26 #include<DatabaseManagerImpl.h>
41 char fldName
[IDENTIFIER_LENGTH
];
64 HashMapNode() { elem
= NULL
; next
= NULL
; }
72 HashMap(){ keySize
= 0; bucketSize
= 1009;
73 bucket
= (void**) malloc(bucketSize
* sizeof(void*));
74 memset(bucket
, 0, bucketSize
* sizeof(void*));
76 void setKeySize(int size
);
77 DbRetVal
insert(void *elem
);
78 void* find(void *elem
);
82 class AggTableImpl
:public Table
85 char tblName_
[IDENTIFIER_LENGTH
];
86 void *curTuple
; //holds the current tuple ptr. moved during fetch() calls
90 List aggNodes
; //change this list to some other data structure
91 ListIterator aggNodeIter
;
92 HashMap aggNodeMap
; //for faster lookup
95 DbRetVal
copyValuesToBindBuffer(void *tuple
);
98 virtual ~AggTableImpl();
99 DbRetVal
getFieldInfo(const char *fieldName
, FieldInfo
*&info
)
100 { return tableHdl
->getFieldInfo(fieldName
, info
); }
103 if (groupFld
.type
== typeUnknown
) return false; else return true;
106 void setTable(Table
*impl
){ tableHdl
= impl
;}
107 Table
* getTableHdl(){ return tableHdl
; }
108 DbRetVal
closeScan();
109 void *getBindFldAddr(const char *name
);
110 DbRetVal
bindFld(const char *name
, void *val
);
111 DbRetVal
bindFld(const char *name
, AggType aggType
, void *val
);
112 DbRetVal
setGroup(const char *name
, void *val
);
113 void setCondition(Condition
*p
){}
114 DbRetVal
markFldNull(const char *name
){}
115 DbRetVal
markFldNull(int colpos
){}
116 bool isFldNull(const char *name
){return false;}
117 bool isFldNull(int colpos
){return false;}
118 void clearFldNull(const char *name
){}
119 void clearFldNull(int colpos
){}
120 int getFldPos(char *name
){}
121 void resetNullinfo(){}
122 DbRetVal
insertTuple() { return ErrBadCall
; }
123 DbRetVal
updateTuple() { return ErrBadCall
; }
124 DbRetVal
deleteTuple() { return ErrBadCall
; }
125 int deleteWhere() { return ErrBadCall
; }
126 int truncate() { return ErrBadCall
; }
127 long spaceUsed() { return 0; }
128 int pagesUsed() { return 0; }
129 DbRetVal
lock(bool shared
) { return ErrBadCall
; }
130 DbRetVal
unlock(){ return ErrBadCall
; }
131 DbRetVal
setUndoLogging(bool flag
) { return ErrBadCall
; }
132 void printSQLIndexString(){ };
133 char* getName() { return tableHdl
->getName(); }
134 List
getFieldNameList(){ List list
; return list
;}
137 void* fetch(DbRetVal
&rv
);
139 void* fetchNoBind(DbRetVal
&rv
);
143 bool pushPredicate(Predicate
*pred
)
144 { printf("Wrong call\n"); return false; }
145 void setPredicate(Predicate
*pred
)
146 { printf("Wrong call\n"); }
147 bool isTableInvolved(char *tableName
)
148 { printf("Wrong call\n"); return false; }
149 void printPlan(int space
){printf("AGG-PLAN-TODO\n");}
151 { printf("Wrong call\n"); return OK
; }
152 ScanType
getScanType(){ return unknownScan
;}
153 bool hasIndex(char *fName
){ return false;}