#include <PoolDatabaseSchema.h>
Public Member Functions | |
void | addContainer (int id, const std::string &containerName, const std::string &className) |
void | create () |
void | decrementNumberOfObjects (int id) |
void | drop () |
bool | exists () |
bool | getContainerData (std::map< std::string, ContainerHeaderData > &destination) |
void | incrementNumberOfObjects (int id) |
void | init (PoolDbCache &dbCache) |
PoolContainerHeaderTable (coral::ISchema &dbSchema) | |
void | removeContainer (int id) |
void | updateNumberOfObjects (const std::map< int, unsigned int > &numberOfObjectsForContainerIds) |
virtual | ~PoolContainerHeaderTable () |
Static Public Member Functions | |
static std::string | baseMappingVersionColumn () |
static std::string | classNameColumn () |
static std::string | containerIdColumn () |
static std::string | containerNameColumn () |
static std::string | containerTypeColumn () |
static std::string | homogeneousContainerType () |
static std::string | numberOfDeletedObjectsColumn () |
static std::string | numberOfWrittenObjectsColumn () |
static std::string | tableName () |
static std::string | tableNameColumn () |
Private Attributes | |
PoolDbCache * | m_dbCache |
coral::ISchema & | m_schema |
Definition at line 126 of file PoolDatabaseSchema.h.
ora::PoolContainerHeaderTable::PoolContainerHeaderTable | ( | coral::ISchema & | dbSchema | ) | [explicit] |
Definition at line 458 of file PoolDatabaseSchema.cc.
ora::PoolContainerHeaderTable::~PoolContainerHeaderTable | ( | ) | [virtual] |
Definition at line 463 of file PoolDatabaseSchema.cc.
{ }
void ora::PoolContainerHeaderTable::addContainer | ( | int | id, |
const std::string & | containerName, | ||
const std::string & | className | ||
) | [virtual] |
if(!m_dbCache){ throwException("Container Table handle has not been initialized.","PoolContainerHeaderTable::addContainer"); } PoolDbCacheData& contData = m_dbCache->find( containerId );
unsigned int nobj = 0; coral::AttributeList dataToInsert; dataToInsert.extend<int>( containerIdColumn()); dataToInsert.extend<std::string>( containerNameColumn()); dataToInsert.extend<std::string>( classNameColumn()); dataToInsert.extend<std::string>( tableNameColumn()); dataToInsert.extend<std::string>( baseMappingVersionColumn()); dataToInsert.extend<unsigned int>( numberOfWrittenObjectsColumn()); dataToInsert.extend<unsigned int>( numberOfDeletedObjectsColumn()); dataToInsert[ containerIdColumn() ].data<int>() = containerId; dataToInsert[ containerNameColumn() ].data<std::string>() = containerName; dataToInsert[ classNameColumn() ].data<std::string>() = className; dataToInsert[ tableNameColumn() ].data<std::string>() = "-"; dataToInsert[ baseMappingVersionColumn() ].data<std::string>() = contData.m_mappingVersion; dataToInsert[ numberOfWrittenObjectsColumn() ].data<unsigned int>() = nobj; dataToInsert[ numberOfDeletedObjectsColumn() ].data<unsigned int>() = nobj; coral::ITable& containerTable = m_schema.tableHandle( tableName() ); containerTable.dataEditor().insertRow( dataToInsert );
Implements ora::IContainerHeaderTable.
Definition at line 517 of file PoolDatabaseSchema.cc.
References ora::throwException().
{ throwException( "Cannot create new Containers into POOL database.","PoolContainerHeaderTable::addContainer"); }
std::string ora::PoolContainerHeaderTable::baseMappingVersionColumn | ( | ) | [static] |
Definition at line 438 of file PoolDatabaseSchema.cc.
{ static std::string s_column("MAPPING_VERSION"); return s_column; }
std::string ora::PoolContainerHeaderTable::classNameColumn | ( | ) | [static] |
Definition at line 433 of file PoolDatabaseSchema.cc.
{ static std::string s_column("CLASS_NAME"); return s_column; }
std::string ora::PoolContainerHeaderTable::containerIdColumn | ( | ) | [static] |
Definition at line 412 of file PoolDatabaseSchema.cc.
Referenced by ora::PoolMappingSchema::getClassVersionListForContainer(), ora::PoolMappingSchema::getMappingVersionListForContainer(), and ora::PoolMappingSchema::selectMappingVersion().
{ static std::string s_column("CONTAINER_ID"); return s_column; }
std::string ora::PoolContainerHeaderTable::containerNameColumn | ( | ) | [static] |
Definition at line 418 of file PoolDatabaseSchema.cc.
Referenced by ora::PoolMappingSchema::getClassVersionListForContainer(), ora::PoolMappingSchema::getMappingVersionListForContainer(), and ora::PoolMappingSchema::selectMappingVersion().
{ static std::string s_column("CONTAINER_NAME"); return s_column; }
std::string ora::PoolContainerHeaderTable::containerTypeColumn | ( | ) | [static] |
Definition at line 423 of file PoolDatabaseSchema.cc.
{ static std::string s_column("CONTAINER_TYPE"); return s_column; }
void ora::PoolContainerHeaderTable::create | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 611 of file PoolDatabaseSchema.cc.
References ora::throwException().
{ if( m_schema.existsTable( tableName() )){ throwException( "POOL database container header table already exists in this schema.", "PoolContainerHeaderTable::create"); } throwException( "POOL database cannot be created.","PoolContainerHeaderTable::create"); }
void ora::PoolContainerHeaderTable::decrementNumberOfObjects | ( | int | id | ) | [virtual] |
Implements ora::IContainerHeaderTable.
Definition at line 566 of file PoolDatabaseSchema.cc.
References ora::throwException().
{ throwException( "Operation not supported into POOL database.","PoolContainerHeaderTable::decrementNumberOfObjects"); }
void ora::PoolContainerHeaderTable::drop | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 619 of file PoolDatabaseSchema.cc.
bool ora::PoolContainerHeaderTable::exists | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 607 of file PoolDatabaseSchema.cc.
bool ora::PoolContainerHeaderTable::getContainerData | ( | std::map< std::string, ContainerHeaderData > & | destination | ) | [virtual] |
Implements ora::IContainerHeaderTable.
Definition at line 392 of file OraDatabaseSchema.cc.
References className(), alignmentValidation::dest, o2o::query, and runTheMatrix::ret.
{ bool ret = false; coral::ITable& containerTable = m_schema.tableHandle( tableName() ); std::auto_ptr<coral::IQuery> query( containerTable.newQuery()); coral::AttributeList outputBuffer; outputBuffer.extend<int>( containerIdColumn() ); outputBuffer.extend<std::string>( containerNameColumn() ); outputBuffer.extend<std::string>( classNameColumn() ); outputBuffer.extend<unsigned int>( numberOfObjectsColumn() ); query->defineOutput( outputBuffer ); coral::ICursor& cursor = query->execute(); while ( cursor.next() ) { ret = true; const coral::AttributeList& row = cursor.currentRow(); int containerId = row[ containerIdColumn() ].data< int >(); std::string containerName = row[ containerNameColumn()].data< std::string >(); std::string className = row[ classNameColumn()].data< std::string >(); unsigned int numberOfObjects = row[ numberOfObjectsColumn()].data< unsigned int >(); dest.insert( std::make_pair( containerName, ContainerHeaderData( containerId, className, numberOfObjects ) )) ; } return ret; }
std::string ora::PoolContainerHeaderTable::homogeneousContainerType | ( | ) | [static] |
Definition at line 453 of file PoolDatabaseSchema.cc.
{ static std::string s_type("Homogeneous"); return s_type; }
void ora::PoolContainerHeaderTable::incrementNumberOfObjects | ( | int | id | ) | [virtual] |
Implements ora::IContainerHeaderTable.
Definition at line 562 of file PoolDatabaseSchema.cc.
References ora::throwException().
{ throwException( "Operation not supported into POOL database.","PoolContainerHeaderTable::incrementNumberOfObjects"); }
void ora::PoolContainerHeaderTable::init | ( | PoolDbCache & | dbCache | ) |
Definition at line 466 of file PoolDatabaseSchema.cc.
Referenced by ora::PoolDatabaseSchema::PoolDatabaseSchema().
{ m_dbCache = &dbCache; }
std::string ora::PoolContainerHeaderTable::numberOfDeletedObjectsColumn | ( | ) | [static] |
Definition at line 448 of file PoolDatabaseSchema.cc.
{ static std::string s_column("NUMBER_OF_DELETED_OBJECTS"); return s_column; }
std::string ora::PoolContainerHeaderTable::numberOfWrittenObjectsColumn | ( | ) | [static] |
Definition at line 443 of file PoolDatabaseSchema.cc.
{ static std::string s_column("NUMBER_OF_WRITTEN_OBJECTS"); return s_column; }
void ora::PoolContainerHeaderTable::removeContainer | ( | int | id | ) | [virtual] |
Implements ora::IContainerHeaderTable.
Definition at line 548 of file PoolDatabaseSchema.cc.
References ora::throwException().
{ if(!m_dbCache){ throwException("Container Table handle has not been initialized.","PoolContainerHeaderTable::removeContainer"); } m_dbCache->remove( id ); std::stringstream whereClause; whereClause << containerIdColumn() << "= :" <<containerIdColumn(); coral::AttributeList whereData; whereData.extend< int >( containerIdColumn() ); whereData.begin()->data< int >() = id + 1; //POOL starts counting from 1!; coral::ITable& containerTable = m_schema.tableHandle( tableName() ); containerTable.dataEditor().deleteRows(whereClause.str(),whereData); }
std::string ora::PoolContainerHeaderTable::tableName | ( | ) | [static] |
Definition at line 406 of file PoolDatabaseSchema.cc.
Referenced by ora::PoolMappingSchema::getClassVersionListForContainer(), ora::PoolMappingSchema::getMappingVersionListForContainer(), and ora::PoolMappingSchema::selectMappingVersion().
{ static std::string s_name("POOL_RSS_CONTAINERS"); return s_name; }
std::string ora::PoolContainerHeaderTable::tableNameColumn | ( | ) | [static] |
Definition at line 428 of file PoolDatabaseSchema.cc.
{ static std::string s_column("TABLE_NAME"); return s_column; }
void ora::PoolContainerHeaderTable::updateNumberOfObjects | ( | const std::map< int, unsigned int > & | numberOfObjectsForContainerIds | ) | [virtual] |
Implements ora::IContainerHeaderTable.
Definition at line 570 of file PoolDatabaseSchema.cc.
References ora::PoolDbCacheData::m_nobjWr, and ora::throwException().
{ if( numberOfObjectsForContainerIds.size() ){ if(!m_dbCache){ throwException("Container Table handle has not been initialized.","PoolContainerHeaderTable::updateNumberOfObjects"); } std::stringstream whereClause; whereClause << containerIdColumn() << " = :" <<containerIdColumn(); std::stringstream setClause; setClause << numberOfWrittenObjectsColumn()<< " = :"<<numberOfWrittenObjectsColumn(); setClause << " , "<< numberOfDeletedObjectsColumn()<< " = :"<<numberOfDeletedObjectsColumn(); coral::AttributeList updateData; updateData.extend<unsigned int>( numberOfWrittenObjectsColumn() ); updateData.extend<unsigned int>( numberOfDeletedObjectsColumn() ); updateData.extend<int>( containerIdColumn() ); coral::ITable& containerTable = m_schema.tableHandle( tableName() ); std::auto_ptr<coral::IBulkOperation> bulkUpdate( containerTable.dataEditor().bulkUpdateRows( setClause.str(), whereClause.str(), updateData,(int)numberOfObjectsForContainerIds.size()+1)); for( std::map<int,unsigned int>::const_iterator iCont = numberOfObjectsForContainerIds.begin(); iCont != numberOfObjectsForContainerIds.end(); ++iCont ){ PoolDbCacheData& contData = m_dbCache->find( iCont->first ); unsigned int nwrt = contData.m_nobjWr; unsigned int ndel = nwrt-iCont->second; updateData[containerIdColumn()].data<int>() = iCont->first + 1; //POOL starts counting from 1!; updateData[numberOfWrittenObjectsColumn()].data<unsigned int>() = nwrt; updateData[numberOfDeletedObjectsColumn()].data<unsigned int>() = ndel; bulkUpdate->processNextIteration(); } bulkUpdate->flush(); } }
Definition at line 154 of file PoolDatabaseSchema.h.
coral::ISchema& ora::PoolContainerHeaderTable::m_schema [private] |
Definition at line 153 of file PoolDatabaseSchema.h.