Public Member Functions | |
bool | build () |
QVReader (const Reflex::Type &objectType, MappingElement &mapping, ContainerSchema &contSchema) | |
void | read (void *address) |
void | select (const std::vector< int > &fullId) |
void | select (const std::vector< int > &fullId, const Selection &selection) |
size_t | selectionCount (const std::vector< int > &fullId, const Selection &selection) |
void | setQueryCondition (IRelationalData &queryData, const Selection &selection, MappingElement &mappingElement) |
~QVReader () | |
Private Attributes | |
std::auto_ptr< IArrayHandler > | m_arrayHandler |
std::auto_ptr< IRelationalReader > | m_dataReader |
DataElement | m_localElement |
MappingElement & | m_mappingElement |
Reflex::Type | m_objectType |
int | m_oid |
std::auto_ptr< SelectOperation > | m_query |
std::vector< int > | m_recordId |
ContainerSchema & | m_schema |
Definition at line 21 of file QueryableVectorStreamer.cc.
ora::QVReader::QVReader | ( | const Reflex::Type & | objectType, |
MappingElement & | mapping, | ||
ContainerSchema & | contSchema | ||
) | [inline] |
Definition at line 23 of file QueryableVectorStreamer.cc.
{ }
ora::QVReader::~QVReader | ( | ) | [inline] |
Definition at line 35 of file QueryableVectorStreamer.cc.
{
bool ora::QVReader::build | ( | ) | [inline] |
Definition at line 38 of file QueryableVectorStreamer.cc.
Referenced by ora::RelationalVectorLoader::load(), and ora::RelationalVectorLoader::loadSelection().
{ m_query->addId( recIdCols[ i ] ); m_query->addOrderId( recIdCols[ i ] ); } 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) + "\"", "QueryableVectorReadBuffer::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) + "\"", "QueryableVectorReadBuffer::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", "QueryableVectorReadBuffer::build" ); } m_dataReader.reset( streamerFactory.newReader( valueResolvedType, iMe->second ) ); m_dataReader->build( m_localElement, *m_query ); return true; }
void ora::QVReader::read | ( | void * | address | ) | [inline] |
Definition at line 212 of file QueryableVectorStreamer.cc.
References ora::throwException().
Referenced by ora::RelationalVectorLoader::load(), and ora::RelationalVectorLoader::loadSelection().
{ throwException("The reader has not been built.", "QVReader::read"); } Reflex::Type iteratorDereferenceReturnType = m_arrayHandler->iteratorReturnType(); Reflex::Member firstMember = iteratorDereferenceReturnType.MemberByName( "first" ); if ( ! firstMember ) { throwException( "Could not retrieve the data member \"first\" of the class \"" + iteratorDereferenceReturnType.Name(Reflex::SCOPED) + "\"", "QueryableVectorReadBuffer::read" ); } Reflex::Member secondMember = iteratorDereferenceReturnType.MemberByName( "second" ); if ( ! secondMember ) { throwException( "Could not retrieve the data member \"second\" of the class \"" + iteratorDereferenceReturnType.Name(Reflex::SCOPED) + "\"", "QueryableVectorReadBuffer::read" ); } m_arrayHandler->clear( address ); unsigned int i=0; while ( m_query->nextCursorRow() ){ // Create a new element for the array void* objectData = iteratorDereferenceReturnType.Construct().Address(); void* positionData = static_cast< char* >( objectData ) + firstMember.Offset(); void* containerData = static_cast< char* >( objectData ) + secondMember.Offset(); m_recordId[m_recordId.size()-1] = (int)i; coral::AttributeList& row = m_query->data(); *(size_t*)positionData = (size_t)(row[m_mappingElement.posColumn()].data<int>()); m_dataReader->setRecordId( m_recordId ); m_dataReader->select( m_oid ); m_dataReader->read( containerData ); size_t prevSize = m_arrayHandler->size( address ); m_arrayHandler->appendNewElement( address, objectData ); bool inserted = m_arrayHandler->size( address )>prevSize; iteratorDereferenceReturnType.Destruct( objectData ); if ( !inserted ) { throwException( "Could not insert a new element in the array type \"" + m_objectType.Name(Reflex::SCOPED|Reflex::FINAL) + "\"", "QueryableVectorReadBuffer::read" ); } ++i; } m_arrayHandler->finalize( address ); }
void ora::QVReader::select | ( | const std::vector< int > & | fullId, |
const Selection & | selection | ||
) | [inline] |
Definition at line 161 of file QueryableVectorStreamer.cc.
References ora::throwException().
{ throwException("The reader has not been built.", "QVReader::select"); } m_oid = fullId[0]; m_recordId.clear(); for(size_t i=1;i<fullId.size();i++) { m_recordId.push_back( fullId[i] ); } // allocate the element for the index... m_recordId.push_back( 0 ); coral::AttributeList& whereData = m_query->whereData(); whereData[ m_mappingElement.pkColumn() ].data<int>() = fullId[0]; setQueryCondition( *m_query, selection, m_mappingElement ); m_query->execute(); }
void ora::QVReader::select | ( | const std::vector< int > & | fullId | ) | [inline] |
Definition at line 142 of file QueryableVectorStreamer.cc.
References ora::throwException().
Referenced by ora::RelationalVectorLoader::load(), and ora::RelationalVectorLoader::loadSelection().
{ throwException("The reader has not been built.", "QVReader::select"); } m_oid = fullId[0]; m_recordId.clear(); for(size_t i=1;i<fullId.size();i++) { m_recordId.push_back( fullId[i] ); } // allocate the element for the index... m_recordId.push_back( 0 ); coral::AttributeList& whereData = m_query->whereData(); whereData[ m_mappingElement.pkColumn() ].data<int>() = fullId[0]; m_query->execute(); }
size_t ora::QVReader::selectionCount | ( | const std::vector< int > & | fullId, |
const Selection & | selection | ||
) | [inline] |
Definition at line 183 of file QueryableVectorStreamer.cc.
Referenced by ora::RelationalVectorLoader::getSelectionCount().
{ countQuery.addWhereId( recIdColumns[i] ); } coral::AttributeList& whereData = countQuery.whereData(); // Fill-in the identities. whereData[ m_mappingElement.pkColumn() ].data<int>() = fullId[0]; for ( size_t i=0;i<fullId.size();i++ ){ whereData[ recIdColumns[i] ].data<int>() = fullId[i+1]; } setQueryCondition( countQuery, selection, m_mappingElement ); countQuery.execute(); size_t result = 0; if( countQuery.nextCursorRow() ){ coral::AttributeList& row = countQuery.data(); result = row[countColumn].data<int>(); } return result; }
void ora::QVReader::setQueryCondition | ( | IRelationalData & | queryData, |
const Selection & | selection, | ||
MappingElement & | mappingElement | ||
) | [inline] |
Definition at line 85 of file QueryableVectorStreamer.cc.
References ora::MappingElement::columnNames(), ora::MappingElement::elementType(), ora::MappingElement::elementTypeAsString(), ora::MappingElement::end(), ora::MappingElement::find(), i, ora::Selection::indexVariable(), ora::MappingElement::Object, ora::MappingElement::Primitive, ora::throwException(), and ora::Selection::variableNameFromUniqueString().
{ cond << " AND "; std::string varName = Selection::variableNameFromUniqueString(iItem->first); std::stringstream selColumn; std::string colName(""); if(varName == Selection::indexVariable()){ colName = mappingElement.columnNames()[mappingElement.columnNames().size()-1]; // the position column is the last selColumn << colName<<"_"<<i; whereData.extend<int>(selColumn.str()); whereData[selColumn.str()].data<int>() = selection.data()[iItem->first].data<int>(); } else { MappingElement::iterator iElem = mappingElement.find("value_type"); if ( iElem == mappingElement.end() ) { throwException( "Item for element \"value_type\" not found in the mapping element", "QueryableVectorReadBuffer::setQueryCondition" ); } MappingElement& valueTypeElement = iElem->second; if( valueTypeElement.elementType()==MappingElement::Primitive ){ if(varName!="value_type"){ throwException( "Item for element \"" + varName + "\" not found in the mapping element", "QueryableVectorReadBuffer::setQueryCondition" ); } colName = valueTypeElement.columnNames()[0]; } else if( valueTypeElement.elementType()==MappingElement::Object ){ MappingElement::iterator iInnerElem = valueTypeElement.find(varName); if ( iInnerElem == valueTypeElement.end() ) { throwException( "Item for element \"" + varName + "\" not found in the mapping element", "QueryableVectorReadBuffer::setQueryCondition" ); } colName = iInnerElem->second.columnNames()[0]; } else { throwException( "Queries cannot be executed on types mapped on "+ MappingElement::elementTypeAsString(valueTypeElement.elementType()), "QueryableVectorReadBuffer::setQueryCondition" ); } selColumn << colName<<"_"<<i; whereData.extend(selColumn.str(),selection.data()[iItem->first].specification().type()); whereData[selColumn.str()].setValueFromAddress(selection.data()[iItem->first].addressOfData()); } cond << colName << " " << iItem->second << " :"<<selColumn.str(); i++; selColumn.str(""); } // add the resulting condition clause queryData.whereClause()+=cond.str(); }
std::auto_ptr<IArrayHandler> ora::QVReader::m_arrayHandler [private] |
Definition at line 274 of file QueryableVectorStreamer.cc.
std::auto_ptr<IRelationalReader> ora::QVReader::m_dataReader [private] |
Definition at line 275 of file QueryableVectorStreamer.cc.
DataElement ora::QVReader::m_localElement [private] |
Definition at line 272 of file QueryableVectorStreamer.cc.
MappingElement& ora::QVReader::m_mappingElement [private] |
Definition at line 269 of file QueryableVectorStreamer.cc.
Reflex::Type ora::QVReader::m_objectType [private] |
Definition at line 268 of file QueryableVectorStreamer.cc.
int ora::QVReader::m_oid [private] |
Definition at line 276 of file QueryableVectorStreamer.cc.
std::auto_ptr<SelectOperation> ora::QVReader::m_query [private] |
Definition at line 273 of file QueryableVectorStreamer.cc.
std::vector<int> ora::QVReader::m_recordId [private] |
Definition at line 271 of file QueryableVectorStreamer.cc.
ContainerSchema& ora::QVReader::m_schema [private] |
Definition at line 270 of file QueryableVectorStreamer.cc.