Public Member Functions | |
size_t | flush () |
void | registerForWrite (int oid, const void *data) |
WriteBuffer (ContainerSchema &contSchema) | |
~WriteBuffer () | |
Private Attributes | |
std::vector< std::pair< int, const void * > > | m_buffer |
ContainerSchema & | m_contSchema |
Definition at line 20 of file DatabaseContainer.cc.
ora::WriteBuffer::WriteBuffer | ( | ContainerSchema & | contSchema | ) | [inline, explicit] |
Definition at line 22 of file DatabaseContainer.cc.
: m_buffer(), m_contSchema( contSchema ){ }
ora::WriteBuffer::~WriteBuffer | ( | ) | [inline] |
Definition at line 27 of file DatabaseContainer.cc.
{ }
size_t ora::WriteBuffer::flush | ( | ) | [inline] |
Definition at line 34 of file DatabaseContainer.cc.
References ora::InputRelationalData::addId(), ora::MappingElement::columnNames(), AlCaHLTBitMon_QueryRunRegistry::data, ora::MappingElement::end(), ora::MappingElement::find(), m_buffer, m_contSchema, ora::ContainerSchema::mapping(), ora::RelationalStreamerFactory::newWriter(), ora::ContainerSchema::storageSchema(), ora::MappingElement::tableName(), ora::throwException(), ora::MappingTree::topElement(), and ora::ContainerSchema::type().
{ size_t nobj = 0; if( m_buffer.size() ){ MappingElement& topLevelMapping = m_contSchema.mapping( true ).topElement(); RelationalBuffer operationBuffer( m_contSchema.storageSchema() ); InsertOperation* topLevelInsert = &operationBuffer.newInsert( topLevelMapping.tableName() ); topLevelInsert->addId( topLevelMapping.columnNames()[ 0 ] ); const Reflex::Type& type = m_contSchema.type(); MappingElement::iterator iMap = topLevelMapping.find( type.Name(Reflex::SCOPED) ); // the first inner mapping is the relevant... if( iMap == topLevelMapping.end()){ throwException("Could not find a mapping element for class \""+ type.Name(Reflex::SCOPED)+"\"", "WriteBuffer::flush"); } MappingElement& mapping = iMap->second; RelationalStreamerFactory streamerFactory( m_contSchema ); DataElement topLevelElement; std::auto_ptr<IRelationalWriter> writer( streamerFactory.newWriter( type, mapping ) ); writer->build( topLevelElement, *topLevelInsert, operationBuffer ); for( std::vector<std::pair<int, const void*> >::const_iterator iW = m_buffer.begin(); iW != m_buffer.end(); ++iW ){ int oid = iW->first; const void* data = iW->second; coral::AttributeList& dataBuff = topLevelInsert->data(); dataBuff.begin()->data<int>() = oid; writer->write( oid, data ); if( operationBuffer.flush() ) nobj++; } m_buffer.clear(); } return nobj; }
void ora::WriteBuffer::registerForWrite | ( | int | oid, |
const void * | data | ||
) | [inline] |
Definition at line 30 of file DatabaseContainer.cc.
References m_buffer.
std::vector<std::pair<int, const void*> > ora::WriteBuffer::m_buffer [private] |
Definition at line 71 of file DatabaseContainer.cc.
Referenced by flush(), and registerForWrite().
ContainerSchema& ora::WriteBuffer::m_contSchema [private] |
Definition at line 72 of file DatabaseContainer.cc.
Referenced by flush().