|
19 | 19 | namespace o2::framework |
20 | 20 | { |
21 | 21 |
|
| 22 | +namespace { |
| 23 | +std::shared_ptr<arrow::ChunkedArray> GetColumnByNameCI(std::shared_ptr<arrow::Table> const& table, std::string const& key) |
| 24 | +{ |
| 25 | + auto const& fields = table->schema()->fields(); |
| 26 | + auto target = std::find_if(fields.begin(), fields.end(), [&key](std::shared_ptr<arrow::Field> const& field){ |
| 27 | + return [](std::string_view const& s1, std::string_view const& s2){ |
| 28 | + return std::ranges::equal( |
| 29 | + s1, s2, |
| 30 | + [](char c1, char c2){ |
| 31 | + return std::tolower(static_cast<unsigned char>(c1)) == std::tolower(static_cast<unsigned char>(c2)); |
| 32 | + } |
| 33 | + ); |
| 34 | + }(field->name(), key); |
| 35 | + }); |
| 36 | + return table->column(std::distance(fields.begin(), target)); |
| 37 | +} |
| 38 | +} |
| 39 | + |
22 | 40 | void updatePairList(Cache& list, std::string const& binding, std::string const& key, bool enabled = true) |
23 | 41 | { |
24 | 42 | auto locate = std::find_if(list.begin(), list.end(), [&binding, &key](auto const& entry) { return (entry.binding == binding) && (entry.key == key); }); |
@@ -99,7 +117,7 @@ arrow::Status ArrowTableSlicingCache::updateCacheEntry(int pos, std::shared_ptr< |
99 | 117 | validateOrder(bindingsKeys[pos], table); |
100 | 118 |
|
101 | 119 | int maxValue = -1; |
102 | | - auto column = table->GetColumnByName(k); |
| 120 | + auto column = GetColumnByNameCI(table, k); |
103 | 121 |
|
104 | 122 | // starting from the end, find the first positive value, in a sorted column it is the largest index |
105 | 123 | for (auto iChunk = column->num_chunks() - 1; iChunk >= 0; --iChunk) { |
@@ -155,7 +173,7 @@ arrow::Status ArrowTableSlicingCache::updateCacheEntryUnsorted(int pos, const st |
155 | 173 | if (!e) { |
156 | 174 | throw runtime_error_f("Disabled unsorted cache %s/%s update requested", b.c_str(), k.c_str()); |
157 | 175 | } |
158 | | - auto column = table->GetColumnByName(k); |
| 176 | + auto column = GetColumnByNameCI(table, k); |
159 | 177 | auto row = 0; |
160 | 178 | for (auto iChunk = 0; iChunk < column->num_chunks(); ++iChunk) { |
161 | 179 | auto chunk = static_cast<arrow::NumericArray<arrow::Int32Type>>(column->chunk(iChunk)->data()); |
@@ -252,7 +270,7 @@ SliceInfoUnsortedPtr ArrowTableSlicingCache::getCacheUnsortedForPos(int pos) con |
252 | 270 | void ArrowTableSlicingCache::validateOrder(Entry const& bindingKey, const std::shared_ptr<arrow::Table>& input) |
253 | 271 | { |
254 | 272 | auto const& [target, key, enabled] = bindingKey; |
255 | | - auto column = input->GetColumnByName(key); |
| 273 | + auto column = o2::framework::GetColumnByNameCI(input, key); |
256 | 274 | auto array0 = static_cast<arrow::NumericArray<arrow::Int32Type>>(column->chunk(0)->data()); |
257 | 275 | int32_t prev = 0; |
258 | 276 | int32_t cur = array0.Value(0); |
|
0 commit comments