@@ -234,9 +234,7 @@ class InputRecord
234234 // the buffer to be deleted when it goes out of scope. The string is built
235235 // from the data and its lengh, null-termination is not necessary.
236236 // return std::string object
237- auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
238- assert (header);
239- return std::string (ref.payload , header->payloadSize );
237+ return std::string (ref.payload , DataRefUtils::getPayloadSize (ref));
240238
241239 // implementation (c)
242240 } else if constexpr (std::is_same<T, char const *>::value) {
@@ -253,21 +251,17 @@ class InputRecord
253251 // substitution for TableConsumer
254252 // For the moment this is dummy, as it requires proper support to
255253 // create the RDataSource from the arrow buffer.
256- auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
257- assert (header);
258254 auto data = reinterpret_cast <uint8_t const *>(ref.payload );
259- return std::make_unique<TableConsumer>(data, header-> payloadSize );
255+ return std::make_unique<TableConsumer>(data, DataRefUtils::getPayloadSize (ref) );
260256
261257 // implementation (e)
262258 } else if constexpr (framework::is_boost_serializable<T>::value || is_specialization<T, BoostSerialized>::value) {
263259 // substitution for boost-serialized entities
264260 // We have to deserialize the ostringstream.
265261 // FIXME: check that the string is null terminated.
266262 // @return deserialized copy of payload
267- auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
268- assert (header);
269- auto str = std::string (ref.payload , header->payloadSize );
270- assert (header->payloadSize == sizeof (T));
263+ auto str = std::string (ref.payload , DataRefUtils::getPayloadSize (ref));
264+ assert (DataRefUtils::getPayloadSize (ref) == sizeof (T));
271265 if constexpr (is_specialization<T, BoostSerialized>::value) {
272266 return o2::utils::BoostDeserialize<typename T::wrapped_type>(str);
273267 } else {
@@ -285,25 +279,27 @@ class InputRecord
285279 throw runtime_error (" Inconsistent serialization method for extracting span" );
286280 }
287281 using ValueT = typename T::value_type;
288- if (header->payloadSize % sizeof (ValueT)) {
282+ auto payloadSize = DataRefUtils::getPayloadSize (ref);
283+ if (payloadSize % sizeof (ValueT)) {
289284 throw runtime_error ((" Inconsistent type and payload size at " + std::string (ref.spec ->binding ) + " (" + DataSpecUtils::describe (*ref.spec ) + " )" +
290285 " : type size " + std::to_string (sizeof (ValueT)) +
291- " payload size " + std::to_string (header-> payloadSize ))
286+ " payload size " + std::to_string (payloadSize))
292287 .c_str ());
293288 }
294- return gsl::span<ValueT const >(reinterpret_cast <ValueT const *>(ref.payload ), header-> payloadSize / sizeof (ValueT));
289+ return gsl::span<ValueT const >(reinterpret_cast <ValueT const *>(ref.payload ), payloadSize / sizeof (ValueT));
295290
296291 // implementation (g)
297292 } else if constexpr (is_container<T>::value) {
298293 // currently implemented only for vectors
299294 if constexpr (is_specialization<typename std::remove_const<T>::type, std::vector>::value) {
300295 auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
296+ auto payloadSize = DataRefUtils::getPayloadSize (ref);
301297 auto method = header->payloadSerializationMethod ;
302298 if (method == o2::header::gSerializationMethodNone ) {
303299 // TODO: construct a vector spectator
304300 // this is a quick solution now which makes a copy of the plain vector data
305301 auto * start = reinterpret_cast <typename T::value_type const *>(ref.payload );
306- auto * end = start + header-> payloadSize / sizeof (typename T::value_type);
302+ auto * end = start + payloadSize / sizeof (typename T::value_type);
307303 T result (start, end);
308304 return result;
309305 } else if (method == o2::header::gSerializationMethodROOT ) {
@@ -358,6 +354,7 @@ class InputRecord
358354 using ValueT = typename std::remove_pointer<T>::type;
359355
360356 auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
357+ auto payloadSize = DataRefUtils::getPayloadSize (ref);
361358 auto method = header->payloadSerializationMethod ;
362359 if (method == o2::header::gSerializationMethodNone ) {
363360 if constexpr (is_messageable<ValueT>::value) {
@@ -369,7 +366,7 @@ class InputRecord
369366 // TODO: construct a vector spectator
370367 // this is a quick solution now which makes a copy of the plain vector data
371368 auto * start = reinterpret_cast <typename ValueT::value_type const *>(ref.payload );
372- auto * end = start + header-> payloadSize / sizeof (typename ValueT::value_type);
369+ auto * end = start + payloadSize / sizeof (typename ValueT::value_type);
373370 auto container = std::make_unique<ValueT>(start, end);
374371 std::unique_ptr<ValueT const , Deleter<ValueT const >> result (container.release (), Deleter<ValueT const >(true ));
375372 return result;
@@ -425,9 +422,7 @@ class InputRecord
425422 T get_boost (char const * binding) const
426423 {
427424 DataRef ref = get<DataRef>(binding);
428- auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
429- assert (header);
430- auto str = std::string (ref.payload , header->payloadSize );
425+ auto str = std::string (ref.payload , DataRefUtils::getPayloadSize (ref));
431426 auto desData = o2::utils::BoostDeserialize<T>(str);
432427 return std::move (desData);
433428 }
0 commit comments