| 12 | namespace nd { |
| 13 | |
| 14 | class string_stream_array_holder |
| 15 | { |
| 16 | public: |
| 17 | string_stream_array_holder() = default; |
| 18 | explicit string_stream_array_holder(const nd::array& arr); |
| 19 | std::string_view data(int64_t index) const; |
| 20 | |
| 21 | inline bool is_valid() const noexcept |
| 22 | { |
| 23 | return is_valid_; |
| 24 | } |
| 25 | |
| 26 | private: |
| 27 | // Storage - kept as separate members for cache efficiency |
| 28 | nd::array vstack_holder_; |
| 29 | std::vector<int64_t> offsets_; |
| 30 | std::vector<int64_t> range_offsets_; |
| 31 | std::vector<const void*> holders_; |
| 32 | const void* dynamic_std_holder_ = nullptr; |
| 33 | const void* dynamic_icm_holder_ = nullptr; |
| 34 | bool is_valid_ = true; |
| 35 | |
| 36 | void initialize(const nd::array& arr); |
| 37 | void initialize_single_range(const auto& range_adapter); |
| 38 | void initialize_complex(const nd::array& arr); |
| 39 | bool try_initialize_range_arrays(const auto& vstacked, const nd::array& fallback); |
| 40 | void clear_range_data(); |
| 41 | std::string_view get_range_data(int64_t index) const; |
| 42 | std::string_view get_dynamic_data(int64_t index) const; |
| 43 | std::string_view get_vstack_data(int64_t index) const; |
| 44 | }; |
| 45 | |
| 46 | } // namespace nd |