@@ -865,31 +865,7 @@ auto select(T const& t, framework::expressions::Filter&& f)
865865 t.asArrowTable ()->schema ()));
866866}
867867
868- namespace
869- {
870- auto getSliceFor (int value, char const * key, std::shared_ptr<arrow::Table> const & input, std::shared_ptr<arrow::Table>& output, uint64_t & offset)
871- {
872- arrow::Datum value_counts;
873- auto options = arrow::compute::CountOptions::Defaults ();
874- ARROW_ASSIGN_OR_RAISE (value_counts,
875- arrow::compute::CallFunction (" value_counts" , {input->GetColumnByName (key)},
876- &options));
877- auto pair = static_cast <arrow::StructArray>(value_counts.array ());
878- auto values = static_cast <arrow::NumericArray<arrow::Int32Type>>(pair.field (0 )->data ());
879- auto counts = static_cast <arrow::NumericArray<arrow::Int64Type>>(pair.field (1 )->data ());
880-
881- int slice;
882- for (slice = 0 ; slice < values.length (); ++slice) {
883- if (values.Value (slice) == value) {
884- offset = slice;
885- output = input->Slice (slice, counts.Value (slice));
886- return arrow::Status::OK ();
887- }
888- }
889- output = input->Slice (0 , 0 );
890- return arrow::Status::OK ();
891- }
892- } // namespace
868+ arrow::Status getSliceFor (int value, char const * key, std::shared_ptr<arrow::Table> const & input, std::shared_ptr<arrow::Table>& output, uint64_t & offset);
893869
894870template <typename T>
895871auto sliceBy (T const & t, framework::expressions::BindingNode const & node, int value)
@@ -900,9 +876,12 @@ auto sliceBy(T const& t, framework::expressions::BindingNode const& node, int va
900876 if (status.ok ()) {
901877 return T ({result}, offset);
902878 }
903- throw std::runtime_error (" Failed to slice table" );
879+ o2::framework::throw_error (o2::framework::runtime_error (" Failed to slice table" ));
880+ O2_BUILTIN_UNREACHABLE ();
904881}
905882
883+ arrow::ChunkedArray* getIndexFromLabel (arrow::Table* table, const char * label);
884+
906885// / A Table class which observes an arrow::Table and provides
907886// / It is templated on a set of Column / DynamicColumn types.
908887template <typename ... C>
@@ -1137,11 +1116,7 @@ class Table
11371116 {
11381117 if constexpr (T::persistent::value) {
11391118 auto label = T::columnLabel ();
1140- auto index = mTable ->schema ()->GetAllFieldIndices (label);
1141- if (index.empty () == true ) {
1142- throw o2::framework::runtime_error_f (" Unable to find column with label %s" , label);
1143- }
1144- return mTable ->column (index[0 ]).get ();
1119+ return getIndexFromLabel (mTable .get (), label);
11451120 } else {
11461121 return nullptr ;
11471122 }
0 commit comments