Skip to content

Commit 51e700f

Browse files
committed
Accept missing "configuration" key for "chunkKeyEncoding".
The DefaultChunkKeyEncoding constructor currently requires a `Configuration` argument, which means that the Jackson deserializer will fail upon attempting to parse array metadata containing a `chunk_key_encoding` like this one: ``` "chunk_key_encoding": { "name": "default" } ``` Instead, it expects, at a minimum: ``` "chunk_key_encoding": { "name": "default", "configuration": {} } ``` I believe Zarr-Java is being too strict here. It is true that that the spec for the "Default chunk key encoding" [1] says nothing about the `configuration` object being optional (it only says that the `separator` member is optional). But the spec for extension points [2] (and `chunk_key_encoding` _is_ an extension point) does say that the `configuration` member MAY be present (and therefore is optional), and in the absence of any overriding statement, I believe `configuration` should be considered optional _also_ in the context of the "Default chunk key encoding" extension. There are definitely OME-Zarr files out in the wild with a missing `configuration` member, for example [3]. This commit relaxes the requirement in the constructor of both the DefaultChunkKeyEncoding and V2ChunkKeyEncoding classes, so that they accept a missing (null) configuration argument and default to using a '/' and '.' separator, respectively. -- [1] https://zarr-specs.readthedocs.io/en/latest/v3/chunk-key-encodings/default/index.html [2] https://zarr-specs.readthedocs.io/en/latest/v3/core/index.html#extension-definition [3] https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.5/idr0066/ExpD_chicken_embryo_MIP.ome.zarr
1 parent 74b5396 commit 51e700f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/main/java/dev/zarr/zarrjava/v3/chunkkeyencoding/DefaultChunkKeyEncoding.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ public class DefaultChunkKeyEncoding extends ChunkKeyEncoding {
1919

2020
@JsonCreator
2121
public DefaultChunkKeyEncoding(
22-
@Nonnull @JsonProperty(value = "configuration", required = true) Configuration configuration
22+
@JsonProperty(value = "configuration") Configuration configuration
2323
) {
24-
this.configuration = configuration;
24+
if (configuration == null) {
25+
this.configuration = new Configuration(Separator.SLASH);
26+
} else {
27+
this.configuration = configuration;
28+
}
2529
}
2630

2731

src/main/java/dev/zarr/zarrjava/v3/chunkkeyencoding/V2ChunkKeyEncoding.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ public class V2ChunkKeyEncoding extends ChunkKeyEncoding {
1919

2020
@JsonCreator
2121
public V2ChunkKeyEncoding(
22-
@Nonnull @JsonProperty(value = "configuration", required = true) Configuration configuration
22+
@JsonProperty(value = "configuration") Configuration configuration
2323
) {
24-
this.configuration = configuration;
24+
if (configuration == null) {
25+
this.configuration = new Configuration(Separator.DOT);
26+
} else {
27+
this.configuration = configuration;
28+
}
2529
}
2630

2731
@Override

0 commit comments

Comments
 (0)