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) {
66 auto cxLevel = compression % 100;
68 fnWriter(from, nbytes, 0);
73 unsigned int nZipBlocks = 1 + (nbytes - 1) / kMAXZIPBUF;
74 char *source =
const_cast<char *
>(
static_cast<const char *
>(from));
75 int szTarget = kMAXZIPBUF;
78 int szRemaining = nbytes;
80 for (
unsigned int i = 0; i < nZipBlocks; ++i) {
81 int szSource = std::min(
static_cast<int>(kMAXZIPBUF), szRemaining);
82 R__zipMultipleAlgorithm(cxLevel, &szSource, source, &szTarget,
target, &szOutBlock, cxAlgorithm);
84 if ((szOutBlock == 0) || (szOutBlock >= szSource)) {
86 fnWriter(from, nbytes, 0);
90 fnWriter(
target, szOutBlock, szZipData);
91 szZipData += szOutBlock;
93 szRemaining -= szSource;
102 size_t Zip(
const void *from,
size_t nbytes,
int compression) {
106 auto cxLevel = compression % 100;
113 int szSource = nbytes;
114 char *source =
const_cast<char *
>(
static_cast<const char *
>(from));
115 int szTarget = nbytes;
118 R__zipMultipleAlgorithm(cxLevel, &szSource, source, &szTarget,
target, &szOut, cxAlgorithm);
120 if ((szOut > 0) && (
static_cast<unsigned int>(szOut) < nbytes))
128 static std::size_t
Zip(
const void *from, std::size_t nbytes,
int compression,
void *to) {
131 auto cxLevel = compression % 100;
133 memcpy(to, from, nbytes);
138 unsigned int nZipBlocks = 1 + (nbytes - 1) / kMAXZIPBUF;
139 char *source =
const_cast<char *
>(
static_cast<const char *
>(from));
140 int szTarget = nbytes;
141 char *
target =
reinterpret_cast<char *
>(to);
143 int szRemaining = nbytes;
144 size_t szZipData = 0;
145 for (
unsigned int i = 0; i < nZipBlocks; ++i) {
146 int szSource = std::min(
static_cast<int>(kMAXZIPBUF), szRemaining);
147 R__zipMultipleAlgorithm(cxLevel, &szSource, source, &szTarget,
target, &szOutBlock, cxAlgorithm);
149 if ((szOutBlock == 0) || (szOutBlock >= szSource)) {
151 memcpy(to, from, nbytes);
155 szZipData += szOutBlock;
157 szRemaining -= szSource;
177 using Buffer_t = std::array<unsigned char, kMAXZIPBUF>;
191 void Unzip(
const void *from,
size_t nbytes,
size_t dataLen,
void *to) {
192 if (dataLen == nbytes) {
193 memcpy(to, from, nbytes);
198 unsigned char *source =
const_cast<unsigned char *
>(
static_cast<const unsigned char *
>(from));
199 unsigned char *
target =
static_cast<unsigned char *
>(to);
200 int szRemaining = dataLen;
208 R__ASSERT(
static_cast<unsigned int>(szSource) <= nbytes);
209 R__ASSERT(
static_cast<unsigned int>(szTarget) <= dataLen);
217 szRemaining -= unzipBytes;
218 }
while (szRemaining > 0);
225 void Unzip(
void *fromto,
size_t nbytes,
size_t dataLen) {
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.
static constexpr size_t kMaxSingleBlock
std::array< unsigned char, kMAXZIPBUF > Buffer_t
std::unique_ptr< Buffer_t > fZipBuffer
RNTupleCompressor(RNTupleCompressor &&other)=default
static Writer_t MakeMemCopyWriter(unsigned char *dest)
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 ...
size_t Zip(const void *from, size_t nbytes, int compression)
Returns the size of the compressed data block.
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.
size_t Zip(const void *from, size_t nbytes, int compression, Writer_t fnWriter)
Returns the size of the compressed data.
RNTupleCompressor(const RNTupleCompressor &other)=delete
RNTupleCompressor & operator=(const RNTupleCompressor &other)=delete
Helper class to uncompress data blocks in the ROOT compression frame format.
RNTupleDecompressor & operator=(const RNTupleDecompressor &other)=delete
std::array< unsigned char, kMAXZIPBUF > Buffer_t
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.
std::unique_ptr< Buffer_t > fUnzipBuffer
RNTupleDecompressor(RNTupleDecompressor &&other)=default
RNTupleDecompressor(const RNTupleDecompressor &other)=delete
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
EValues
Note: this is only temporarily a struct and will become a enum class hence the name.
#define dest(otri, vertexptr)