Skip to content

Commit

Permalink
Merge pull request #40 from davidbrochart/v2_dimension_separator
Browse files Browse the repository at this point in the history
Support zarr v2 dimension separator
  • Loading branch information
davidbrochart committed Apr 20, 2021
2 parents 9971302 + 5d38910 commit 484f98b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
35 changes: 30 additions & 5 deletions include/xtensor-zarr/xzarr_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ namespace xt
case 3:
j["chunk_grid"]["type"] = "regular";
j["chunk_grid"]["chunk_shape"] = chunk_shape;
if (chunk_separator == 0)
{
chunk_separator = '/';
}
j["chunk_grid"]["separator"] = std::string(1, chunk_separator);
j["data_type"] = dtype;
j["chunk_memory_layout"] = std::string(1, chunk_memory_layout);
Expand All @@ -42,7 +46,14 @@ namespace xt
break;
case 2:
j["chunks"] = chunk_shape;
chunk_separator = '.';
if (chunk_separator == 0)
{
chunk_separator = '.';
}
else
{
j["dimension_separator"] = std::string(1, chunk_separator);
}
j["dtype"] = dtype;
j["order"] = std::string(1, chunk_memory_layout);
if (compressor.name == "binary")
Expand Down Expand Up @@ -144,10 +155,24 @@ namespace xt
json_chunk_shape = j["chunks"];
dtype = j["dtype"];
chunk_memory_layout = j["order"];
compressor = j["compressor"]["id"];
compressor_config = j["compressor"];
compressor_config.erase("id");
chunk_separator = '.';
if (j["compressor"].is_null())
{
compressor = "binary";
}
else
{
compressor = j["compressor"]["id"];
compressor_config = j["compressor"];
compressor_config.erase("id");
}
if (j.contains("dimension_separator"))
{
chunk_separator = j["dimension_separator"];
}
else
{
chunk_separator = '.';
}
full_path = store.get_root() + '/' + path;
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion include/xtensor-zarr/xzarr_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace xt

xzarr_create_array_options()
: chunk_memory_layout('C')
, chunk_separator('/')
, chunk_separator(0)
, compressor(C())
, attrs(nlohmann::json::object())
, chunk_pool_size(1)
Expand Down

0 comments on commit 484f98b

Please sign in to comment.