16 #ifndef ROOT7_RNTupleZip
17 #define ROOT7_RNTupleZip
30 namespace Experimental {
42 using Buffer_t = std::array<unsigned char, kMAXZIPBUF>;
62 auto cxLevel = compression % 100;
64 fnWriter(from, nbytes, 0);
69 unsigned int nZipBlocks = 1 + (nbytes - 1) / kMAXZIPBUF;
70 char *source =
const_cast<char *
>(
static_cast<const char *
>(from));
71 int szTarget = kMAXZIPBUF;
72 char *target =
reinterpret_cast<char *
>(
fZipBuffer->data());
74 int szRemaining = nbytes;
76 for (
unsigned int i = 0; i < nZipBlocks; ++i) {
77 int szSource = std::min(
static_cast<int>(kMAXZIPBUF), szRemaining);
78 R__zipMultipleAlgorithm(cxLevel, &szSource, source, &szTarget, target, &szOutBlock, cxAlgorithm);
80 if ((szOutBlock == 0) || (szOutBlock >= szSource)) {
82 fnWriter(from, nbytes, 0);
86 fnWriter(target, szOutBlock, szZipData);
87 szZipData += szOutBlock;
89 szRemaining -= szSource;
98 size_t operator() (
const void *from,
size_t nbytes,
int compression) {
102 auto cxLevel = compression % 100;
109 int szSource = nbytes;
110 char *source =
const_cast<char *
>(
static_cast<const char *
>(from));
111 int szTarget = nbytes;
112 char *target =
reinterpret_cast<char *
>(
fZipBuffer->data());
114 R__zipMultipleAlgorithm(cxLevel, &szSource, source, &szTarget, target, &szOut, cxAlgorithm);
116 if ((szOut > 0) && (
static_cast<unsigned int>(szOut) < nbytes))
136 using Buffer_t = std::array<unsigned char, kMAXZIPBUF>;
150 void operator() (
const void *from,
size_t nbytes,
size_t dataLen,
void *to) {
151 if (dataLen == nbytes) {
152 memcpy(to, from, nbytes);
157 unsigned char *source =
const_cast<unsigned char *
>(
static_cast<const unsigned char *
>(from));
158 unsigned char *target =
static_cast<unsigned char *
>(to);
159 int szRemaining = dataLen;
167 R__ASSERT(
static_cast<unsigned int>(szSource) <= nbytes);
168 R__ASSERT(
static_cast<unsigned int>(szTarget) <= dataLen);
171 R__unzip(&szSource, source, &szTarget, target, &unzipBytes);
176 szRemaining -= unzipBytes;
177 }
while (szRemaining > 0);
184 void operator() (
void *fromto,
size_t nbytes,
size_t dataLen) {