Skip to content

Commit ce38d05

Browse files
committed
Add test for chunked zarray assignment
1 parent 4524240 commit ce38d05

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

include/xtensor-zarr/xzarr_aws_store.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ namespace xt
115115
request.SetKey(m_path);
116116

117117
std::shared_ptr<Aws::IOStream> writer = Aws::MakeShared<Aws::FStream>("SampleAllocationTag", m_path.c_str(), std::ios_base::in | std::ios_base::binary);
118-
writer->write(value, size);
118+
writer->write(value, (std::streamsize)size);
119119
writer->flush();
120120

121121
request.SetBody(writer);

include/xtensor-zarr/xzarr_common.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ namespace xt
2020
std::size_t zarr_major;
2121
if (i == std::string::npos)
2222
{
23-
zarr_major = std::stoi(zarr_version);
23+
zarr_major = (std::size_t)std::stoi(zarr_version);
2424
}
2525
else
2626
{
27-
zarr_major = std::stoi(zarr_version.substr(0, i));
27+
zarr_major = (std::size_t)std::stoi(zarr_version.substr(0, i));
2828
}
2929
if ((zarr_major < 2) || (zarr_major > 3))
3030
{

include/xtensor-zarr/xzarr_file_system_store.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ namespace xt
129129
}
130130
}
131131
std::ofstream stream(m_path, std::ofstream::binary);
132-
stream.write(value, size);
132+
stream.write(value, (std::streamsize)size);
133133
stream.flush();
134134
}
135135

include/xtensor-zarr/xzarr_gcs_store.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace xt
9595
void xzarr_gcs_stream::assign(const char* value, std::size_t size)
9696
{
9797
auto writer = m_client.WriteObject(m_bucket, m_path);
98-
writer.write(value, size);
98+
writer.write(value, (std::streamsize)size);
9999
writer.flush();
100100
}
101101

test/test_zarr.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ namespace xt
156156
"data/root/arthur/dent/c1/1",
157157
"data/root/arthur/dent/c2/0",
158158
"data/root/arthur/dent/c2/1"};
159-
for (int i = 0; i < 6; i++)
159+
for (unsigned long int i = 0; i < 6; i++)
160160
{
161161
EXPECT_EQ(keys1[i], ref1[i]);
162162
}
@@ -165,7 +165,7 @@ namespace xt
165165
auto keys2 = s2.list();
166166
std::string ref2[] = {"android.array.json",
167167
"paranoid.group.json"};
168-
for (int i = 0; i < 2; i++)
168+
for (unsigned long int i = 0; i < 2; i++)
169169
{
170170
EXPECT_EQ(keys2[i], ref2[i]);
171171
// we don't have rights to erase objects in this bucket as an anonymous client
@@ -184,4 +184,15 @@ namespace xt
184184
auto h = create_zarr_hierarchy("h_xtensor.zr2", zarr_version);
185185
zarray z1 = h.create_array("/arthur/dent", shape, chunk_shape, "<f8", 'C', '.', xio_gzip_config(), attrs, pool_size, fill_value);
186186
}
187+
188+
TEST(xzarr_hierarchy, zarr_assign)
189+
{
190+
std::vector<size_t> shape = {4, 4};
191+
std::vector<size_t> chunk_shape = {2, 2};
192+
auto h1 = create_zarr_hierarchy("src.zr3");
193+
zarray z1 = h1.create_array("/", shape, chunk_shape, "<f8", 'C', '.', xio_gzip_config());
194+
auto h2 = create_zarr_hierarchy("dst.zr3");
195+
zarray z2 = h2.create_array("/", shape, chunk_shape, "<f8", 'C', '.', xio_gzip_config());
196+
z2 = z1;
197+
}
187198
}

0 commit comments

Comments
 (0)