diff --git a/Detectors/EMCAL/workflow/src/StandaloneAODProducerSpec.cxx b/Detectors/EMCAL/workflow/src/StandaloneAODProducerSpec.cxx index 73987ce6d1c1b..227fc373bf20c 100644 --- a/Detectors/EMCAL/workflow/src/StandaloneAODProducerSpec.cxx +++ b/Detectors/EMCAL/workflow/src/StandaloneAODProducerSpec.cxx @@ -17,7 +17,6 @@ #include "Framework/InputRecordWalker.h" #include "Framework/Logger.h" #include "Framework/TableBuilder.h" -#include "Framework/TableTreeHelpers.h" #include "MathUtils/Utils.h" using namespace o2::framework; @@ -105,7 +104,7 @@ void StandaloneAODProducerSpec::run(ProcessingContext& pc) o2::math_utils::detail::truncateFloatFraction(cell.getTimeStamp(), mCaloTime), cell.getType(), 1); // hard coded for emcal (-1 would be undefined, 0 phos) - } // end of cell loop + } // end of cell loop // filled only with BCID, rest dummy for no2 caloCellsTRGTableCursor(0, diff --git a/Detectors/Filtering/src/FilteringSpec.cxx b/Detectors/Filtering/src/FilteringSpec.cxx index 847fa2cf7e1e5..bcf3c6c3539d4 100644 --- a/Detectors/Filtering/src/FilteringSpec.cxx +++ b/Detectors/Filtering/src/FilteringSpec.cxx @@ -38,7 +38,6 @@ #include "Framework/InputRecordWalker.h" #include "Framework/Logger.h" #include "Framework/TableBuilder.h" -#include "Framework/TableTreeHelpers.h" #include "Framework/CCDBParamSpec.h" #include "FDDBase/Constants.h" #include "FT0Base/Geometry.h" diff --git a/Detectors/PHOS/workflow/src/StandaloneAODProducerSpec.cxx b/Detectors/PHOS/workflow/src/StandaloneAODProducerSpec.cxx index 454be7a5fcb83..06baf889b662f 100644 --- a/Detectors/PHOS/workflow/src/StandaloneAODProducerSpec.cxx +++ b/Detectors/PHOS/workflow/src/StandaloneAODProducerSpec.cxx @@ -19,7 +19,6 @@ #include "Framework/InputRecordWalker.h" #include "Framework/Logger.h" #include "Framework/TableBuilder.h" -#include "Framework/TableTreeHelpers.h" #include "MathUtils/Utils.h" using namespace o2::framework; @@ -106,7 +105,7 @@ void StandaloneAODProducerSpec::run(ProcessingContext& pc) o2::math_utils::detail::truncateFloatFraction(c.getTime(), mCaloTime), c.getType(), // HG/LG 0); // hard coded for phos (-1 would be undefined, 0 phos) - } // end of cell loop + } // end of cell loop auto bcID = tr.getBCData().toLong(); bcCursor(0, diff --git a/Framework/AnalysisSupport/src/DataInputDirector.cxx b/Framework/AnalysisSupport/src/DataInputDirector.cxx index 7cc0134a27968..2bc6c5613f065 100644 --- a/Framework/AnalysisSupport/src/DataInputDirector.cxx +++ b/Framework/AnalysisSupport/src/DataInputDirector.cxx @@ -16,8 +16,8 @@ #include "Framework/AnalysisDataModelHelpers.h" #include "Framework/Output.h" #include "Framework/Signpost.h" +#include "Framework/FragmentToBatch.h" #include "Headers/DataHeader.h" -#include "Framework/TableTreeHelpers.h" #include "Monitoring/Tags.h" #include "Monitoring/Metric.h" #include "Monitoring/Monitoring.h" diff --git a/Framework/AnalysisSupport/src/Plugin.cxx b/Framework/AnalysisSupport/src/Plugin.cxx index e39e76f01dbdd..5f61a236cbd58 100644 --- a/Framework/AnalysisSupport/src/Plugin.cxx +++ b/Framework/AnalysisSupport/src/Plugin.cxx @@ -27,6 +27,12 @@ O2_DECLARE_DYNAMIC_LOG(analysis_support); +struct ROOTTypeInfo { + EDataType type; + char suffix[3]; + int size; +}; + struct ROOTFileReader : o2::framework::AlgorithmPlugin { o2::framework::AlgorithmSpec create(o2::framework::ConfigContext const& config) override { diff --git a/Framework/Core/CMakeLists.txt b/Framework/Core/CMakeLists.txt index 936d8874179a5..43571526855cc 100644 --- a/Framework/Core/CMakeLists.txt +++ b/Framework/Core/CMakeLists.txt @@ -87,6 +87,7 @@ o2_add_library(Framework src/FairMQDeviceProxy.cxx src/FairMQResizableBuffer.cxx src/FairOptionsRetriever.cxx + src/FragmentToBatch.cxx src/ConfigurationOptionsRetriever.cxx src/FreePortFinder.cxx src/GraphvizHelpers.cxx diff --git a/Framework/Core/include/Framework/FragmentToBatch.h b/Framework/Core/include/Framework/FragmentToBatch.h new file mode 100644 index 0000000000000..3a600d71452b9 --- /dev/null +++ b/Framework/Core/include/Framework/FragmentToBatch.h @@ -0,0 +1,51 @@ +// Copyright 2019-2025 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +#ifndef O2_FRAMEWORK_FRAGMENT_TO_BATCH_H_ +#define O2_FRAMEWORK_FRAGMENT_TO_BATCH_H_ + +#include +#include +#include +#include +#include + +// ============================================================================= +namespace o2::framework +{ +class FragmentToBatch +{ + public: + // The function to be used to create the required stream. + using StreamerCreator = std::function(std::shared_ptr, const std::shared_ptr& buffer)>; + + FragmentToBatch(StreamerCreator, std::shared_ptr, arrow::MemoryPool* pool = arrow::default_memory_pool()); + void setLabel(const char* label); + void fill(std::shared_ptr dataSetSchema, std::shared_ptr); + std::shared_ptr finalize(); + + std::shared_ptr streamer(std::shared_ptr buffer) + { + return mCreator(mFragment, buffer); + } + + private: + std::shared_ptr mFragment; + arrow::MemoryPool* mArrowMemoryPool = nullptr; + std::string mTableLabel; + std::shared_ptr mRecordBatch; + StreamerCreator mCreator; +}; + +// ----------------------------------------------------------------------------- +} // namespace o2::framework + +// ============================================================================= +#endif // O2_FRAMEWORK_FRAGMENT_TO_BATCH_H_ diff --git a/Framework/Core/include/Framework/TableTreeHelpers.h b/Framework/Core/include/Framework/TableTreeHelpers.h index 3f76298a5bbd4..0a163d59aecb0 100644 --- a/Framework/Core/include/Framework/TableTreeHelpers.h +++ b/Framework/Core/include/Framework/TableTreeHelpers.h @@ -91,30 +91,6 @@ class TableToTree std::vector> mColumnReaders; }; -class FragmentToBatch -{ - public: - // The function to be used to create the required stream. - using StreamerCreator = std::function(std::shared_ptr, const std::shared_ptr& buffer)>; - - FragmentToBatch(StreamerCreator, std::shared_ptr, arrow::MemoryPool* pool = arrow::default_memory_pool()); - void setLabel(const char* label); - void fill(std::shared_ptr dataSetSchema, std::shared_ptr); - std::shared_ptr finalize(); - - std::shared_ptr streamer(std::shared_ptr buffer) - { - return mCreator(mFragment, buffer); - } - - private: - std::shared_ptr mFragment; - arrow::MemoryPool* mArrowMemoryPool = nullptr; - std::string mTableLabel; - std::shared_ptr mRecordBatch; - StreamerCreator mCreator; -}; - // ----------------------------------------------------------------------------- } // namespace o2::framework diff --git a/Framework/Core/src/AnalysisSupportHelpers.cxx b/Framework/Core/src/AnalysisSupportHelpers.cxx index e8c2d7acab5d2..7cfab22885671 100644 --- a/Framework/Core/src/AnalysisSupportHelpers.cxx +++ b/Framework/Core/src/AnalysisSupportHelpers.cxx @@ -15,7 +15,6 @@ #include "Framework/ControlService.h" #include "Framework/EndOfStreamContext.h" #include "Framework/DeviceSpec.h" -#include "Framework/TableTreeHelpers.h" #include "Framework/PluginManager.h" #include "Framework/ConfigContext.h" #include "WorkflowHelpers.h" diff --git a/Framework/Core/src/DataAllocator.cxx b/Framework/Core/src/DataAllocator.cxx index 4b559ef26191e..f0de6a40935b7 100644 --- a/Framework/Core/src/DataAllocator.cxx +++ b/Framework/Core/src/DataAllocator.cxx @@ -11,7 +11,6 @@ #include "Framework/CompilerBuiltins.h" #include "Framework/Lifetime.h" #include "Framework/TableBuilder.h" -#include "Framework/TableTreeHelpers.h" #include "Framework/DataAllocator.h" #include "Framework/MessageContext.h" #include "Framework/ArrowContext.h" @@ -19,6 +18,7 @@ #include "Framework/DataProcessingHeader.h" #include "Framework/FairMQResizableBuffer.h" #include "Framework/DataProcessingContext.h" +#include "Framework/FragmentToBatch.h" #include "Framework/DeviceSpec.h" #include "Framework/StreamContext.h" #include "Framework/Signpost.h" diff --git a/Framework/Core/src/FragmentToBatch.cxx b/Framework/Core/src/FragmentToBatch.cxx new file mode 100644 index 0000000000000..88b4f42a8f220 --- /dev/null +++ b/Framework/Core/src/FragmentToBatch.cxx @@ -0,0 +1,57 @@ +// Copyright 2019-2025 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +#include "Framework/FragmentToBatch.h" +#include "Framework/Logger.h" +#include "Framework/Endian.h" +#include "Framework/Signpost.h" + +#include +#include +#include +#include +#include + +#include +#include + +O2_DECLARE_DYNAMIC_LOG(tabletree_helpers); + +namespace o2::framework +{ + +FragmentToBatch::FragmentToBatch(StreamerCreator creator, std::shared_ptr fragment, arrow::MemoryPool* pool) + : mFragment{std::move(fragment)}, + mArrowMemoryPool{pool}, + mCreator{std::move(creator)} +{ +} + +void FragmentToBatch::setLabel(const char* label) +{ + mTableLabel = label; +} + +void FragmentToBatch::fill(std::shared_ptr schema, std::shared_ptr format) +{ + auto options = std::make_shared(); + options->dataset_schema = schema; + auto scanner = format->ScanBatchesAsync(options, mFragment); + auto batch = (*scanner)(); + mRecordBatch = *batch.result(); + // Notice that up to here the buffer was not yet filled. +} + +std::shared_ptr FragmentToBatch::finalize() +{ + return mRecordBatch; +} + +} // namespace o2::framework diff --git a/Framework/Core/src/TableTreeHelpers.cxx b/Framework/Core/src/TableTreeHelpers.cxx index 92231cb9ce069..800a31e8ecac3 100644 --- a/Framework/Core/src/TableTreeHelpers.cxx +++ b/Framework/Core/src/TableTreeHelpers.cxx @@ -296,31 +296,4 @@ struct BranchInfo { }; } // namespace -FragmentToBatch::FragmentToBatch(StreamerCreator creator, std::shared_ptr fragment, arrow::MemoryPool* pool) - : mFragment{std::move(fragment)}, - mArrowMemoryPool{pool}, - mCreator{std::move(creator)} -{ -} - -void FragmentToBatch::setLabel(const char* label) -{ - mTableLabel = label; -} - -void FragmentToBatch::fill(std::shared_ptr schema, std::shared_ptr format) -{ - auto options = std::make_shared(); - options->dataset_schema = schema; - auto scanner = format->ScanBatchesAsync(options, mFragment); - auto batch = (*scanner)(); - mRecordBatch = *batch.result(); - // Notice that up to here the buffer was not yet filled. -} - -std::shared_ptr FragmentToBatch::finalize() -{ - return mRecordBatch; -} - } // namespace o2::framework