16#ifndef ROOT7_RNTupleZip
17#define ROOT7_RNTupleZip
30namespace Experimental {
42 using Buffer_t = std::array<unsigned char, kMAXZIPBUF>;
48 using Writer_t = std::function<
void(
const void *buffer,
size_t nbytes,
size_t offset)>;
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) {
typedef void((*Func_t)())
void R__unzip(Int_t *nin, UChar_t *bufin, Int_t *lout, char *bufout, Int_t *nout)
int R__unzip_header(Int_t *nin, UChar_t *bufin, Int_t *lout)
Helper class to compress data blocks in the ROOT compression frame format.
static constexpr size_t kMaxSingleBlock
const void * GetZipBuffer()
size_t operator()(const void *from, size_t nbytes, int compression, Writer_t fnWriter)
Returns the size of the compressed data.
std::array< unsigned char, kMAXZIPBUF > Buffer_t
std::unique_ptr< Buffer_t > fZipBuffer
RNTupleCompressor(RNTupleCompressor &&other)=default
std::function< void(const void *buffer, size_t nbytes, size_t offset)> Writer_t
Data might be overwritten, if a zipped block in the middle of a large input data stream turns out to ...
RNTupleCompressor(const RNTupleCompressor &other)=delete
RNTupleCompressor & operator=(const RNTupleCompressor &other)=delete
Helper class to uncompress data blocks in the ROOT compression frame format.
void operator()(const void *from, size_t nbytes, size_t dataLen, void *to)
The nbytes parameter provides the size ls of the from buffer.
RNTupleDecompressor & operator=(const RNTupleDecompressor &other)=delete
std::array< unsigned char, kMAXZIPBUF > Buffer_t
std::unique_ptr< Buffer_t > fUnzipBuffer
RNTupleDecompressor(RNTupleDecompressor &&other)=default
RNTupleDecompressor(const RNTupleDecompressor &other)=delete
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
EValues
Note: this is only temporarily a struct and will become a enum class hence the name.