#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) |
bool | lockContainer (int id, ContainerHeaderData &destination) |
std::string | name () |
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 |
Definition at line 125 of file PoolDatabaseSchema.h.
ora::PoolContainerHeaderTable::PoolContainerHeaderTable | ( | coral::ISchema & | dbSchema | ) | [explicit] |
Definition at line 483 of file PoolDatabaseSchema.cc.
: IContainerHeaderTable(dbSchema), m_dbCache( 0 ){ }
ora::PoolContainerHeaderTable::~PoolContainerHeaderTable | ( | ) | [virtual] |
Definition at line 488 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 = schema().tableHandle( tableName() ); containerTable.dataEditor().insertRow( dataToInsert );
Implements ora::IContainerHeaderTable.
Definition at line 542 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 463 of file PoolDatabaseSchema.cc.
{ static std::string s_column("MAPPING_VERSION"); return s_column; }
std::string ora::PoolContainerHeaderTable::classNameColumn | ( | ) | [static] |
Definition at line 458 of file PoolDatabaseSchema.cc.
{ static std::string s_column("CLASS_NAME"); return s_column; }
std::string ora::PoolContainerHeaderTable::containerIdColumn | ( | ) | [static] |
Definition at line 437 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 443 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 448 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 670 of file PoolDatabaseSchema.cc.
References python::IdGenerator::schema, and ora::throwException().
{ if( 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 621 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 678 of file PoolDatabaseSchema.cc.
References python::IdGenerator::schema.
bool ora::PoolContainerHeaderTable::exists | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 666 of file PoolDatabaseSchema.cc.
References python::IdGenerator::schema.
bool ora::PoolContainerHeaderTable::getContainerData | ( | std::map< std::string, ContainerHeaderData > & | destination | ) | [virtual] |
Implements ora::IContainerHeaderTable.
Definition at line 428 of file OraDatabaseSchema.cc.
References className(), alignCSCRings::dest, o2o::query, run_regression::ret, and python::IdGenerator::schema.
{ bool ret = false; coral::ITable& containerTable = 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 478 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 617 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 491 of file PoolDatabaseSchema.cc.
Referenced by ora::PoolDatabaseSchema::PoolDatabaseSchema().
{ m_dbCache = &dbCache; }
bool ora::PoolContainerHeaderTable::lockContainer | ( | int | id, |
ContainerHeaderData & | destination | ||
) | [virtual] |
Implements ora::IContainerHeaderTable.
Definition at line 587 of file PoolDatabaseSchema.cc.
References ora::ContainerHeaderData::className, errorMatrix2Lands_multiChannel::id, ora::ContainerHeaderData::id, ora::ContainerHeaderData::numberOfObjects, o2o::query, run_regression::ret, and python::IdGenerator::schema.
{ bool ret = false; coral::ITable& containerTable = schema().tableHandle( tableName() ); std::auto_ptr<coral::IQuery> query( containerTable.newQuery()); query->addToOutputList( classNameColumn() ); query->defineOutputType( classNameColumn() , coral::AttributeSpecification::typeNameForType<std::string>() ); query->addToOutputList( numberOfWrittenObjectsColumn() ); query->defineOutputType( numberOfWrittenObjectsColumn(), coral::AttributeSpecification::typeNameForType<unsigned int>() ); query->addToOutputList( numberOfDeletedObjectsColumn() ); query->defineOutputType( numberOfDeletedObjectsColumn(), coral::AttributeSpecification::typeNameForType<unsigned int>() ); std::stringstream whereClause; whereClause << containerIdColumn() << "= :" <<containerIdColumn(); coral::AttributeList whereData; whereData.extend<int>( containerIdColumn() ); whereData.begin()->data<int>() = id +1 ; //POOL starts counting from 1!; query->setCondition( whereClause.str(), whereData ); query->setForUpdate(); coral::ICursor& cursor = query->execute(); if( cursor.next() ) { ret = true; const coral::AttributeList& row = cursor.currentRow(); dest.id = id; dest.className = row[ classNameColumn()].data< std::string >(); unsigned int numberOfWrittenObjects = row[ numberOfWrittenObjectsColumn()].data< unsigned int >(); unsigned int numberOfDeletedObjects = row[ numberOfDeletedObjectsColumn()].data< unsigned int >(); dest.numberOfObjects = numberOfWrittenObjects-numberOfDeletedObjects; } return ret; }
std::string ora::PoolContainerHeaderTable::name | ( | ) | [virtual] |
Implements ora::IDatabaseTable.
Definition at line 662 of file PoolDatabaseSchema.cc.
{ return tableName(); }
std::string ora::PoolContainerHeaderTable::numberOfDeletedObjectsColumn | ( | ) | [static] |
Definition at line 473 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 468 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 573 of file PoolDatabaseSchema.cc.
References python::IdGenerator::schema, and 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 = schema().tableHandle( tableName() ); containerTable.dataEditor().deleteRows(whereClause.str(),whereData); }
std::string ora::PoolContainerHeaderTable::tableName | ( | ) | [static] |
Definition at line 431 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 453 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 625 of file PoolDatabaseSchema.cc.
References ora::PoolDbCacheData::m_nobjWr, python::IdGenerator::schema, 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 = 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.