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;
52 if (cxLevel == 0 || nbytes == 0) {
53 memcpy(to, from, nbytes);
58 const auto blocks = ROOT::Internal::GetZipBlocks(nbytes);
59 const unsigned int nZipBlocks = blocks.fNBlocks;
60 const int szBlock = blocks.fBlockSize;
61 const char *source =
static_cast<const char *
>(from);
62 int szTarget = nbytes;
63 char *
target =
reinterpret_cast<char *
>(to);
65 int szRemaining = nbytes;
67 for (
unsigned int i = 0; i < nZipBlocks; ++i) {
68 int szSource = std::min(szBlock, szRemaining);
69 R__zipMultipleAlgorithm(cxLevel, &szSource, source, &szTarget,
target, &szOutBlock, cxAlgorithm);
71 if ((szOutBlock == 0) || (szOutBlock >= szSource)) {
73 memcpy(to, from, nbytes);
77 szZipData += szOutBlock;
80 szRemaining -= szSource;
107 static void Unzip(
const void *from,
size_t nbytes,
size_t dataLen,
void *to)
109 if (dataLen == nbytes) {
110 memcpy(to, from, nbytes);
115 const unsigned char *source =
static_cast<const unsigned char *
>(from);
116 unsigned char *
target =
static_cast<unsigned char *
>(to);
117 size_t szRemainingLen = dataLen;
118 size_t szRemainingNbytes = nbytes;
120 if (
R__unlikely(szRemainingNbytes < ROOT::Internal::kZipHeaderSize)) {
125 int retval = R__unzip_header(&szSource, source, &szTarget);
126 if (
R__unlikely(!((retval == 0) && (szSource > 0) && (szTarget > szSource) &&
127 (
static_cast<unsigned int>(szSource) <= szRemainingNbytes) &&
128 (
static_cast<unsigned int>(szTarget) <= szRemainingLen)))) {
133 R__unzip(&szSource, source, &szTarget,
target, &unzipBytes);
136 std::to_string(szTarget) +
", got: " + std::to_string(unzipBytes) +
")"));
141 szRemainingNbytes -= szSource;
142 szRemainingLen -= unzipBytes;
143 }
while (szRemainingLen > 0);
145 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.
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
Helper class to compress data blocks in the ROOT compression frame format.
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
Helper class to uncompress data blocks in the ROOT compression frame format.
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.