|
21 | 21 | #include "Framework/Signpost.h" |
22 | 22 | #include "Framework/DanglingEdgesContext.h" |
23 | 23 | #include "Framework/ConfigContext.h" |
24 | | -#include "Framework/ConfigContext.h" |
| 24 | +#include "Framework/ConfigParamsHelper.h" |
25 | 25 | #include <arrow/array/builder_binary.h> |
26 | 26 | #include <arrow/type.h> |
27 | 27 | #include <arrow/type_fwd.h> |
@@ -71,31 +71,45 @@ AlgorithmSpec AnalysisCCDBHelpers::fetchFromCCDB(ConfigContext const& /*ctx*/) |
71 | 71 | { |
72 | 72 | return adaptStateful([](ConfigParamRegistry const& options, DeviceSpec const& spec, InitContext& ic) { |
73 | 73 | auto& dec = ic.services().get<DanglingEdgesContext>(); |
| 74 | + // The effective default for each ccdb: option was already resolved at topology |
| 75 | + // time by ArrowSupport (consulting task Configurables) and registered on this |
| 76 | + // device's options. Here we just read the final value — honouring any further |
| 77 | + // runtime override supplied via CLI or JSON config. |
| 78 | + std::unordered_map<std::string, std::string> ccdbUrls; |
| 79 | + for (auto& input : dec.analysisCCDBInputs) { |
| 80 | + for (auto& m : input.metadata) { |
| 81 | + if (!m.name.starts_with("ccdb:") || ccdbUrls.count(m.name)) { |
| 82 | + continue; |
| 83 | + } |
| 84 | + std::string url = m.defaultValue.asString(); |
| 85 | + if (ConfigParamsHelper::hasOption(spec.options, m.name)) { |
| 86 | + url = options.get<std::string>(m.name.c_str()); |
| 87 | + } |
| 88 | + LOGP(info, "CCDB path resolved for {}: {}", m.name, url); |
| 89 | + ccdbUrls.emplace(m.name, std::move(url)); |
| 90 | + } |
| 91 | + } |
74 | 92 | std::vector<std::shared_ptr<arrow::Schema>> schemas; |
75 | | - auto schemaMetadata = std::make_shared<arrow::KeyValueMetadata>(); |
76 | | - |
77 | 93 | for (auto& input : dec.analysisCCDBInputs) { |
| 94 | + auto schemaMetadata = std::make_shared<arrow::KeyValueMetadata>(); |
78 | 95 | std::vector<std::shared_ptr<arrow::Field>> fields; |
79 | 96 | schemaMetadata->Append("outputRoute", DataSpecUtils::describe(input)); |
80 | 97 | schemaMetadata->Append("outputBinding", input.binding); |
81 | | - |
82 | 98 | for (auto& m : input.metadata) { |
83 | | - // Save the list of input tables |
84 | 99 | if (m.name.starts_with("input:")) { |
85 | 100 | auto name = m.name.substr(6); |
86 | 101 | schemaMetadata->Append("sourceTable", name); |
87 | 102 | schemaMetadata->Append("sourceMatcher", DataSpecUtils::describe(std::get<ConcreteDataMatcher>(DataSpecUtils::fromMetadataString(m.defaultValue.get<std::string>()).matcher))); |
88 | 103 | continue; |
89 | 104 | } |
90 | | - // Ignore the non ccdb: entries |
91 | 105 | if (!m.name.starts_with("ccdb:")) { |
92 | 106 | continue; |
93 | 107 | } |
94 | | - // Create the schema of the output |
95 | | - auto metadata = std::make_shared<arrow::KeyValueMetadata>(); |
96 | | - metadata->Append("url", m.defaultValue.asString()); |
| 108 | + auto fieldMetadata = std::make_shared<arrow::KeyValueMetadata>(); |
| 109 | + auto it = ccdbUrls.find(m.name); |
| 110 | + fieldMetadata->Append("url", it != ccdbUrls.end() ? it->second : m.defaultValue.asString()); |
97 | 111 | auto columnName = m.name.substr(strlen("ccdb:")); |
98 | | - fields.emplace_back(std::make_shared<arrow::Field>(columnName, arrow::binary_view(), false, metadata)); |
| 112 | + fields.emplace_back(std::make_shared<arrow::Field>(columnName, arrow::binary_view(), false, fieldMetadata)); |
99 | 113 | } |
100 | 114 | schemas.emplace_back(std::make_shared<arrow::Schema>(fields, schemaMetadata)); |
101 | 115 | } |
|
0 commit comments