13 #include "CoralBase/Attribute.h"
14 #include "CoralBase/Blob.h"
19 m_objectType( objectType ),
22 m_schema( contSchema ),
24 m_relationalData( 0 ),
25 m_relationalBuffer( 0 ),
27 m_useCompression(
true ){
36 if( m_mapping.columnNames().size() == 0 ){
38 "BlobWriterBase::build");
41 m_dataElement = &dataElement;
42 std::string columnName = m_mapping.columnNames()[0];
43 m_columnIndex = relationalData.
addBlobData( columnName );
44 m_relationalData = &relationalData;
45 m_relationalBuffer = &operationBuffer;
46 m_blobWriter = m_schema.blobStreamingService();
49 "BlobWriterBase::::build");
51 if( m_schema.dbSession().schema().mainTable().schemaVersion()==
poolSchemaVersion() ) m_useCompression =
false;
56 if( ! m_dataElement ){
58 "BlobWriterBase::bindData");
60 void* dataElementAddress = m_dataElement->address( data );
61 coral::Attribute& relDataElement = m_relationalData->data()[ m_columnIndex ];
62 boost::shared_ptr<coral::Blob> blobData = m_blobWriter->write( dataElementAddress, m_objectType, m_useCompression );
63 m_relationalBuffer->storeBlob( blobData );
64 relDataElement.bind<coral::Blob>( *blobData );
79 return buildDataElement( dataElement, relationalData, relationalBuffer );
102 return buildDataElement( dataElement, relationalData, relationalBuffer );
117 m_objectType( objectType ),
118 m_mapping( mapping ),
120 m_schema( contSchema ),
122 m_relationalData( 0 ),
132 if( m_mapping.columnNames().size() == 0 ){
134 "BlobReader::build");
137 m_dataElement = &dataElement;
138 std::string columnName = m_mapping.columnNames()[0];
139 m_columnIndex = relationalData.
addBlobData( columnName );
140 m_relationalData = &relationalData;
141 m_blobReader = m_schema.blobStreamingService();
144 "BlobReader::build");
156 if( ! m_dataElement ){
160 void* dataElementAddress = m_dataElement->address( data );
161 coral::Attribute& relDataElement = m_relationalData->data()[ m_columnIndex ];
162 m_blobReader->read(relDataElement.data<coral::Blob>(), dataElementAddress, m_objectType );
171 m_objectType( objectType ),
172 m_mapping( mapping ),
173 m_schema( contSchema ){
180 return new BlobWriter( m_objectType, m_mapping, m_schema );
184 return new BlobUpdater( m_objectType, m_mapping, m_schema );
188 return new BlobReader( m_objectType, m_mapping, m_schema );
BlobWriterBase(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
virtual ~BlobWriterBase()
bool buildDataElement(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
void setRecordId(const std::vector< int > &identity)
virtual int addBlobData(const std::string &columnName)=0
BlobWriter(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
void bindData(const void *data)
bool build(DataElement &dataElement, IRelationalData &relationalData)
std::string poolSchemaVersion()
void update(int oid, const void *data)
Updates a data element.
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
bool build(DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer &operationBuffer)
BlobStreamer(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
BlobReader(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
IRelationalUpdater * newUpdater()
void read(void *data)
Reads a data element.
void setRecordId(const std::vector< int > &identity)
void setRecordId(const std::vector< int > &identity)
BlobUpdater(const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
IRelationalWriter * newWriter()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
IRelationalReader * newReader()
char data[epos_bytes_allocation]
void write(int oid, const void *data)
Writes a data element.