#include <QueryableVectorStreamer.h>
Public Member Functions | |
IArrayHandler * | arrayHandler () |
bool | build (DataElement &offset, IRelationalData &relationalData, RelationalBuffer &operationBuffer) |
DataElement * | dataElement () |
MappingElement & | mapping () |
Reflex::Type & | objectType () |
QueryableVectorWriter (const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema) | |
Constructor. | |
void | setRecordId (const std::vector< int > &identity) |
void | write (int oid, const void *data) |
Writes a data element. | |
virtual | ~QueryableVectorWriter () |
Private Attributes | |
std::auto_ptr< IArrayHandler > | m_arrayHandler |
std::auto_ptr< IRelationalWriter > | m_dataWriter |
MultiRecordInsertOperation * | m_insertOperation |
DataElement | m_localElement |
MappingElement & | m_mappingElement |
Reflex::Type | m_objectType |
DataElement * | m_offset |
std::vector< int > | m_recordId |
ContainerSchema & | m_schema |
Definition at line 21 of file QueryableVectorStreamer.h.
ora::QueryableVectorWriter::QueryableVectorWriter | ( | const Reflex::Type & | objectType, |
MappingElement & | mapping, | ||
ContainerSchema & | contSchema | ||
) |
Constructor.
Definition at line 343 of file QueryableVectorStreamer.cc.
: m_objectType( objectType ), m_mappingElement( mapping ), m_schema( contSchema ), m_recordId(), m_localElement(), m_offset(0), m_insertOperation( 0 ), m_arrayHandler(){ }
ora::QueryableVectorWriter::~QueryableVectorWriter | ( | ) | [virtual] |
Definition at line 356 of file QueryableVectorStreamer.cc.
{ }
ora::IArrayHandler * ora::QueryableVectorWriter::arrayHandler | ( | ) | [inline] |
Definition at line 134 of file QueryableVectorStreamer.h.
{ return m_arrayHandler.get(); }
bool ora::QueryableVectorWriter::build | ( | DataElement & | offset, |
IRelationalData & | relationalData, | ||
RelationalBuffer & | operationBuffer | ||
) | [virtual] |
Implements ora::IRelationalWriter.
Definition at line 359 of file QueryableVectorStreamer.cc.
References ora::ClassUtils::containerSubType(), ora::ClassUtils::containerValueType(), ora::ArrayHandlerFactory::newArrayHandler(), ora::RelationalBuffer::newMultiRecordInsert(), ora::RelationalStreamerFactory::newWriter(), evf::evtn::offset(), ora::ClassUtils::resolvedType(), and ora::throwException().
{ m_localElement.clear(); m_recordId.clear(); // allocate for the index... m_recordId.push_back(0); RelationalStreamerFactory streamerFactory( m_schema ); // first open the insert on the extra table... m_insertOperation = &operationBuffer.newMultiRecordInsert( m_mappingElement.tableName() ); const std::vector<std::string>& columns = m_mappingElement.columnNames(); if( !columns.size() ){ throwException( "Id columns not found in the mapping.", "QueryableVectorWriter::build"); } for( size_t i=0; i<columns.size(); i++ ){ m_insertOperation->addId( columns[ i ] ); } m_offset = &offset; Reflex::Type storeBaseType = ClassUtils::containerSubType(m_objectType,"store_base_type"); if( !storeBaseType ){ throwException( "Missing dictionary information for the store base type of the container \"" + m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) + "\"", "QueryableVectorWriter::build" ); } m_arrayHandler.reset( ArrayHandlerFactory::newArrayHandler( storeBaseType ) ); Reflex::Type valueType = ClassUtils::containerValueType(m_objectType); Reflex::Type valueResolvedType = ClassUtils::resolvedType(valueType); // Check the component type if ( ! valueType || !valueResolvedType ) { throwException( "Missing dictionary information for the content type of the container \"" + m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) + "\"", "QueryableVectorWriter::build" ); } std::string valueName = valueType.Name(); // Retrieve the relevant mapping element MappingElement::iterator iMe = m_mappingElement.find( valueName ); if ( iMe == m_mappingElement.end() ) { throwException( "Item for \"" + valueName + "\" not found in the mapping element", "QueryableVectorWriter::build" ); } m_dataWriter.reset( streamerFactory.newWriter( valueResolvedType, iMe->second ) ); m_dataWriter->build( m_localElement, *m_insertOperation, operationBuffer ); return true; }
ora::DataElement * ora::QueryableVectorWriter::dataElement | ( | ) | [inline] |
Definition at line 128 of file QueryableVectorStreamer.h.
{ return m_offset; }
ora::MappingElement & ora::QueryableVectorWriter::mapping | ( | ) | [inline] |
Definition at line 122 of file QueryableVectorStreamer.h.
{ return m_mappingElement; }
Reflex::Type & ora::QueryableVectorWriter::objectType | ( | ) | [inline] |
Definition at line 116 of file QueryableVectorStreamer.h.
References m_objectType.
{ return m_objectType; }
void ora::QueryableVectorWriter::setRecordId | ( | const std::vector< int > & | identity | ) | [virtual] |
Implements ora::IRelationalWriter.
Definition at line 413 of file QueryableVectorStreamer.cc.
{ m_recordId.clear(); for(size_t i=0;i<identity.size();i++) { m_recordId.push_back( identity[i] ); } m_recordId.push_back( 0 ); }
void ora::QueryableVectorWriter::write | ( | int | oid, |
const void * | data | ||
) | [virtual] |
Writes a data element.
Implements ora::IRelationalWriter.
Definition at line 421 of file QueryableVectorStreamer.cc.
References i, ora::InsertCache::processNextIteration(), and ora::throwException().
{ if(!m_offset){ throwException("The streamer has not been built.", "QueryableVectorWriter::write"); } const std::vector<std::string>& columns = m_mappingElement.columnNames(); if( columns.size() != m_recordId.size()+1){ throwException( "Object id elements provided are not matching with the mapped id columns.", "QueryableVectorWriter::write"); } void* vectorAddress = m_offset->address( inputData ); Reflex::Object vectorObj( m_objectType,const_cast<void*>(vectorAddress)); vectorObj.Invoke("load",0); void* storageAddress = 0; vectorObj.Invoke("storageAddress",storageAddress); // Use the iterator to loop over the elements of the container. size_t containerSize = m_arrayHandler->size( storageAddress ); size_t persistentSize = m_arrayHandler->persistentSize( storageAddress ); if ( containerSize == 0 || containerSize < persistentSize ) return; size_t startElementIndex = m_arrayHandler->startElementIndex( storageAddress ); std::auto_ptr<IArrayIteratorHandler> iteratorHandler( m_arrayHandler->iterate( storageAddress ) ); const Reflex::Type& iteratorDereferenceReturnType = iteratorHandler->returnType(); Reflex::Member secondMember = iteratorDereferenceReturnType.MemberByName( "second" ); if ( ! secondMember ) { throwException( "Could not retrieve the data member \"second\" for the class \"" + iteratorDereferenceReturnType.Name(Reflex::SCOPED) + "\"", "QueryableVectorWriter::write" ); } InsertCache& bulkInsert = m_insertOperation->setUp( containerSize-startElementIndex+1 ); for ( size_t iIndex = startElementIndex; iIndex < containerSize; ++iIndex ) { m_recordId[m_recordId.size()-1] = iIndex; coral::AttributeList& dataBuff = m_insertOperation->data(); dataBuff[ columns[0] ].data<int>() = oid; for( size_t i = 1;i < columns.size(); i++ ){ dataBuff[ columns[i] ].data<int>() = m_recordId[i-1]; } void* objectReference = iteratorHandler->object(); void* componentData = static_cast< char* >( objectReference ) + secondMember.Offset(); m_dataWriter->setRecordId( m_recordId ); m_dataWriter->write( oid, componentData ); bulkInsert.processNextIteration(); // Increment the iterator iteratorHandler->increment(); } // execute the insert... m_arrayHandler->finalize( const_cast<void*>( storageAddress ) ); }
std::auto_ptr<IArrayHandler> ora::QueryableVectorWriter::m_arrayHandler [private] |
Definition at line 47 of file QueryableVectorStreamer.h.
std::auto_ptr<IRelationalWriter> ora::QueryableVectorWriter::m_dataWriter [private] |
Definition at line 48 of file QueryableVectorStreamer.h.
Definition at line 46 of file QueryableVectorStreamer.h.
Definition at line 42 of file QueryableVectorStreamer.h.
Definition at line 39 of file QueryableVectorStreamer.h.
Reflex::Type ora::QueryableVectorWriter::m_objectType [private] |
Definition at line 38 of file QueryableVectorStreamer.h.
Referenced by objectType().
DataElement* ora::QueryableVectorWriter::m_offset [private] |
Definition at line 45 of file QueryableVectorStreamer.h.
std::vector<int> ora::QueryableVectorWriter::m_recordId [private] |
Definition at line 41 of file QueryableVectorStreamer.h.
Definition at line 40 of file QueryableVectorStreamer.h.