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)>;
51 return [=](
const void *
b,
size_t n,
size_t o) { memcpy(
dest + o,
b,
n); };
63 size_t Zip(
const void *from,
size_t nbytes,
int compression,
Writer_t fnWriter)
67 auto cxLevel = compression % 100;
69 fnWriter(from, nbytes, 0);
74 unsigned int nZipBlocks = 1 + (nbytes - 1) / kMAXZIPBUF;
75 char *source =
const_cast<char *
>(
static_cast<const char *
>(from));
76 int szTarget = kMAXZIPBUF;
79 int szRemaining = nbytes;
81 for (
unsigned int i = 0; i < nZipBlocks; ++i) {
82 int szSource = std::min(
static_cast<int>(kMAXZIPBUF), szRemaining);
83 R__zipMultipleAlgorithm(cxLevel, &szSource, source, &szTarget,
target, &szOutBlock, cxAlgorithm);
85 if ((szOutBlock == 0) || (szOutBlock >= szSource)) {
87 fnWriter(from, nbytes, 0);
91 fnWriter(
target, szOutBlock, szZipData);
92 szZipData += szOutBlock;
94 szRemaining -= szSource;
103 size_t Zip(
const void *from,
size_t nbytes,
int compression)
108 auto cxLevel = compression % 100;
115 int szSource = nbytes;
116 char *source =
const_cast<char *
>(
static_cast<const char *
>(from));
117 int szTarget = nbytes;
120 R__zipMultipleAlgorithm(cxLevel, &szSource, source, &szTarget,
target, &szOut, cxAlgorithm);
122 if ((szOut > 0) && (
static_cast<unsigned int>(szOut) < nbytes))
130 static std::size_t
Zip(
const void *from, std::size_t nbytes,
int compression,
void *to)
134 auto cxLevel = compression % 100;
136 memcpy(to, from, nbytes);
141 unsigned int nZipBlocks = 1 + (nbytes - 1) / kMAXZIPBUF;
142 char *source =
const_cast<char *
>(
static_cast<const char *
>(from));
143 int szTarget = nbytes;
144 char *
target =
reinterpret_cast<char *
>(to);
146 int szRemaining = nbytes;
147 size_t szZipData = 0;
148 for (
unsigned int i = 0; i < nZipBlocks; ++i) {
149 int szSource = std::min(
static_cast<int>(kMAXZIPBUF), szRemaining);
150 R__zipMultipleAlgorithm(cxLevel, &szSource, source, &szTarget,
target, &szOutBlock, cxAlgorithm);
152 if ((szOutBlock == 0) || (szOutBlock >= szSource)) {
154 memcpy(to, from, nbytes);
158 szZipData += szOutBlock;
161 szRemaining -= szSource;
180 using Buffer_t = std::array<unsigned char, kMAXZIPBUF>;
194 static void Unzip(
const void *from,
size_t nbytes,
size_t dataLen,
void *to)
196 if (dataLen == nbytes) {
197 memcpy(to, from, nbytes);
202 unsigned char *source =
const_cast<unsigned char *
>(
static_cast<const unsigned char *
>(from));
203 unsigned char *
target =
static_cast<unsigned char *
>(to);
204 int szRemaining = dataLen;
212 R__ASSERT(
static_cast<unsigned int>(szSource) <= nbytes);
213 R__ASSERT(
static_cast<unsigned int>(szTarget) <= dataLen);
221 szRemaining -= unzipBytes;
222 }
while (szRemaining > 0);
229 void Unzip(
void *fromto,
size_t nbytes,
size_t dataLen)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
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.
size_t Zip(const void *from, size_t nbytes, int compression)
Returns the size of the compressed data block.
RNTupleCompressor & operator=(const RNTupleCompressor &other)=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.
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 ...
static Writer_t MakeMemCopyWriter(unsigned char *dest)
std::unique_ptr< Buffer_t > fZipBuffer
RNTupleCompressor & operator=(RNTupleCompressor &&other)=default
RNTupleCompressor(const RNTupleCompressor &other)=delete
size_t Zip(const void *from, size_t nbytes, int compression, Writer_t fnWriter)
Returns the size of the compressed data.
RNTupleCompressor(RNTupleCompressor &&other)=default
std::array< unsigned char, kMAXZIPBUF > Buffer_t
static constexpr size_t kMaxSingleBlock
Helper class to uncompress data blocks in the ROOT compression frame format.
RNTupleDecompressor & operator=(RNTupleDecompressor &&other)=default
RNTupleDecompressor(const RNTupleDecompressor &other)=delete
std::unique_ptr< Buffer_t > fUnzipBuffer
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.
void Unzip(void *fromto, size_t nbytes, size_t dataLen)
In-place decompression via unzip buffer.
RNTupleDecompressor & operator=(const RNTupleDecompressor &other)=delete
std::array< unsigned char, kMAXZIPBUF > Buffer_t
RNTupleDecompressor(RNTupleDecompressor &&other)=default
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 convention used.