#include <CatalogTables.h>
Collaboration diagram for CatalogTableINDEX:
Public Member Functions | |
CatalogTableINDEX (Database *db) | |
DbRetVal | insert (const char *name, void *tblPtr, int numFlds, bool isUnique, void *chunk, int bucketSize, void *hChunk, void *&tupleptr) |
DbRetVal | remove (const char *name, void *&chunk, void *&hchunk, void *&iptr) |
DbRetVal | get (const char *name, void *&chunk, void *&hchunk, void *&iptr) |
int | getNumIndexes (void *tblPtr) |
char * | getIndexName (void *tblPtr, int pos) |
void | getIndexPtrs (void *tblPtr, char **&array) |
Static Public Member Functions | |
static ChunkIterator | getIterator (void *iptr) |
static int | getNoOfBuckets (void *iptr) |
static int | getUnique (void *iptr) |
static char * | getName (void *iptr) |
Definition at line 194 of file CatalogTables.h.
CatalogTableINDEX::CatalogTableINDEX | ( | Database * | db | ) | [inline] |
DbRetVal CatalogTableINDEX::get | ( | const char * | name, | |
void *& | chunk, | |||
void *& | hchunk, | |||
void *& | iptr | |||
) |
Definition at line 296 of file CatalogTables.cxx.
References ErrNotExists, Chunk::getIterator(), Database::getSystemDatabaseChunk(), IndexTableId, ChunkIterator::nextElement(), OK, and printError.
Referenced by DatabaseManagerImpl::printIndexInfo().
00297 { 00298 Chunk *fChunk = systemDatabase_->getSystemDatabaseChunk(IndexTableId); 00299 ChunkIterator iter = fChunk->getIterator(); 00300 00301 void *data = NULL; 00302 while ((data = iter.nextElement())!= NULL) 00303 { 00304 if (0 == strcmp(((INDEX*)data)->indName_, name)) 00305 { 00306 //remove this element and store the tuple ptr 00307 //there will be only one row for this table(Primary key) 00308 chunk = (Chunk*) ((INDEX*)data)->chunkPtr_; 00309 hchunk = (Chunk*) ((INDEX*)data)->hashNodeChunk_; 00310 iptr = (void*) data; 00311 break; 00312 } 00313 } 00314 if (NULL == iptr) 00315 { 00316 printError(ErrNotExists,"Index %s not exists in INDEX catalog table", name); 00317 return ErrNotExists; 00318 } 00319 return OK; 00320 }
Here is the call graph for this function:
Here is the caller graph for this function:
char * CatalogTableINDEX::getIndexName | ( | void * | tblPtr, | |
int | pos | |||
) |
Definition at line 335 of file CatalogTables.cxx.
References Chunk::getIterator(), Database::getSystemDatabaseChunk(), IndexTableId, and ChunkIterator::nextElement().
Referenced by DatabaseManagerImpl::dropTable().
00336 { 00337 if (position == 0) return NULL; 00338 Chunk *fChunk = systemDatabase_->getSystemDatabaseChunk(IndexTableId); 00339 ChunkIterator iter = fChunk->getIterator(); 00340 void *iptr = NULL; 00341 int numIndex =0; 00342 int curPos =0; 00343 while (NULL != (iptr = iter.nextElement())) 00344 { 00345 if (((INDEX*)iptr)->tblPtr_ == tptr) curPos++; 00346 if ( curPos == position ) return ((INDEX*)iptr)->indName_; 00347 } 00348 return NULL; 00349 00350 }
Here is the call graph for this function:
Here is the caller graph for this function:
void CatalogTableINDEX::getIndexPtrs | ( | void * | tblPtr, | |
char **& | array | |||
) |
Definition at line 352 of file CatalogTables.cxx.
References Chunk::getIterator(), Database::getSystemDatabaseChunk(), IndexTableId, and ChunkIterator::nextElement().
Referenced by DatabaseManagerImpl::openTable().
00353 { 00354 void *iptr = NULL; 00355 Chunk *fChunk = systemDatabase_->getSystemDatabaseChunk(IndexTableId); 00356 ChunkIterator iter = fChunk->getIterator(); 00357 int i=0; 00358 while (NULL != (iptr = iter.nextElement())) 00359 { 00360 if (((INDEX*)iptr)->tblPtr_ == tptr) 00361 { 00362 array[i++] = (char*) iptr; 00363 } 00364 } 00365 return; 00366 }
Here is the call graph for this function:
Here is the caller graph for this function:
ChunkIterator CatalogTableINDEX::getIterator | ( | void * | iptr | ) | [static] |
Definition at line 368 of file CatalogTables.cxx.
References INDEX::chunkPtr_.
Referenced by HashIndex::insert(), DatabaseManagerImpl::openTable(), HashIndex::remove(), and HashIndex::update().
00369 { 00370 INDEX *index = (INDEX*)iptr; 00371 return ((Chunk*)index->chunkPtr_)->getIterator(); 00372 }
Here is the caller graph for this function:
char * CatalogTableINDEX::getName | ( | void * | iptr | ) | [static] |
Definition at line 386 of file CatalogTables.cxx.
References INDEX::indName_.
Referenced by TableImpl::printInfo().
Here is the caller graph for this function:
int CatalogTableINDEX::getNoOfBuckets | ( | void * | iptr | ) | [static] |
Definition at line 375 of file CatalogTables.cxx.
References INDEX::noOfBuckets_.
Referenced by DatabaseManagerImpl::openTable(), and DatabaseManagerImpl::printIndexInfo().
00376 { 00377 INDEX *index = (INDEX*)iptr; 00378 return index->noOfBuckets_; 00379 }
Here is the caller graph for this function:
int CatalogTableINDEX::getNumIndexes | ( | void * | tblPtr | ) |
Definition at line 322 of file CatalogTables.cxx.
References Chunk::getIterator(), Database::getSystemDatabaseChunk(), IndexTableId, and ChunkIterator::nextElement().
Referenced by DatabaseManagerImpl::dropTable(), and DatabaseManagerImpl::openTable().
00323 { 00324 Chunk *fChunk = systemDatabase_->getSystemDatabaseChunk(IndexTableId); 00325 ChunkIterator iter = fChunk->getIterator(); 00326 void *iptr = NULL; 00327 int numIndex =0; 00328 while (NULL != (iptr = iter.nextElement())) 00329 { 00330 if (((INDEX*)iptr)->tblPtr_ == tptr) numIndex++; 00331 } 00332 return numIndex; 00333 }
Here is the call graph for this function:
Here is the caller graph for this function:
int CatalogTableINDEX::getUnique | ( | void * | iptr | ) | [static] |
Definition at line 381 of file CatalogTables.cxx.
References INDEX::isUnique_.
Referenced by DatabaseManagerImpl::openTable(), and DatabaseManagerImpl::printIndexInfo().
Here is the caller graph for this function:
DbRetVal CatalogTableINDEX::insert | ( | const char * | name, | |
void * | tblPtr, | |||
int | numFlds, | |||
bool | isUnique, | |||
void * | chunk, | |||
int | bucketSize, | |||
void * | hChunk, | |||
void *& | tupleptr | |||
) |
Definition at line 224 of file CatalogTables.cxx.
References Chunk::allocate(), INDEX::chunkPtr_, DM_SystemDatabase, ErrAlready, Chunk::getIterator(), Database::getSystemDatabaseChunk(), hashIndex, INDEX::hashNodeChunk_, IndexTableId, INDEX::indexType_, INDEX::indName_, INDEX::isUnique_, ChunkIterator::nextElement(), INDEX::noOfBuckets_, INDEX::numFlds_, OK, printDebug, printError, INDEX::tblID_, and INDEX::tblPtr_.
00226 { 00227 Chunk *tChunk = systemDatabase_->getSystemDatabaseChunk(IndexTableId); 00228 ChunkIterator iter = tChunk->getIterator(); 00229 00230 //Checking for index having same name, proceed further only 00231 //if no such indexes are 00232 void *data = NULL; 00233 while ((data = iter.nextElement())!= NULL) 00234 { 00235 if (0 == strcmp(((INDEX*)data)->indName_, name)) 00236 { 00237 printError(ErrAlready, "Index with name \'%s\' already exists " 00238 "on the table \'%s\'.", name, ((TABLE *)tptr)->tblName_); 00239 return ErrAlready; 00240 } 00241 00242 } 00243 00244 DbRetVal rv =OK; 00245 tupleptr = tChunk->allocate(systemDatabase_, &rv); 00246 if (NULL == tupleptr) 00247 { 00248 printError(rv, 00249 "Could not allocate for INDEX catalog table"); 00250 return rv; 00251 } 00252 INDEX *indexInfo = (INDEX*)tupleptr; 00253 strcpy(indexInfo->indName_, name); 00254 indexInfo->tblID_ = -1; //Not used currently 00255 indexInfo->tblPtr_ = tptr; 00256 indexInfo->numFlds_ = numFlds; 00257 indexInfo->indexType_ = hashIndex; 00258 indexInfo->chunkPtr_ = chunk; 00259 indexInfo->hashNodeChunk_ = hChunk; 00260 indexInfo->noOfBuckets_ = bucketSize; 00261 indexInfo->isUnique_ = isUnique; 00262 printDebug(DM_SystemDatabase,"One Row inserted into INDEX %x %s",tupleptr, name); 00263 return OK; 00264 }
Here is the call graph for this function:
DbRetVal CatalogTableINDEX::remove | ( | const char * | name, | |
void *& | chunk, | |||
void *& | hchunk, | |||
void *& | iptr | |||
) |
Definition at line 266 of file CatalogTables.cxx.
References DM_SystemDatabase, ErrNotExists, Chunk::free(), Chunk::getIterator(), Database::getSystemDatabaseChunk(), IndexTableId, ChunkIterator::nextElement(), OK, printDebug, and printError.
00267 { 00268 Chunk *fChunk = systemDatabase_->getSystemDatabaseChunk(IndexTableId); 00269 ChunkIterator iter = fChunk->getIterator(); 00270 00271 void *data = NULL; 00272 while ((data = iter.nextElement())!= NULL) 00273 { 00274 if (0 == strcmp(((INDEX*)data)->indName_, name)) 00275 { 00276 //remove this element and store the tuple ptr 00277 //there will be only one row for this table(Primary key) 00278 chunk = (Chunk*) ((INDEX*)data)->chunkPtr_; 00279 hchunk = (Chunk*) ((INDEX*)data)->hashNodeChunk_; 00280 iptr = (void*) data; 00281 break; 00282 } 00283 } 00284 if (NULL != iptr) 00285 { 00286 fChunk->free(systemDatabase_, iptr); 00287 printDebug(DM_SystemDatabase,"One Row deleted from INDEX %x %s",iptr, name); 00288 } 00289 else 00290 { 00291 printError(ErrNotExists,"Index %s not exists in INDEX catalog table", name); 00292 return ErrNotExists; 00293 } 00294 return OK; 00295 }
Here is the call graph for this function: