MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ merge_chunks_to_result()

template<ComputeData InputType = Kakshya::DataVariant, ComputeData OutputType = InputType>
output_type MayaFlux::Yantra::StandardSorter< InputType, OutputType >::merge_chunks_to_result ( const std::vector< InputType > &  chunks,
const input_type &  original_input,
DataStructureInfo  info 
)
inlineprivate

Merge chunks back to single result.

Definition at line 341 of file StandardSorter.hpp.

342 {
343 output_type result {};
344 result.metadata = original_input.metadata;
345 result.metadata["sort_type"] = "chunked_merged";
346
347 if constexpr (std::same_as<InputType, OutputType>) {
348 if (chunks.empty()) {
349 return result;
350 }
351
352 try {
353 std::vector<std::vector<double>> merged_channels;
354
355 for (const auto& chunk : chunks) {
356 auto chunk_channels = OperationHelper::extract_numeric_data(chunk);
357
358 if (merged_channels.empty()) {
359 merged_channels.resize(chunk_channels.size());
360 }
361
362 for (size_t ch = 0; ch < chunk_channels.size() && ch < merged_channels.size(); ++ch) {
363 merged_channels[ch].insert(merged_channels[ch].end(),
364 chunk_channels[ch].begin(), chunk_channels[ch].end());
365 }
366 }
367
368 result = this->convert_result(merged_channels, info);
369 result.metadata = original_input.metadata;
370 result.metadata["sort_type"] = "chunked_merged";
371
372 } catch (...) {
373 result.data = chunks[0];
374 }
375 }
376
377 return result;
378 }
output_type convert_result(std::vector< std::vector< double > > &result_data, DataStructureInfo &metadata)
Convert processed double data back to OutputType using metadata and optional callback.
static std::span< double > extract_numeric_data(const T &compute_data)
extract numeric data from single-variant types
typename base_type::output_type output_type
std::unordered_map< std::string, std::any > metadata
Associated metadata.
Definition DataIO.hpp:30

References MayaFlux::Yantra::ComputeOperation< InputType, OutputType >::convert_result(), and MayaFlux::Yantra::OperationHelper::extract_numeric_data().

Referenced by MayaFlux::Yantra::StandardSorter< InputType, OutputType >::sort_chunked().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: