@@ -2248,11 +2248,14 @@ ColumnGetterFunction<R, typename T::iterator> getColumnGetterByLabel(const std::
22482248
22492249namespace o2 ::aod
22502250{
2251+ // If you get an error about not satisfying is_origin_hash, you need to add
2252+ // an entry here.
22512253O2ORIGIN (" AOD" );
22522254O2ORIGIN (" AOD1" );
22532255O2ORIGIN (" AOD2" );
22542256O2ORIGIN (" DYN" );
22552257O2ORIGIN (" IDX" );
2258+ O2ORIGIN (" TIM" );
22562259O2ORIGIN (" JOIN" );
22572260O2HASH (" JOIN/0" );
22582261O2ORIGIN (" CONC" );
@@ -2313,6 +2316,43 @@ consteval static std::string_view namespace_prefix()
23132316 }; \
23142317 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
23152318
2319+ #define DECLARE_SOA_CCDB_COLUMN_FULL (_Name_, _Label_, _Getter_, _ConcreteType_, _CCDBQuery_ ) \
2320+ struct _Name_ : o2::soa::Column<std::span<std::byte>, _Name_> { \
2321+ static constexpr const char * mLabel = _Label_; \
2322+ static constexpr const char * query = _CCDBQuery_; \
2323+ static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2324+ using base = o2::soa::Column<std::span<std::byte>, _Name_>; \
2325+ using type = std::span<std::byte>; \
2326+ using column_t = _Name_; \
2327+ _Name_ (arrow::ChunkedArray const * column) \
2328+ : o2::soa::Column<std::span<std::byte>, _Name_>(o2::soa::ColumnIterator<std::span<std::byte>>(column)) \
2329+ { \
2330+ } \
2331+ \
2332+ _Name_ () = default ; \
2333+ _Name_ (_Name_ const & other) = default ; \
2334+ _Name_& operator =(_Name_ const & other) = default ; \
2335+ \
2336+ decltype (auto ) _Getter_() const \
2337+ { \
2338+ static std::byte* payload = nullptr ; \
2339+ static _ConcreteType_* deserialised = nullptr ; \
2340+ auto span = *mColumnIterator ; \
2341+ if (payload != (std::byte*)span.data ()) { \
2342+ payload = (std::byte*)span.data (); \
2343+ TBufferFile f (TBufferFile::EMode::kRead , span.size (), (char *)span.data (), kFALSE ); \
2344+ deserialised = (_ConcreteType_*)f.ReadObjectAny (TClass::GetClass (#_ConcreteType_)); \
2345+ } \
2346+ return *deserialised; \
2347+ } \
2348+ \
2349+ decltype (auto ) \
2350+ get () const \
2351+ { \
2352+ return _Getter_ (); \
2353+ } \
2354+ };
2355+
23162356#define DECLARE_SOA_COLUMN (_Name_, _Getter_, _Type_ ) \
23172357 DECLARE_SOA_COLUMN_FULL (_Name_, _Getter_, _Type_, " f" #_Name_)
23182358
@@ -3188,6 +3228,36 @@ consteval auto getIndexTargets()
31883228 using metadata = _Name_##Metadata; \
31893229 };
31903230
3231+ // Declare were each row is associated to a timestamp column of an _TimestampSource_
3232+ // table.
3233+ //
3234+ // The columns of this table have to be CCDB_COLUMNS so that for each timestamp, we get a row
3235+ // which points to the specified CCDB objectes described by those columns.
3236+ #define DECLARE_SOA_TIMESTAMPED_TABLE_FULL (_Name_, _Label_, _TimestampSource_, _TimestampColumn_, _Origin_, _Version_, _Desc_, ...) \
3237+ O2HASH (_Desc_ " /" #_Version_); \
3238+ template <typename O> \
3239+ using _Name_##TimestampFrom = soa::Table<o2::aod::Hash<_Label_ " " _h>, o2::aod::Hash<_Desc_ " /" #_Version_ " " _h>, O>; \
3240+ using _Name_##Timestamp = _Name_##TimestampFrom<o2::aod::Hash<_Origin_ " " _h>>; \
3241+ template <typename O = o2::aod::Hash<_Origin_ " " _h>> \
3242+ struct _Name_ ##TimestampMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ " /" #_Version_ " " _h>, __VA_ARGS__> { \
3243+ using base_table_t = _TimestampSource_; \
3244+ using extension_table_t = _Name_##TimestampFrom<O>; \
3245+ using ccdb_pack_t = framework::pack<__VA_ARGS__>; \
3246+ /* static constexpr auto timestampColumn = _TimestampColumn_;*/ \
3247+ }; \
3248+ using _Name_##TimestampMetadata = _Name_##TimestampMetadataFrom<o2::aod::Hash<_Origin_ " " _h>>; \
3249+ template <> \
3250+ struct MetadataTrait <o2::aod::Hash<_Desc_ " /" #_Version_ " " _h>> { \
3251+ using metadata = _Name_##TimestampMetadata; \
3252+ }; \
3253+ template <typename O> \
3254+ using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ " /" #_Version_ " " _h>, _TimestampSource_, _Name_##TimestampFrom<O>>; \
3255+ using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ " " _h>>;
3256+
3257+ #define DECLARE_SOA_TIMESTAMPED_TABLE (_Name_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3258+ O2HASH (#_Name_ " Timestamped" ); \
3259+ DECLARE_SOA_TIMESTAMPED_TABLE_FULL (_Name_, #_Name_ " Timestamped" , _TimestampSource_, _TimestampColumn_, " TIM" , _Version_, _Desc_, __VA_ARGS__)
3260+
31913261#define DECLARE_SOA_INDEX_TABLE (_Name_, _Key_, _Description_, ...) \
31923262 DECLARE_SOA_INDEX_TABLE_FULL (_Name_, _Key_, " IDX" , 0 , _Description_, false , __VA_ARGS__)
31933263
0 commit comments