@@ -115,11 +115,14 @@ std::shared_ptr<arrow::Table> ArrowHelpers::concatTables(std::vector<std::shared
115115
116116arrow::ChunkedArray* getIndexFromLabel (arrow::Table* table, const char * label)
117117{
118- auto index = table->schema ()->GetAllFieldIndices (label);
119- if (index.empty ()) {
118+ auto field = std::find_if (table->schema ()->fields ().begin (), table->schema ()->fields ().end (), [&](std::shared_ptr<arrow::Field> const & f){
119+ return o2::framework::strToUpper (label) == o2::framework::strToUpper (std::string{f->name ()});
120+ });
121+ if (field == table->schema ()->fields ().end ()) {
120122 o2::framework::throw_error (o2::framework::runtime_error_f (" Unable to find column with label %s" , label));
121123 }
122- return table->column (index[0 ]).get ();
124+ auto index = std::distance (table->schema ()->fields ().begin (), field);
125+ return table->column (index).get ();
123126}
124127
125128void notBoundTable (const char * tableName)
@@ -150,35 +153,9 @@ std::string cutString(std::string&& str)
150153 return str;
151154}
152155
153- void sliceByColumnGeneric (
154- char const * key,
155- char const * target,
156- std::shared_ptr<arrow::Table> const & input,
157- int32_t fullSize,
158- ListVector* groups,
159- ListVector* unassigned)
156+ std::string strToUpper (std::string&& str)
160157{
161- groups->resize (fullSize);
162- auto column = input->GetColumnByName (key);
163- int32_t row = 0 ;
164- for (auto iChunk = 0 ; iChunk < column->num_chunks (); ++iChunk) {
165- auto chunk = static_cast <arrow::NumericArray<arrow::Int32Type>>(column->chunk (iChunk)->data ());
166- for (auto iElement = 0 ; iElement < chunk.length (); ++iElement) {
167- auto v = chunk.Value (iElement);
168- if (v >= 0 ) {
169- if (v >= groups->size ()) {
170- throw runtime_error_f (" Table %s has an entry with index (%d) that is larger than the grouping table size (%d)" , target, v, fullSize);
171- }
172- (*groups)[v].push_back (row);
173- } else if (unassigned != nullptr ) {
174- auto av = std::abs (v);
175- if (unassigned->size () < av + 1 ) {
176- unassigned->resize (av + 1 );
177- }
178- (*unassigned)[av].push_back (row);
179- }
180- ++row;
181- }
182- }
158+ std::transform (str.begin (), str.end (), str.begin (), [](unsigned char c){ return std::toupper (c); });
159+ return str;
183160}
184161} // namespace o2::framework
0 commit comments