From 4aeae98a1a080b66fb5b273f77dfc9776928a00c Mon Sep 17 00:00:00 2001 From: silverweed Date: Wed, 29 Jan 2025 15:25:51 +0100 Subject: [PATCH] [ntuple] RMiniFile: write StreamerInfo with the correct compression --- tree/ntuple/v7/inc/ROOT/RMiniFile.hxx | 5 +++-- tree/ntuple/v7/src/RMiniFile.cxx | 8 ++++---- tree/ntuple/v7/src/RPageStorageFile.cxx | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tree/ntuple/v7/inc/ROOT/RMiniFile.hxx b/tree/ntuple/v7/inc/ROOT/RMiniFile.hxx index 7a61e63d74b3a..a2424d0e99fb0 100644 --- a/tree/ntuple/v7/inc/ROOT/RMiniFile.hxx +++ b/tree/ntuple/v7/inc/ROOT/RMiniFile.hxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -202,7 +203,7 @@ private: /// Write the TList with the RNTuple key void WriteTFileKeysList(); /// Write the compressed streamer info record with the description of the RNTuple class - void WriteTFileStreamerInfo(); + void WriteTFileStreamerInfo(int compression); /// Last record in the file void WriteTFileFreeList(); /// For a bare file, which is necessarily written by a C file stream, write file header @@ -245,7 +246,7 @@ public: /// Ensures that the streamer info records passed as argument are written to the file void UpdateStreamerInfos(const RNTupleSerializer::StreamerInfoMap_t &streamerInfos); /// Writes the RNTuple key to the file so that the header and footer keys can be found - void Commit(); + void Commit(int compression = RCompressionSetting::EDefaults::kUseGeneralPurpose); }; } // namespace Internal diff --git a/tree/ntuple/v7/src/RMiniFile.cxx b/tree/ntuple/v7/src/RMiniFile.cxx index 4c43dce4c2b39..b11d6498d7571 100644 --- a/tree/ntuple/v7/src/RMiniFile.cxx +++ b/tree/ntuple/v7/src/RMiniFile.cxx @@ -1188,7 +1188,7 @@ void ROOT::Experimental::Internal::RNTupleFileWriter::UpdateStreamerInfos( fStreamerInfoMap.insert(streamerInfos.cbegin(), streamerInfos.cend()); } -void ROOT::Experimental::Internal::RNTupleFileWriter::Commit() +void ROOT::Experimental::Internal::RNTupleFileWriter::Commit(int compression) { if (fFileProper) { // Easy case, the ROOT file header and the RNTuple streaming is taken care of by TFile @@ -1220,7 +1220,7 @@ void ROOT::Experimental::Internal::RNTupleFileWriter::Commit() WriteTFileNTupleKey(); WriteTFileKeysList(); - WriteTFileStreamerInfo(); + WriteTFileStreamerInfo(compression); WriteTFileFreeList(); // Update header and TFile record @@ -1365,7 +1365,7 @@ void ROOT::Experimental::Internal::RNTupleFileWriter::WriteBareFileSkeleton(int fFileSimple.fKeyOffset = fFileSimple.fFilePos; } -void ROOT::Experimental::Internal::RNTupleFileWriter::WriteTFileStreamerInfo() +void ROOT::Experimental::Internal::RNTupleFileWriter::WriteTFileStreamerInfo(int compression) { // The streamer info record is a TList of TStreamerInfo object. We cannot use // RNTupleSerializer::SerializeStreamerInfos because that uses TBufferIO::WriteObject. @@ -1400,7 +1400,7 @@ void ROOT::Experimental::Internal::RNTupleFileWriter::WriteTFileStreamerInfo() RNTupleCompressor compressor; auto zipStreamerInfos = MakeUninitArray(lenPayload); - auto szZipStreamerInfos = compressor.Zip(bufPayload, lenPayload, 1, zipStreamerInfos.get()); + auto szZipStreamerInfos = compressor.Zip(bufPayload, lenPayload, compression, zipStreamerInfos.get()); fFileSimple.WriteKey(zipStreamerInfos.get(), szZipStreamerInfos, lenPayload, fFileSimple.fControlBlock->fHeader.GetSeekInfo(), RTFHeader::kBEGIN, "TList", "StreamerInfo", diff --git a/tree/ntuple/v7/src/RPageStorageFile.cxx b/tree/ntuple/v7/src/RPageStorageFile.cxx index f1acaed0169bd..967a9151b8810 100644 --- a/tree/ntuple/v7/src/RPageStorageFile.cxx +++ b/tree/ntuple/v7/src/RPageStorageFile.cxx @@ -245,7 +245,7 @@ void ROOT::Experimental::Internal::RPageSinkFile::CommitDatasetImpl(unsigned cha auto szFooterZip = fCompressor->Zip(serializedFooter, length, GetWriteOptions().GetCompression(), RNTupleCompressor::MakeMemCopyWriter(bufFooterZip.get())); fWriter->WriteNTupleFooter(bufFooterZip.get(), szFooterZip, length); - fWriter->Commit(); + fWriter->Commit(GetWriteOptions().GetCompression()); } ////////////////////////////////////////////////////////////////////////////////