15 #include "RelationalAccess/IBulkOperation.h"
18 #include "CoralBase/Attribute.h"
33 void read(
const std::vector<int>& fullId,
void* destinationAddress){
35 std::vector<int> recordId;
36 for(
size_t i=1;
i<fullId.size();
i++) {
37 recordId.push_back( fullId[
i] );
78 for(
size_t i=0;
i<recIdCols.size();
i++ ){
80 m_query->addOrderId( recIdCols[ i ] );
85 throwException(
"Missing dictionary information for the range store base type of the container \"" +
87 "QVQueryMaker::build" );
95 if ( ! valueType ||!valueResolvedType ) {
96 throwException(
"Missing dictionary information for the content type of the container \"" +
98 "QVQueryMaker::build" );
103 throwException(
"Item for \"value_type\" not found in the mapping element",
104 "QVQueryMaker::build" );
113 coral::AttributeList& whereData = queryData.
whereData();
115 const std::vector<std::pair<std::string,std::string> >& theItems = selection.
items();
116 std::stringstream cond;
118 for(std::vector<std::pair<std::string,std::string> >::const_iterator iItem = theItems.begin();
119 iItem != theItems.end();
123 std::stringstream selColumn;
127 selColumn << colName<<
"_"<<
i;
128 whereData.extend<
int>(selColumn.str());
129 whereData[selColumn.str()].data<
int>() = selection.
data()[iItem->first].data<
int>();
132 if ( iElem == mappingElement.
end() ) {
133 throwException(
"Item for element \"value_type\" not found in the mapping element",
134 "QVQueryMaker::setQueryCondition" );
138 if(varName!=
"value_type"){
139 throwException(
"Item for element \"" + varName +
"\" not found in the mapping element",
140 "QVQueryMaker::setQueryCondition" );
145 if ( iInnerElem == valueTypeElement.
end() ) {
146 throwException(
"Item for element \"" + varName +
"\" not found in the mapping element",
147 "QVQueryMaker::setQueryCondition" );
149 colName = iInnerElem->second.columnNames()[0];
153 "QVQueryMaker::setQueryCondition" );
155 selColumn << colName<<
"_"<<
i;
156 whereData.extend(selColumn.str(),selection.
data()[iItem->first].specification().type());
157 whereData[selColumn.str()].setValueFromAddress(selection.
data()[iItem->first].addressOfData());
159 cond << colName <<
" " << iItem->second <<
" :"<<selColumn.str();
176 for(
size_t i=1;
i<fullId.size();
i++) {
182 coral::AttributeList& whereData =
m_query->whereData();
193 countQuery.addData( countColumn ,
typeid(
int) );
196 for(
size_t i=0;
i<recIdColumns.size();
i++){
197 countQuery.addWhereId( recIdColumns[
i] );
200 coral::AttributeList& whereData = countQuery.whereData();
203 for (
size_t i=0;
i<fullId.size();
i++ ){
204 whereData[ recIdColumns[
i] ].data<
int>() = fullId[
i+1];
208 countQuery.execute();
211 if( countQuery.nextCursorRow() ){
212 coral::AttributeList& row = countQuery.data();
213 result = row[countColumn].data<
int>();
226 if ( ! firstMember ) {
227 throwException(
"Could not retrieve the data member \"first\" of the class \"" +
228 iteratorDereferenceReturnType.
cppName() +
"\"",
229 "QVQueryMakerAndLoad::read" );
232 if ( ! secondMember ) {
233 throwException(
"Could not retrieve the data member \"second\" of the class \"" +
234 iteratorDereferenceReturnType.
cppName() +
"\"",
235 "QVQueryMakerAndLoad::read" );
241 while (
m_query->nextCursorRow() ){
245 void* positionData =
static_cast< char*
>( objectData ) + firstMember.
offset();
246 void* containerData =
static_cast< char*
>( objectData ) + secondMember.
offset();
249 coral::AttributeList& row =
m_query->data();
261 iteratorDereferenceReturnType.
destruct( objectData );
263 throwException(
"Could not insert a new element in the array type \"" +
265 "QVQueryMakerAndLoad::executeAndLoad" );
292 const std::vector<int>& fullId ):
294 m_reader( objectType, mapping, contSchema ),
306 bool load(
void* address)
const override {
354 m_objectType( objectType ),
357 m_writer(ClassUtils::
containerSubType(objectType,
"store_base_type"), mapping, contSchema ){
367 m_localElement.clear();
368 return m_writer.build( m_localElement, data, operationBuffer );
372 m_writer.setRecordId( identity );
379 "QueryableVectorWriter::write");
381 void* vectorAddress = m_offset->address( inputData );
383 m_objectType.functionMemberByName(
"load").invoke(vectorObj,
nullptr);
384 void* storageAddress =
nullptr;
386 m_objectType.functionMemberByName(
"storageAddress").invoke(vectorObj, &storAddObj);
387 m_writer.write( oid, storageAddress );
393 m_objectType( objectType ),
396 m_updater( ClassUtils::
containerSubType(objectType,
"store_base_type"), mapping, contSchema ){
406 m_localElement.clear();
407 return m_updater.build( m_localElement, relationalData, operationBuffer );
411 m_updater.setRecordId( identity );
418 "QueryableVectorUpdater::update");
420 void* vectorAddress = m_offset->address( data );
422 m_objectType.functionMemberByName(
"load").invoke(vectorObj,
nullptr);
423 void* storageAddress =
nullptr;
425 m_objectType.functionMemberByName(
"storageAddress").invoke(vectorObj, &storAddObj);
426 m_updater.update( oid, storageAddress );
432 m_objectType(objectType),
433 m_mapping( mapping ),
434 m_schema( contSchema ),
441 for(std::vector<boost::shared_ptr<IVectorLoader> >::const_iterator iL = m_loaders.begin();
442 iL != m_loaders.end(); ++iL ){
449 m_dataElement = &dataElement;
451 m_tmpIds.push_back(0);
460 m_tmpIds.resize( 1+identity.size() );
461 for(
size_t i=0;
i<identity.size();
i++){
462 m_tmpIds[1+
i] = identity[
i];
469 "QueryableVectorReader::read");
476 "QueryableVectorReader::read");
479 void* loaderAddress = loaderMemberElement.
address( destinationData );
482 boost::shared_ptr<IVectorLoader> loader(
new QueryableVectorLoader( m_objectType, m_mapping, m_schema, m_tmpIds ) );
483 m_loaders.push_back(loader);
485 *(
static_cast<boost::shared_ptr<IVectorLoader>*
>( loaderAddress )) = loader;
495 m_objectType( objectType ),
496 m_mapping( mapping ),
497 m_schema( contSchema ){
bool build(DataElement &offset, IRelationalData &relationalData)
tuple ret
prodAgent to be discontinued
void setQueryCondition(IRelationalData &queryData, const Selection &selection, MappingElement &mappingElement)
IRelationalWriter * newWriter()
virtual coral::AttributeList & whereData()=0
DataElement m_localElement
IRelationalReader * newReader()
IRelationalUpdater * newUpdater()
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
ContainerSchema & m_schema
size_t getSelectionCount(const Selection &selection) const override
void * address(const void *topLevelAddress) const
const coral::AttributeList & data() const
QueryableVectorUpdater(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
Constructor.
void executeAndLoad(void *address)
bool load(void *address) const override
static std::string variableNameFromUniqueString(const std::string &uniqueString)
QueryableVectorLoader(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema, const std::vector< int > &fullId)
bool build(DataElement &offset, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
bool isValid() const override
void write(int oid, const void *data)
Writes a data element.
~QueryableVectorStreamer()
ElementType elementType() const
MappingElement & m_mappingElement
QVQueryMaker m_queryMaker
void setRecordId(const std::vector< int > &identity)
MemberWithDict dataMemberByName(std::string const &) const
virtual ~QueryableVectorReader()
virtual std::string & whereClause()=0
void read(const std::vector< int > &fullId, void *destinationAddress)
std::string cppName() const
std::auto_ptr< IArrayHandler > m_arrayHandler
std::vector< int > m_recordId
std::vector< std::string > recordIdColumns() const
edm::TypeWithDict containerSubType(const edm::TypeWithDict &typ, const std::string &subTypeName)
virtual ~QueryableVectorLoader()
static std::string indexVariable()
std::string posColumn() const
static std::string elementTypeAsString(ElementType elementType)
Converts the enumeration type to a string.
static IArrayHandler * newArrayHandler(const edm::TypeWithDict &arrayType)
QVQueryMaker(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
size_t selectionCount(const std::vector< int > &fullId, const Selection &selection)
edm::TypeWithDict m_objectType
void update(int oid, const void *data)
Updates a data element.
iterator find(const std::string &key)
Retrieves a sub-element.
std::string pkColumn() const
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
QVReader(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
const std::vector< std::string > & columnNames() const
DataElement & addChild(size_t declaringScopeOffset, size_toffset)
void read(void *address)
Reads a data element.
edm::TypeWithDict m_objectType
std::auto_ptr< SelectOperation > m_query
std::vector< int > m_identity
void setRecordId(const std::vector< int > &identity)
bool loadSelection(const Selection &selection, void *address) const override
DataElement m_localElement
IRelationalReader * newReader(const edm::TypeWithDict &dataType, MappingElement &dataMapping)
void read(void *address)
Reads a data element.
void setRecordId(const std::vector< int > &identity)
void destruct(void *address, bool dealloc=true) const
QueryableVectorWriter(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
Constructor.
QueryableVectorStreamer(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
coral::ISchema & storageSchema()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
void select(const std::vector< int > &fullId, const Selection &selection)
iterator end()
Returns an iterator in the end of the sequence.
void invalidate() override
edm::TypeWithDict containerValueType(const edm::TypeWithDict &typ)
void setRecordId(const std::vector< int > &identity)
const std::string & tableName() const
ObjectWithDict construct() const
const std::vector< std::pair< std::string, std::string > > & items() const
QueryableVectorReader(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
Constructor.
std::auto_ptr< IRelationalReader > m_dataReader
bool build(DataElement &offset, IRelationalData &relationalData)
bool build(DataElement &offset, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
virtual ~QueryableVectorUpdater()
virtual ~QueryableVectorWriter()