Skip to content

Commit 1a638e4

Browse files
committed
Add factory chunked_array for stored arrays
1 parent ce9f7cc commit 1a638e4

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

include/xtensor-io/xchunk_store_manager.hpp

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include <vector>
55
#include <array>
66

7-
#include "xarray.hpp"
8-
#include "xcsv.hpp"
9-
#include "xio.hpp"
7+
#include "xtensor/xarray.hpp"
8+
#include "xtensor/xchunked_array.hpp"
9+
#include "xfile_array.hpp"
1010

1111
namespace xt
1212
{
@@ -138,6 +138,45 @@ namespace xt
138138
IP m_index_path;
139139
};
140140

141+
template <class T, class IOH, class IP = xindex_path, class EXT = empty_extension, class S>
142+
xchunked_array<xchunk_store_manager<xfile_array<T, IOH>, IP>, EXT>
143+
chunked_file_array(S&& shape, S&& chunk_shape, const std::string& path, std::size_t pool_size = 1);
144+
145+
template <class IOH, class IP = xindex_path, class EXT = empty_extension, class E, class S>
146+
xchunked_array<xchunk_store_manager<xfile_array<typename E::value_type, IOH>, IP>, EXT>
147+
chunked_file_array(const xexpression<E>& e, S&& chunk_shape, const std::string& path, std::size_t pool_size = 1);
148+
149+
template <class IOH, class IP = xindex_path, class EXT = empty_extension, class E>
150+
xchunked_array<xchunk_store_manager<xfile_array<typename E::value_type, IOH>, IP>, EXT>
151+
chunked_file_array(const xexpression<E>& e, const std::string& path, std::size_t pool_size = 1);
152+
153+
template <class T, class IOH, class IP, class EXT, class S>
154+
inline xchunked_array<xchunk_store_manager<xfile_array<T, IOH>, IP>, EXT>
155+
chunked_file_array(S&& shape, S&& chunk_shape, const std::string& path, std::size_t pool_size)
156+
{
157+
using chunk_storage = xchunk_store_manager<xfile_array<T, IOH>, IP>;
158+
chunk_storage chunks(shape, chunk_shape, path, pool_size);
159+
return xchunked_array<chunk_storage, EXT>(std::move(chunks), std::forward<S>(shape), std::forward<S>(chunk_shape));
160+
}
161+
162+
template <class IOH, class IP, class EXT, class E, class S>
163+
inline xchunked_array<xchunk_store_manager<xfile_array<typename E::value_type, IOH>, IP>, EXT>
164+
chunked_file_array(const xexpression<E>& e, S&& chunk_shape, const std::string& path, std::size_t pool_size)
165+
{
166+
using chunk_storage = xchunk_store_manager<xfile_array<typename E::value_type, IOH>, IP>;
167+
chunk_storage chunks(e.derived_cast().shape(), chunk_shape, path, pool_size);
168+
return xchunked_array<chunk_storage, EXT>(e, chunk_storage(), std::forward<S>(chunk_shape));
169+
}
170+
171+
template <class IOH, class IP, class EXT, class E>
172+
inline xchunked_array<xchunk_store_manager<xfile_array<typename E::value_type, IOH>, IP>, EXT>
173+
chunked_file_array(const xexpression<E>& e, const std::string& path, std::size_t pool_size)
174+
{
175+
using chunk_storage = xchunk_store_manager<xfile_array<typename E::value_type, IOH>, IP>;
176+
chunk_storage chunks(e.derived_cast().shape(), detail::chunk_helper<E>::chunk_shape(e), path, pool_size);
177+
return xchunked_array<chunk_storage, EXT>(e, chunk_storage());
178+
}
179+
141180
/******************************
142181
* xindex_path implementation *
143182
******************************/

0 commit comments

Comments
 (0)