Project
Loading...
Searching...
No Matches
o2::framework::DataAllocator Class Reference

#include <DataAllocator.h>

Classes

struct  CacheId
 
struct  UninitializedVector
 

Public Types

enum struct  CacheStrategy : int { Never = 0 , Always = 1 }
 
using AllowedOutputRoutes = std::vector< OutputRoute >
 
using DataHeader = o2::header::DataHeader
 
using DataOrigin = o2::header::DataOrigin
 
using DataDescription = o2::header::DataDescription
 
using SubSpecificationType = o2::header::DataHeader::SubSpecificationType
 

Public Member Functions

 DataAllocator (ServiceRegistryRef ref)
 
DataChunknewChunk (const Output &, size_t)
 
DataChunknewChunk (OutputRef &&ref, size_t size)
 
void adoptChunk (const Output &, char *, size_t, fair::mq::FreeFn *, void *)
 
void cookDeadBeef (const Output &spec)
 
template<typename T , typename... Args>
requires is_specialization_v<T, o2::framework::DataAllocator::UninitializedVector>
decltype(auto) make (const Output &spec, Args... args)
 
template<typename T , typename... Args>
requires VectorOfMessageableTypes<T>
decltype(auto) make (const Output &spec, Args... args)
 
template<typename T , typename... Args>
requires (!VectorOfMessageableTypes<T> && has_root_dictionary<T>::value == true && is_messageable<T>::value == false)
decltype(auto) make (const Output &spec, Args... args)
 
template<typename T , typename... Args>
requires std::is_base_of_v<std::string, T>
decltype(auto) make (const Output &spec, Args... args)
 
template<typename T , typename... Args>
requires (requires { static_cast<struct TableBuilder>(std::declval<std::decay_t<T>>()); })
decltype(auto) make (const Output &spec, Args... args)
 
template<typename T , typename... Args>
requires (requires { static_cast<struct TreeToTable>(std::declval<std::decay_t<T>>()); })
decltype(auto) make (const Output &spec, Args... args)
 
template<typename T , typename... Args>
requires (requires { static_cast<struct FragmentToBatch>(std::declval<std::decay_t<T>>()); })
decltype(auto) make (const Output &spec, Args... args)
 
template<typename T >
requires is_messageable<T>
::value &&!is_specialization_v< T, UninitializedVector > decltype(auto) make (const Output &spec)
 
template<typename T >
requires is_messageable<T>
::value &&!is_specialization_v< T, UninitializedVector > decltype(auto) make (const Output &spec, std::integral auto nElements)
 
template<typename T , typename Arg >
decltype(auto) make (const Output &spec, std::same_as< std::shared_ptr< arrow::Schema > > auto schema)
 
void adopt (const Output &spec, std::string *)
 
void adopt (const Output &spec, LifetimeHolder< struct TableBuilder > &)
 
void adopt (const Output &spec, LifetimeHolder< struct TreeToTable > &)
 
void adopt (const Output &spec, LifetimeHolder< struct FragmentToBatch > &)
 
void adopt (const Output &spec, std::shared_ptr< class arrow::Table >)
 Adopt an Arrow table and send it to all consumers of spec.
 
template<typename T >
void snapshot (const Output &spec, T const &object)
 
void snapshot (const Output &spec, const char *payload, size_t payloadSize, o2::header::SerializationMethod serializationMethod=o2::header::gSerializationMethodNone)
 
template<typename T , typename... Args>
decltype(auto) make (OutputRef &&ref, Args &&... args)
 
template<typename T >
void adopt (OutputRef &&ref, T *obj)
 
o2::pmr::FairMQMemoryResourcegetMemoryResource (const Output &spec)
 
template<typename T , typename... Args>
o2::pmr::vector< T > makeVector (const Output &spec, Args &&... args)
 
template<typename ContainerT >
CacheId adoptContainer (const Output &, ContainerT &, CacheStrategy, o2::header::SerializationMethod)
 
template<typename ContainerT >
CacheId adoptContainer (const Output &spec, ContainerT &&container, CacheStrategy cache=CacheStrategy::Never, o2::header::SerializationMethod method=header::gSerializationMethodNone)
 
void adoptFromCache (Output const &spec, CacheId id, header::SerializationMethod method=header::gSerializationMethodNone)
 Adopt an already cached message, using an already provided CacheId.
 
template<typename... Args>
auto snapshot (OutputRef &&ref, Args &&... args)
 
bool isAllowed (Output const &query)
 check if a certain output is allowed
 
o2::header::DataHeaderfindMessageHeader (const Output &spec)
 
o2::header::DataHeaderfindMessageHeader (OutputRef &&ref)
 
o2::header::StackfindMessageHeaderStack (const Output &spec)
 
o2::header::StackfindMessageHeaderStack (OutputRef &&ref)
 
int countDeviceOutputs (bool excludeDPLOrigin=false)
 

Static Public Attributes

static constexpr ServiceKind service_kind = ServiceKind::Stream
 

Detailed Description

This allocator is responsible to make sure that the messages created match the provided spec and that depending on how many pipelined reader we have, messages get created on the channel for the reader of the current timeframe.

Definition at line 134 of file DataAllocator.h.

Member Typedef Documentation

◆ AllowedOutputRoutes

Definition at line 138 of file DataAllocator.h.

◆ DataDescription

◆ DataHeader

◆ DataOrigin

◆ SubSpecificationType

Member Enumeration Documentation

◆ CacheStrategy

Enumerator
Never 
Always 

Definition at line 486 of file DataAllocator.h.

Constructor & Destructor Documentation

◆ DataAllocator()

o2::framework::DataAllocator::DataAllocator ( ServiceRegistryRef  ref)

Definition at line 49 of file DataAllocator.cxx.

Member Function Documentation

◆ adopt() [1/6]

void o2::framework::DataAllocator::adopt ( const Output spec,
LifetimeHolder< struct FragmentToBatch > &  f2b 
)

Adopt a Source2Batch in the framework and serialise / send it as an Arrow Dataset to all consumers of spec once done

To finalise this we write the table to the buffer. FIXME: most likely not a great idea. We should probably write to the buffer directly in the TableBuilder, incrementally.

Definition at line 304 of file DataAllocator.cxx.

◆ adopt() [2/6]

void o2::framework::DataAllocator::adopt ( const Output spec,
LifetimeHolder< struct TableBuilder > &  tb 
)

Adopt a TableBuilder in the framework and serialise / send it as an Arrow table to all consumers of spec once done

To finalise this we write the table to the buffer.

Definition at line 242 of file DataAllocator.cxx.

◆ adopt() [3/6]

void o2::framework::DataAllocator::adopt ( const Output spec,
LifetimeHolder< struct TreeToTable > &  t2t 
)

Adopt a Tree2Table in the framework and serialise / send it as an Arrow table to all consumers of spec once done

To finalise this we write the table to the buffer. FIXME: most likely not a great idea. We should probably write to the buffer directly in the TableBuilder, incrementally.

Definition at line 272 of file DataAllocator.cxx.

◆ adopt() [4/6]

void o2::framework::DataAllocator::adopt ( const Output spec,
std::shared_ptr< class arrow::Table >   
)

Adopt an Arrow table and send it to all consumers of spec.

◆ adopt() [5/6]

void o2::framework::DataAllocator::adopt ( const Output spec,
std::string *  ptr 
)

Adopt a string in the framework and serialize / send it to the consumers of spec once done.

Definition at line 151 of file DataAllocator.cxx.

◆ adopt() [6/6]

template<typename T >
void o2::framework::DataAllocator::adopt ( OutputRef &&  ref,
T *  obj 
)
inline

adopt an object of type T and route to output specified by OutputRef Framework takes ownership of the object

OutputRef descriptors are expected to be passed as rvalue, i.e. a temporary object in the function call

Definition at line 460 of file DataAllocator.h.

◆ adoptChunk()

void o2::framework::DataAllocator::adoptChunk ( const Output spec,
char buffer,
size_t  size,
fair::mq::FreeFn *  freefn,
void hint = nullptr 
)

Definition at line 91 of file DataAllocator.cxx.

◆ adoptContainer() [1/2]

template<typename ContainerT >
CacheId o2::framework::DataAllocator::adoptContainer ( const Output ,
ContainerT &  ,
CacheStrategy  ,
o2::header::SerializationMethod   
)
inline

Definition at line 492 of file DataAllocator.h.

◆ adoptContainer() [2/2]

template<typename ContainerT >
DataAllocator::CacheId o2::framework::DataAllocator::adoptContainer ( const Output spec,
ContainerT &&  container,
CacheStrategy  cache = CacheStrategy::Never,
o2::header::SerializationMethod  method = header::gSerializationMethodNone 
)

Adopt a PMR container. Notice that the container must be moveable and eventually backed / by a o2::pmr::FairMQMemoryResource. spec where to send the message container the container whose resource needs to be sent cache: if true, the messages being sent are shallow copies of a cached copy. The entry in the cache can be subsequently be sent using the returned CacheId.

Returns
a unique id of the adopted message which can be used to resend the message or can be pruned via the DataAllocator::prune() method.

Definition at line 568 of file DataAllocator.h.

◆ adoptFromCache()

void o2::framework::DataAllocator::adoptFromCache ( Output const &  spec,
CacheId  id,
header::SerializationMethod  method = header::gSerializationMethodNone 
)

Adopt an already cached message, using an already provided CacheId.

Definition at line 400 of file DataAllocator.cxx.

◆ cookDeadBeef()

void o2::framework::DataAllocator::cookDeadBeef ( const Output spec)

Definition at line 418 of file DataAllocator.cxx.

◆ countDeviceOutputs()

int o2::framework::DataAllocator::countDeviceOutputs ( bool  excludeDPLOrigin = false)
inline

Definition at line 547 of file DataAllocator.h.

◆ findMessageHeader() [1/2]

o2::header::DataHeader * o2::framework::DataAllocator::findMessageHeader ( const Output spec)
inline

Definition at line 527 of file DataAllocator.h.

◆ findMessageHeader() [2/2]

o2::header::DataHeader * o2::framework::DataAllocator::findMessageHeader ( OutputRef &&  ref)
inline

Definition at line 532 of file DataAllocator.h.

◆ findMessageHeaderStack() [1/2]

o2::header::Stack * o2::framework::DataAllocator::findMessageHeaderStack ( const Output spec)
inline

Definition at line 537 of file DataAllocator.h.

◆ findMessageHeaderStack() [2/2]

o2::header::Stack * o2::framework::DataAllocator::findMessageHeaderStack ( OutputRef &&  ref)
inline

Definition at line 542 of file DataAllocator.h.

◆ getMemoryResource()

o2::pmr::FairMQMemoryResource * o2::framework::DataAllocator::getMemoryResource ( const Output spec)
inline

Definition at line 466 of file DataAllocator.h.

◆ isAllowed()

bool o2::framework::DataAllocator::isAllowed ( Output const &  query)

check if a certain output is allowed

Definition at line 389 of file DataAllocator.cxx.

◆ make() [1/11]

template<typename T >
requires is_messageable<T>
::value &&!is_specialization_v< T, UninitializedVector > decltype(auto) o2::framework::DataAllocator::make ( const Output spec)
inline

Definition at line 256 of file DataAllocator.h.

◆ make() [2/11]

template<typename T , typename... Args>
requires is_specialization_v<T, o2::framework::DataAllocator::UninitializedVector>
decltype(auto) o2::framework::DataAllocator::make ( const Output spec,
Args...  args 
)
inline

Definition at line 166 of file DataAllocator.h.

◆ make() [3/11]

template<typename T , typename... Args>
requires VectorOfMessageableTypes<T>
decltype(auto) o2::framework::DataAllocator::make ( const Output spec,
Args...  args 
)
inline

Definition at line 184 of file DataAllocator.h.

◆ make() [4/11]

template<typename T , typename... Args>
requires (!VectorOfMessageableTypes<T> && has_root_dictionary<T>::value == true && is_messageable<T>::value == false)
decltype(auto) o2::framework::DataAllocator::make ( const Output spec,
Args...  args 
)
inline

Definition at line 201 of file DataAllocator.h.

◆ make() [5/11]

template<typename T , typename... Args>
requires std::is_base_of_v<std::string, T>
decltype(auto) o2::framework::DataAllocator::make ( const Output spec,
Args...  args 
)
inline

Definition at line 220 of file DataAllocator.h.

◆ make() [6/11]

template<typename T , typename... Args>
requires (requires { static_cast<struct TableBuilder>(std::declval<std::decay_t<T>>()); })
decltype(auto) o2::framework::DataAllocator::make ( const Output spec,
Args...  args 
)
inline

Definition at line 229 of file DataAllocator.h.

◆ make() [7/11]

template<typename T , typename... Args>
requires (requires { static_cast<struct TreeToTable>(std::declval<std::decay_t<T>>()); })
decltype(auto) o2::framework::DataAllocator::make ( const Output spec,
Args...  args 
)
inline

Definition at line 238 of file DataAllocator.h.

◆ make() [8/11]

template<typename T , typename... Args>
requires (requires { static_cast<struct FragmentToBatch>(std::declval<std::decay_t<T>>()); })
decltype(auto) o2::framework::DataAllocator::make ( const Output spec,
Args...  args 
)
inline

Definition at line 247 of file DataAllocator.h.

◆ make() [9/11]

template<typename T >
requires is_messageable<T>
::value &&!is_specialization_v< T, UninitializedVector > decltype(auto) o2::framework::DataAllocator::make ( const Output spec,
std::integral auto  nElements 
)
inline

Definition at line 263 of file DataAllocator.h.

◆ make() [10/11]

template<typename T , typename Arg >
decltype(auto) o2::framework::DataAllocator::make ( const Output spec,
std::same_as< std::shared_ptr< arrow::Schema > > auto  schema 
)
inline

Definition at line 274 of file DataAllocator.h.

◆ make() [11/11]

template<typename T , typename... Args>
decltype(auto) o2::framework::DataAllocator::make ( OutputRef &&  ref,
Args &&...  args 
)
inline

make an object of type T and route to output specified by OutputRef The object is owned by the framework, returned reference can be used to fill the object.

OutputRef descriptors are expected to be passed as rvalue, i.e. a temporary object in the function call

Definition at line 449 of file DataAllocator.h.

◆ makeVector()

template<typename T , typename... Args>
o2::pmr::vector< T > o2::framework::DataAllocator::makeVector ( const Output spec,
Args &&...  args 
)
inline

Definition at line 476 of file DataAllocator.h.

◆ newChunk() [1/2]

DataChunk & o2::framework::DataAllocator::newChunk ( const Output spec,
size_t  size 
)

Definition at line 77 of file DataAllocator.cxx.

◆ newChunk() [2/2]

DataChunk & o2::framework::DataAllocator::newChunk ( OutputRef &&  ref,
size_t  size 
)
inline

Definition at line 154 of file DataAllocator.h.

◆ snapshot() [1/3]

void o2::framework::DataAllocator::snapshot ( const Output spec,
const char payload,
size_t  payloadSize,
o2::header::SerializationMethod  serializationMethod = o2::header::gSerializationMethodNone 
)

Take a snapshot of a raw data array which can be either POD or may contain a serialized object (in such case the serialization method should be specified accordingly). Changes to the data after the call will not be sent.

Definition at line 355 of file DataAllocator.cxx.

◆ snapshot() [2/3]

template<typename T >
void o2::framework::DataAllocator::snapshot ( const Output spec,
T const &  object 
)
inline

Send a snapshot of an object, depending on the object type it is serialized before. The method always takes a copy of the data, which will then be sent once the computation ends. Framework does not take ownership of the object. Changes to object after the call will not be sent.

Supported types:

  • messageable types (trivially copyable, non-polymorphic
  • std::vector of messageable types
  • std::vector of pointers of messageable type
  • types with ROOT dictionary and implementing the ROOT ClassDef interface

Note: for many use cases, especially for the messageable types, the make interface might be better suited as the objects are allocated directly in the underlying memory resource and the copy can be avoided.

Note: messageable objects with ROOT dictionary are preferably sent unserialized. Use ROOTSerialized type wrapper to force ROOT serialization. Same applies to types which do not implement the ClassDef interface but have a dictionary.

Definition at line 325 of file DataAllocator.h.

◆ snapshot() [3/3]

template<typename... Args>
auto o2::framework::DataAllocator::snapshot ( OutputRef &&  ref,
Args &&...  args 
)
inline

snapshot object and route to output specified by OutputRef Framework makes a (serialized) copy of object content.

OutputRef descriptors are expected to be passed as rvalue, i.e. a temporary object in the function call

Definition at line 519 of file DataAllocator.h.

Member Data Documentation

◆ service_kind

constexpr ServiceKind o2::framework::DataAllocator::service_kind = ServiceKind::Stream
staticconstexpr

Definition at line 137 of file DataAllocator.h.


The documentation for this class was generated from the following files: