13#ifndef ROOT_RNTupleZip
14#define ROOT_RNTupleZip
47 static std::size_t
Zip(
const void *from, std::size_t nbytes,
int compression,
void *to)
51 auto cxLevel = compression % 100;
53 memcpy(to, from, nbytes);
58 unsigned int nZipBlocks = 1 + (nbytes - 1) / kMAXZIPBUF;
59 const char *source =
static_cast<const char *
>(from);
60 int szTarget = nbytes;
61 char *target =
reinterpret_cast<char *
>(to);
63 int szRemaining = nbytes;
65 for (
unsigned int i = 0; i < nZipBlocks; ++i) {
66 int szSource = std::min(
static_cast<int>(kMAXZIPBUF), szRemaining);
67 R__zipMultipleAlgorithm(cxLevel, &szSource, source, &szTarget, target, &szOutBlock, cxAlgorithm);
69 if ((szOutBlock == 0) || (szOutBlock >= szSource)) {
71 memcpy(to, from, nbytes);
75 szZipData += szOutBlock;
78 szRemaining -= szSource;
105 static void Unzip(
const void *from,
size_t nbytes,
size_t dataLen,
void *to)
107 if (dataLen == nbytes) {
108 memcpy(to, from, nbytes);
113 const unsigned char *source =
static_cast<const unsigned char *
>(from);
114 unsigned char *target =
static_cast<unsigned char *
>(to);
115 size_t szRemainingLen = dataLen;
116 size_t szRemainingNbytes = nbytes;
118 if (
R__unlikely(szRemainingNbytes < ROOT::Internal::kZipHeaderSize)) {
123 int retval = R__unzip_header(&szSource, source, &szTarget);
124 if (
R__unlikely(!((retval == 0) && (szSource > 0) && (szTarget > szSource) &&
125 (
static_cast<unsigned int>(szSource) <= szRemainingNbytes) &&
126 (
static_cast<unsigned int>(szTarget) <= szRemainingLen)))) {
131 R__unzip(&szSource, source, &szTarget, target, &unzipBytes);
134 std::to_string(szTarget) +
", got: " + std::to_string(unzipBytes) +
")"));
139 szRemainingNbytes -= szSource;
140 szRemainingLen -= unzipBytes;
141 }
while (szRemainingLen > 0);
143 if (szRemainingNbytes > 0) {
#define R__unlikely(expr)
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
RNTupleCompressor()=delete
RNTupleDecompressor()=delete
RNTupleCompressor & operator=(const RNTupleCompressor &other)=delete
RNTupleCompressor()=delete
static std::size_t Zip(const void *from, std::size_t nbytes, int compression, void *to)
Returns the size of the compressed data, written into the provided output buffer.
RNTupleCompressor(RNTupleCompressor &&other)=delete
RNTupleCompressor(const RNTupleCompressor &other)=delete
RNTupleCompressor & operator=(RNTupleCompressor &&other)=delete
RNTupleDecompressor(RNTupleDecompressor &&other)=delete
RNTupleDecompressor()=delete
static void Unzip(const void *from, size_t nbytes, size_t dataLen, void *to)
The nbytes parameter provides the size ls of the from buffer.
RNTupleDecompressor(const RNTupleDecompressor &other)=delete
RNTupleDecompressor & operator=(const RNTupleDecompressor &other)=delete
RNTupleDecompressor & operator=(RNTupleDecompressor &&other)=delete
Base class for all ROOT issued exceptions.
EValues
Note: this is only temporarily a struct and will become a enum class hence the name convention used.