13 #include "CoralBase/Blob.h"
31 boost::shared_ptr<coral::Blob>
write(
const void* addressOfInputData,
Reflex::Type const & classDictionary,
bool useCompression=
true );
33 void read(
const coral::Blob& blobData,
void* addressOfContainer,
Reflex::Type const & classDictionary );
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 std::type_info
const &
t = classDictionary.TypeInfo();
169 if (t==
typeid(std::vector<unsigned char>) )
return 1;
170 if (t==
typeid(std::vector<char>) )
return 2;
184 uLongf destLen = compressBound(isize);
186 boost::shared_ptr<coral::Blob> theBlob(
new coral::Blob(usize));
187 void * startingAddress = (
unsigned char*)(theBlob->startingAddress())+ m_offset;
188 int zerr = compress2( (
unsigned char*)(startingAddress), &destLen,
189 (
unsigned char*)(addr), isize,
191 if (zerr!=0)
edm::LogError(
"BlobStreamingService")<<
"Compression error " <<
zerr;
192 destLen+=
m_idsize +
sizeof(
unsigned long long);
193 theBlob->resize(destLen);
195 startingAddress = (
unsigned char*)(theBlob->startingAddress())+
m_idsize;
197 *
reinterpret_cast<unsigned long long*
>(startingAddress)=isize;
202 if (
size_t(blobIn.size()) <
m_offset)
return boost::shared_ptr<coral::Blob>(
new coral::Blob());
203 long long csize = blobIn.size() -
m_offset;
204 unsigned char const * startingAddress = (
unsigned char const*)(blobIn.startingAddress())+
m_idsize;
205 unsigned long long usize = *
reinterpret_cast<unsigned long long const*
>(startingAddress);
206 startingAddress +=
sizeof(
unsigned long long);
207 boost::shared_ptr<coral::Blob> theBlob(
new coral::Blob(usize));
208 uLongf destLen = usize;
209 int zerr = uncompress((
unsigned char *)(theBlob->startingAddress()), &destLen,
210 startingAddress, csize);
211 if (zerr!=0 || usize!=destLen)
212 edm::LogError(
"BlobStreamingService")<<
"uncompressing error " << zerr
213 <<
" original size was " << usize
214 <<
" new size is " << destLen;
static const size_t m_offset
static Variant findVariant(const void *address)
void read(const coral::Blob &blobData, void *addressOfContainer, Reflex::Type const &classDictionary)
Reads an object from a Blob and fills-in the container.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual ~BlobStreamingService()
boost::shared_ptr< coral::Blob > write(const void *addressOfInputData, Reflex::Type const &classDictionary, bool useCompression=true)
std::pair< unsigned long long, unsigned long long > uuid
static boost::shared_ptr< coral::Blob > expand(const coral::Blob &blobIn)
boost::shared_ptr< ora::IBlobStreamingService > rootService
static int isVectorChar(Reflex::Type const &classDictionary)
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)
static const size_t nVariants