MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kakshya::DataFieldTraversal< Array > Class Template Reference

On-demand windowing and field operations over an indexed array. More...

#include <DataFieldTraversal.hpp>

+ Collaboration diagram for MayaFlux::Kakshya::DataFieldTraversal< Array >:

Public Member Functions

void advance (size_t rows=0)
 Move forward without passing the end of the array.
 
bool at_end () const
 Whether there are no elements after the current position.
 
size_t batch_size () const noexcept
 Current window size.
 
auto current () const
 Borrow the current window, including a short final window.
 
 DataFieldTraversal (const Array &array, size_t batch_size=1) noexcept
 Borrow an array and set the initial window size.
 
template<typename Fn >
void for_each (Fn &&fn) const
 Apply a callable to each available element in the array.
 
template<typename Fn >
void for_each_in_window (Fn &&fn) const
 Apply a callable to each available element in the current window.
 
size_t position () const noexcept
 Current zero-based element position.
 
template<typename Acc , typename Fn >
Acc reduce (Acc init, Fn &&fn) const
 Fold all available elements into an accumulator.
 
size_t remaining () const
 Number of elements after the current position.
 
void seek (size_t row)
 Set the position, clamped to the end of the array.
 
void set_batch_size (size_t rows) noexcept
 Set the window size for subsequent operations.
 
template<typename ValueT >
requires requires(const Array& array, std::string_view name) { array.template to_nddata<ValueT>(name); }
auto to_nddata (std::string_view field_name) const
 Derive homogeneous NDData from one field across the entire array.
 
template<typename ValueT >
requires requires(const Array& array, std::string_view name) { array.slice(size_t {}, size_t {})->template to_nddata<ValueT>(name); }
auto window_to_nddata (std::string_view field_name) const
 Derive homogeneous NDData from one field in the current window.
 

Private Attributes

const Array * m_array
 
size_t m_batch_size
 
size_t m_position {}
 

Detailed Description

template<FieldArray Array>
class MayaFlux::Kakshya::DataFieldTraversal< Array >

On-demand windowing and field operations over an indexed array.

A traversal maintains an independent position and batch size without owning the array. Field projection is available when the array and its slices provide to_nddata<T>(field_name). The same traversal works with any FieldArray; neither it nor the array needs to name a concrete record format.

Usage:

DataFieldTraversal traversal(items, 64);
while (!traversal.at_end()) {
auto scores = traversal.window_to_nddata<double>("score");
traversal.for_each_in_window([](const auto& item) {
auto name = item.text("name");
});
traversal.advance();
}
std::string name
Definition VKDevice.cpp:123
On-demand windowing and field operations over an indexed array.
Template Parameters
ArrayIndexed array satisfying FieldArray.
Note
Borrowed elements and windows remain subject to the array's own lifetime and invalidation rules. Keep the array at a stable address while using a traversal.

Definition at line 46 of file DataFieldTraversal.hpp.


The documentation for this class was generated from the following file: