|
ATLAS Offline Software
|
Go to the documentation of this file.
11 #include "CoralBase/Blob.h"
21 uLongf comprLen = compressBound(strlen(in));
23 blob.resize(comprLen);
24 unsigned char*
ptr =
static_cast<unsigned char*
>(
blob.startingAddress());
25 compress(
ptr, &comprLen,
reinterpret_cast<const unsigned char*
>(in), strlen(in));
26 blob.resize(comprLen);
40 TMemFile
fout(
"buffer",
"recreate");
42 tree->CloneTree(-1,
"fast")->Write();
44 uLongf comprLen =
fout.GetSize();
45 unsigned char *
buffer =
new unsigned char[comprLen];
48 blob.resize(comprLen);
49 char*
ptr =
reinterpret_cast<char*
>(
blob.startingAddress());
62 uLongf uncompLen = 50000;
63 std::unique_ptr<unsigned char[]> uncompBuf(
new unsigned char[uncompLen+1]);
66 actualLen = uncompLen;
67 int res(uncompress(uncompBuf.get(), &actualLen,
reinterpret_cast<const unsigned char*
>(
blob.startingAddress()),
static_cast<uLongf
>(
blob.size())));
68 if(
res == Z_OK )
break;
69 if(
res == Z_BUF_ERROR) {
71 std::cout <<
"ATTENTION: Increasing buffer to " << uncompLen << std::endl;
72 uncompBuf.reset(
new unsigned char[uncompLen+1]);
79 uncompBuf.get()[actualLen]=0;
80 out = std::move(uncompBuf);
86 std::unique_ptr<unsigned char[]> bf {};
89 const char* cstring =
reinterpret_cast<const char*
>(bf.get());
90 out.assign(cstring, len);
101 std::cout <<
"ATTENTION: Cannot unpack Blob object as JSON!" << std::endl;
108 const char* cstring =
reinterpret_cast<const char*
>(
blob.startingAddress());
110 sb.assign(cstring,
blob.size());
112 TMemFile
f(
"buffer",
reinterpret_cast<char*
>(bdata.data()), bdata.size());
114 f.GetObject(
"tree",
t);
void compress(const AmgSymMatrix(N) &covMatrix, std::vector< float > &vec)
bool compressBlob(const char *, coral::Blob &)
bool readBlobAsJson(const coral::Blob &, nlohmann::json &)
bool writeBlobFromTTree(TTree *, coral::Blob &)
std::vector< unsigned char > base64_decode(const std::string &)
bool readBlobAsString(const coral::Blob &, std::string &)
std::pair< std::vector< unsigned int >, bool > res
bool uncompressBlob(const coral::Blob &, std::unique_ptr< unsigned char[]> &, unsigned long &)
bool readBlobAsTTree(const coral::Blob &, std::unique_ptr< TTree > &)
std::string base64_encode(const unsigned char *, unsigned int)
bool writeBlobFromJson(const nlohmann::json &, coral::Blob &)
bool writeBlobFromString(const std::string_view, coral::Blob &)