13 #include "CoralBase/Blob.h"
23 namespace BlobStreaming {
40 boost::shared_ptr<coral::Blob>
write(
const void* addressOfInputData,
edm::TypeWithDict const & classDictionary,
bool useCompression=
true )
override;
42 void read(
const coral::Blob& blobData,
void* addressOfContainer,
edm::TypeWithDict const & classDictionary )
override;
47 typedef std::pair<unsigned long long, unsigned long long>
uuid;
61 static boost::shared_ptr<coral::Blob>
compress(
const void* addr,
size_t isize);
62 static boost::shared_ptr<coral::Blob>
expand(
const coral::Blob& blobIn);
75 boost::shared_ptr<coral::Blob> blobOut;
82 boost::shared_ptr<coral::Blob> buffer =
rootService->write(addressOfInputData, classDictionary);
84 blobOut =
compress(buffer->startingAddress(),buffer->size());
94 std::vector<unsigned char>
const &
v = *
reinterpret_cast< std::vector<unsigned char>
const *
> (addressOfInputData);
95 blobOut =
compress(&v.front(),v.size());
98 blobOut =
rootService->write(addressOfInputData,classDictionary);
104 if( useCompression ){
105 std::vector<char>
const &
v = *
reinterpret_cast<std::vector<char>
const *
> (addressOfInputData);
106 blobOut =
compress(&v.front(),v.size());
109 blobOut =
rootService->write(addressOfInputData,classDictionary);
126 rootService->read( blobData, addressOfContainer, classDictionary);
131 boost::shared_ptr<coral::Blob> blobIn =
expand(blobData);
132 rootService->read( *blobIn, addressOfContainer, classDictionary);
137 boost::shared_ptr<coral::Blob> blobIn =
expand(blobData);
147 std::vector<unsigned char> & v = *
reinterpret_cast< std::vector<unsigned char> *
> (addressOfContainer);
149 v.resize(blobIn->size());
150 std::memcpy(&v.front(),blobIn->startingAddress(),v.size());
155 std::vector<char> & v = *
reinterpret_cast< std::vector<char> *
> (addressOfContainer);
157 v.resize(blobIn->size());
158 std::memcpy(&v.front(),blobIn->startingAddress(),v.size());
177 if (classDictionary ==
typeid(std::vector<unsigned char>))
return 1;
178 if (classDictionary ==
typeid(std::vector<char>))
return 2;
192 uLongf destLen = compressBound(isize);
194 boost::shared_ptr<coral::Blob> theBlob(
new coral::Blob(usize));
195 void *
startingAddress = (
unsigned char*)(theBlob->startingAddress())+ m_offset;
196 int zerr = compress2( (
unsigned char*)(startingAddress), &destLen,
197 (
unsigned char*)(addr), isize,
199 if (zerr!=0)
edm::LogError(
"BlobStreamingService")<<
"Compression error " <<
zerr;
200 destLen+=
m_idsize +
sizeof(
unsigned long long);
201 theBlob->resize(destLen);
203 startingAddress = (
unsigned char*)(theBlob->startingAddress())+
m_idsize;
210 if (
size_t(blobIn.size()) <
m_offset)
return boost::shared_ptr<coral::Blob>(
new coral::Blob());
211 long long csize = blobIn.size() -
m_offset;
214 startingAddress +=
sizeof(
unsigned long long);
215 boost::shared_ptr<coral::Blob> theBlob(
new coral::Blob(usize));
216 uLongf destLen = usize;
217 int zerr = uncompress((
unsigned char *)(theBlob->startingAddress()), &destLen,
218 startingAddress, csize);
219 if (zerr!=0 || usize!=destLen)
220 edm::LogError(
"BlobStreamingService")<<
"uncompressing error " << zerr
221 <<
" original size was " << usize
222 <<
" new size is " << destLen;
static const size_t m_offset
static Variant findVariant(const void *address)
static int isVectorChar(edm::TypeWithDict const &classDictionary)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual ~BlobStreamingService()
std::pair< unsigned long long, unsigned long long > uuid
boost::shared_ptr< coral::Blob > write(const void *addressOfInputData, edm::TypeWithDict const &classDictionary, bool useCompression=true) override
static boost::shared_ptr< coral::Blob > expand(const coral::Blob &blobIn)
boost::shared_ptr< ora::IBlobStreamingService > rootService
static boost::shared_ptr< coral::Blob > compress(const void *addr, size_t isize)
Interface for a Streaming Service.
static uuid const variantIds[nVariants]
static const size_t m_idsize
#define DEFINE_EDM_PLUGIN(factory, type, name)
void read(const coral::Blob &blobData, void *addressOfContainer, edm::TypeWithDict const &classDictionary) override
Reads an object from a Blob and fills-in the container.
static const size_t nVariants