13 #include "CoralBase/Blob.h"
31 boost::shared_ptr<coral::Blob>
write(
const void* addressOfInputData,
edm::TypeWithDict const & classDictionary,
bool useCompression=
true )
override;
33 void read(
const coral::Blob& blobData,
void* addressOfContainer,
edm::TypeWithDict const & classDictionary )
override;
38 typedef std::pair<unsigned long long, unsigned long long>
uuid;
52 static boost::shared_ptr<coral::Blob>
compress(
const void* addr,
size_t isize);
53 static boost::shared_ptr<coral::Blob>
expand(
const coral::Blob& blobIn);
66 boost::shared_ptr<coral::Blob> blobOut;
73 boost::shared_ptr<coral::Blob> buffer =
rootService->write(addressOfInputData, classDictionary);
75 blobOut =
compress(buffer->startingAddress(),buffer->size());
85 std::vector<unsigned char>
const &
v = *
reinterpret_cast< std::vector<unsigned char>
const *
> (addressOfInputData);
86 blobOut =
compress(&v.front(),v.size());
89 blobOut =
rootService->write(addressOfInputData,classDictionary);
96 std::vector<char>
const &
v = *
reinterpret_cast<std::vector<char>
const *
> (addressOfInputData);
97 blobOut =
compress(&v.front(),v.size());
100 blobOut =
rootService->write(addressOfInputData,classDictionary);
117 rootService->read( blobData, addressOfContainer, classDictionary);
122 boost::shared_ptr<coral::Blob> blobIn =
expand(blobData);
123 rootService->read( *blobIn, addressOfContainer, classDictionary);
128 boost::shared_ptr<coral::Blob> blobIn =
expand(blobData);
138 std::vector<unsigned char> & v = *
reinterpret_cast< std::vector<unsigned char> *
> (addressOfContainer);
140 v.resize(blobIn->size());
141 std::memcpy(&v.front(),blobIn->startingAddress(),v.size());
146 std::vector<char> & v = *
reinterpret_cast< std::vector<char> *
> (addressOfContainer);
148 v.resize(blobIn->size());
149 std::memcpy(&v.front(),blobIn->startingAddress(),v.size());
168 if (classDictionary ==
typeid(std::vector<unsigned char>))
return 1;
169 if (classDictionary ==
typeid(std::vector<char>))
return 2;
183 uLongf destLen = compressBound(isize);
185 boost::shared_ptr<coral::Blob> theBlob(
new coral::Blob(usize));
186 void * startingAddress = (
unsigned char*)(theBlob->startingAddress())+ m_offset;
187 int zerr = compress2( (
unsigned char*)(startingAddress), &destLen,
188 (
unsigned char*)(addr), isize,
190 if (zerr!=0)
edm::LogError(
"BlobStreamingService")<<
"Compression error " <<
zerr;
191 destLen+=
m_idsize +
sizeof(
unsigned long long);
192 theBlob->resize(destLen);
194 startingAddress = (
unsigned char*)(theBlob->startingAddress())+
m_idsize;
196 *
reinterpret_cast<unsigned long long*
>(startingAddress)=isize;
201 if (
size_t(blobIn.size()) <
m_offset)
return boost::shared_ptr<coral::Blob>(
new coral::Blob());
202 long long csize = blobIn.size() -
m_offset;
203 unsigned char const * startingAddress = (
unsigned char const*)(blobIn.startingAddress())+
m_idsize;
204 unsigned long long usize = *
reinterpret_cast<unsigned long long const*
>(startingAddress);
205 startingAddress +=
sizeof(
unsigned long long);
206 boost::shared_ptr<coral::Blob> theBlob(
new coral::Blob(usize));
207 uLongf destLen = usize;
208 int zerr = uncompress((
unsigned char *)(theBlob->startingAddress()), &destLen,
209 startingAddress, csize);
210 if (zerr!=0 || usize!=destLen)
211 edm::LogError(
"BlobStreamingService")<<
"uncompressing error " << zerr
212 <<
" original size was " << usize
213 <<
" 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