Skip to content

Commit 2c35608

Browse files
committed
Add chunk_memory_layout parameter to xchunk_store_manager constructor
1 parent b72191a commit 2c35608

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

include/xtensor-io/xchunk_store_manager.hpp

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace xt
7373
using shape_type = typename iterable_base::inner_shape_type;
7474

7575
template <class S>
76-
xchunk_store_manager(S&& shape, S&& chunk_shape, const std::string& directory, std::size_t pool_size);
76+
xchunk_store_manager(S&& shape, S&& chunk_shape, const std::string& directory, std::size_t pool_size, layout_type chunk_memory_layout = XTENSOR_DEFAULT_LAYOUT);
7777
~xchunk_store_manager() = default;
7878

7979
xchunk_store_manager(const xchunk_store_manager&) = default;
@@ -138,42 +138,42 @@ 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);
141+
template <class T, class IOH, layout_type L = XTENSOR_DEFAULT_LAYOUT, class IP = xindex_path, class EXT = empty_extension, class S>
142+
xchunked_array<xchunk_store_manager<xfile_array<T, IOH, L>, IP>, EXT>
143+
chunked_file_array(S&& shape, S&& chunk_shape, const std::string& path, std::size_t pool_size = 1, layout_type chunk_memory_layout = XTENSOR_DEFAULT_LAYOUT);
144144

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);
145+
template <class IOH, layout_type L = XTENSOR_DEFAULT_LAYOUT, 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, L>, IP>, EXT>
147+
chunked_file_array(const xexpression<E>& e, S&& chunk_shape, const std::string& path, std::size_t pool_size = 1, layout_type chunk_memory_layout = XTENSOR_DEFAULT_LAYOUT);
148148

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);
149+
template <class IOH, layout_type L = XTENSOR_DEFAULT_LAYOUT, class IP = xindex_path, class EXT = empty_extension, class E>
150+
xchunked_array<xchunk_store_manager<xfile_array<typename E::value_type, IOH, L>, IP>, EXT>
151+
chunked_file_array(const xexpression<E>& e, const std::string& path, std::size_t pool_size = 1, layout_type chunk_memory_layout = XTENSOR_DEFAULT_LAYOUT);
152152

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)
153+
template <class T, class IOH, layout_type L, class IP, class EXT, class S>
154+
inline xchunked_array<xchunk_store_manager<xfile_array<T, IOH, L>, IP>, EXT>
155+
chunked_file_array(S&& shape, S&& chunk_shape, const std::string& path, std::size_t pool_size, layout_type chunk_memory_layout)
156156
{
157-
using chunk_storage = xchunk_store_manager<xfile_array<T, IOH>, IP>;
158-
chunk_storage chunks(shape, chunk_shape, path, pool_size);
157+
using chunk_storage = xchunk_store_manager<xfile_array<T, IOH, L>, IP>;
158+
chunk_storage chunks(shape, chunk_shape, path, pool_size, chunk_memory_layout);
159159
return xchunked_array<chunk_storage, EXT>(std::move(chunks), std::forward<S>(shape), std::forward<S>(chunk_shape));
160160
}
161161

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)
162+
template <class IOH, layout_type L, class IP, class EXT, class E, class S>
163+
inline xchunked_array<xchunk_store_manager<xfile_array<typename E::value_type, IOH, L>, IP>, EXT>
164+
chunked_file_array(const xexpression<E>& e, S&& chunk_shape, const std::string& path, std::size_t pool_size, char chunk_memory_layout)
165165
{
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);
166+
using chunk_storage = xchunk_store_manager<xfile_array<typename E::value_type, IOH, L>, IP>;
167+
chunk_storage chunks(e.derived_cast().shape(), chunk_shape, path, pool_size, chunk_memory_layout);
168168
return xchunked_array<chunk_storage, EXT>(e, chunk_storage(), std::forward<S>(chunk_shape));
169169
}
170170

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)
171+
template <class IOH, layout_type L, class IP, class EXT, class E>
172+
inline xchunked_array<xchunk_store_manager<xfile_array<typename E::value_type, IOH, L>, IP>, EXT>
173+
chunked_file_array(const xexpression<E>& e, const std::string& path, std::size_t pool_size, char chunk_memory_layout)
174174
{
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);
175+
using chunk_storage = xchunk_store_manager<xfile_array<typename E::value_type, IOH, L>, IP>;
176+
chunk_storage chunks(e.derived_cast().shape(), detail::chunk_helper<E>::chunk_shape(e), path, pool_size, chunk_memory_layout);
177177
return xchunked_array<chunk_storage, EXT>(e, chunk_storage());
178178
}
179179

@@ -214,7 +214,8 @@ namespace xt
214214
inline xchunk_store_manager<EC, IP>::xchunk_store_manager(S&& shape,
215215
S&& chunk_shape,
216216
const std::string& directory,
217-
std::size_t pool_size)
217+
std::size_t pool_size,
218+
layout_type chunk_memory_layout)
218219
: m_shape(shape)
219220
, m_chunk_pool(pool_size)
220221
, m_index_pool(pool_size)
@@ -223,7 +224,7 @@ namespace xt
223224
// resize the pool chunks
224225
for (auto& chunk: m_chunk_pool)
225226
{
226-
chunk.resize(chunk_shape);
227+
chunk.resize(chunk_shape, chunk_memory_layout);
227228
chunk.ignore_empty_path(true);
228229
}
229230
m_index_path.set_directory(directory);

0 commit comments

Comments
 (0)