@@ -67,38 +67,39 @@ void fillValidRoutes(CCDBFetcherHelper& helper, std::vector<o2::framework::Outpu
6767}
6868} // namespace
6969
70- AlgorithmSpec AnalysisCCDBHelpers::fetchFromCCDB (ConfigContext const & ctx)
70+ AlgorithmSpec AnalysisCCDBHelpers::fetchFromCCDB (ConfigContext const & /* ctx*/ )
7171{
72- auto & ac = ctx.services ().get <DanglingEdgesContext>();
73- std::vector<std::shared_ptr<arrow::Schema>> schemas;
74- auto schemaMetadata = std::make_shared<arrow::KeyValueMetadata>();
72+ return adaptStateful ([](ConfigParamRegistry const & options, DeviceSpec const & spec, InitContext& ic) {
73+ auto & dec = ic.services ().get <DanglingEdgesContext>();
74+ std::vector<std::shared_ptr<arrow::Schema>> schemas;
75+ auto schemaMetadata = std::make_shared<arrow::KeyValueMetadata>();
7576
76- for (auto & input : ac .analysisCCDBInputs ) {
77- std::vector<std::shared_ptr<arrow::Field>> fields;
78- schemaMetadata->Append (" outputRoute" , DataSpecUtils::describe (input));
79- schemaMetadata->Append (" outputBinding" , input.binding );
77+ for (auto & input : dec .analysisCCDBInputs ) {
78+ std::vector<std::shared_ptr<arrow::Field>> fields;
79+ schemaMetadata->Append (" outputRoute" , DataSpecUtils::describe (input));
80+ schemaMetadata->Append (" outputBinding" , input.binding );
8081
81- for (auto & m : input.metadata ) {
82- // Save the list of input tables
83- if (m.name .starts_with (" input:" )) {
84- auto name = m.name .substr (6 );
85- schemaMetadata->Append (" sourceTable" , name);
86- schemaMetadata->Append (" sourceMatcher" , DataSpecUtils::describe (std::get<ConcreteDataMatcher>(DataSpecUtils::fromMetadataString (m.defaultValue .get <std::string>()).matcher )));
87- continue ;
88- }
89- // Ignore the non ccdb: entries
90- if (!m.name .starts_with (" ccdb:" )) {
91- continue ;
82+ for (auto & m : input.metadata ) {
83+ // Save the list of input tables
84+ if (m.name .starts_with (" input:" )) {
85+ auto name = m.name .substr (6 );
86+ schemaMetadata->Append (" sourceTable" , name);
87+ schemaMetadata->Append (" sourceMatcher" , DataSpecUtils::describe (std::get<ConcreteDataMatcher>(DataSpecUtils::fromMetadataString (m.defaultValue .get <std::string>()).matcher )));
88+ continue ;
89+ }
90+ // Ignore the non ccdb: entries
91+ if (!m.name .starts_with (" ccdb:" )) {
92+ continue ;
93+ }
94+ // Create the schema of the output
95+ auto metadata = std::make_shared<arrow::KeyValueMetadata>();
96+ metadata->Append (" url" , m.defaultValue .asString ());
97+ auto columnName = m.name .substr (strlen (" ccdb:" ));
98+ fields.emplace_back (std::make_shared<arrow::Field>(columnName, arrow::binary_view (), false , metadata));
9299 }
93- // Create the schema of the output
94- auto metadata = std::make_shared<arrow::KeyValueMetadata>();
95- metadata->Append (" url" , m.defaultValue .asString ());
96- auto columnName = m.name .substr (strlen (" ccdb:" ));
97- fields.emplace_back (std::make_shared<arrow::Field>(columnName, arrow::binary_view (), false , metadata));
100+ schemas.emplace_back (std::make_shared<arrow::Schema>(fields, schemaMetadata));
98101 }
99- schemas.emplace_back (std::make_shared<arrow::Schema>(fields, schemaMetadata));
100- }
101- return adaptStateful ([schemas](CallbackService& callbacks, ConfigParamRegistry const & options, DeviceSpec const & spec) {
102+
102103 std::shared_ptr<CCDBFetcherHelper> helper = std::make_shared<CCDBFetcherHelper>();
103104 CCDBFetcherHelper::initialiseHelper (*helper, options);
104105 std::unordered_map<std::string, int > bindings;
@@ -129,11 +130,11 @@ AlgorithmSpec AnalysisCCDBHelpers::fetchFromCCDB(ConfigContext const& ctx)
129130 int outputRouteIndex = bindings.at (outRouteDesc);
130131 auto & spec = helper->routes [outputRouteIndex].matcher ;
131132 std::vector<std::shared_ptr<arrow::BinaryViewBuilder>> builders;
132- for (auto & _ : schema->fields ()) {
133+ for (auto const & _ : schema->fields ()) {
133134 builders.emplace_back (std::make_shared<arrow::BinaryViewBuilder>());
134135 }
135136
136- for (size_t ci = 0 ; ci < timestampColumn->num_chunks (); ++ci) {
137+ for (auto ci = 0 ; ci < timestampColumn->num_chunks (); ++ci) {
137138 std::shared_ptr<arrow::Array> chunk = timestampColumn->chunk (ci);
138139 auto const * timestamps = chunk->data ()->GetValuesSafe <size_t >(1 );
139140
0 commit comments