Skip to content

Commit 8e218e7

Browse files
committed
fails on non-empty storage_transformers
1 parent d823bdc commit 8e218e7

File tree

4 files changed

+60
-23
lines changed

4 files changed

+60
-23
lines changed

src/main/java/dev/zarr/zarrjava/v3/ArrayMetadata.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ public ArrayMetadata(
9898
throw new ZarrException(
9999
"Expected node type '" + this.nodeType + "', got '" + nodeType + "'.");
100100
}
101-
101+
if (storageTransformers != null && storageTransformers.length > 0) {
102+
throw new ZarrException(
103+
"Storage transformers are not supported in this version of Zarr Java.");
104+
}
102105
if (chunkGrid instanceof RegularChunkGrid) {
103106
int[] chunkShape = ((RegularChunkGrid) chunkGrid).configuration.chunkShape;
104107
if (shape.length != chunkShape.length) {

src/test/java/dev/zarr/zarrjava/ZarrTest.java

+23-22
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.amazonaws.auth.AWSStaticCredentialsProvider;
44
import com.amazonaws.auth.AnonymousAWSCredentials;
55
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
6+
import com.fasterxml.jackson.databind.JsonMappingException;
67
import com.fasterxml.jackson.databind.ObjectMapper;
78
import com.github.luben.zstd.Zstd;
89
import com.github.luben.zstd.ZstdCompressCtx;
@@ -657,30 +658,30 @@ public void testParallel(boolean useParallel) throws IOException, ZarrException
657658
}
658659

659660
@Test
660-
public void testMetadataAcceptsStorageTransformer() throws ZarrException, IOException {
661-
StoreHandle localStoreHandle = new FilesystemStore(TESTDATA).resolve("storage_transformer");
662-
Map<String, Object>[] storageTransformers1 = Array.open(localStoreHandle).metadata.storageTransformers;
661+
public void testMetadataAcceptsEmptyStorageTransformer() throws ZarrException, IOException {
662+
// non-empty storage transformers are currently not supported
663663

664-
Array array2 = Array.create(
665-
new FilesystemStore(TESTOUTPUT).resolve("storage_transformer"),
666-
Array.metadataBuilder()
667-
.withShape(1)
668-
.withChunkShape(1)
669-
.withDataType(DataType.UINT8)
670-
.withStorageTransformers(new HashMap[]{new HashMap<String, Object>(){
671-
{
672-
put("name", "chunk-manifest-json");
673-
put("configuration", new HashMap<String, Object>(){
674-
{
675-
put("manifest", "./manifest.json");
676-
}
677-
});
678-
}
679-
}})
680-
.build()
664+
Map<String, Object>[] storageTransformersEmpty = Array.open(
665+
new FilesystemStore(TESTDATA).resolve("storage_transformer", "empty")
666+
).metadata.storageTransformers;
667+
assert storageTransformersEmpty.length == 0;
668+
669+
assertThrows(JsonMappingException.class, () -> Array.open(
670+
new FilesystemStore(TESTDATA).resolve("storage_transformer", "exists"))
681671
);
682-
Map<String, Object>[] storageTransformers2 = array2.metadata.storageTransformers;
683-
assert Maps.difference(storageTransformers1[0], storageTransformers2[0]).areEqual();
672+
673+
ArrayMetadataBuilder builderWithStorageTransformer = Array.metadataBuilder()
674+
.withShape(1)
675+
.withChunkShape(1)
676+
.withDataType(DataType.UINT8)
677+
.withStorageTransformers(new HashMap[]{new HashMap<String, Object>(){{
678+
put("some", "value");
679+
}}});
680+
681+
assertThrows(ZarrException.class, () -> Array.create(
682+
new FilesystemStore(TESTOUTPUT).resolve("storage_transformer"),
683+
builderWithStorageTransformer.build()
684+
));
684685
}
685686
}
686687

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"zarr_format": 3,
3+
"node_type": "array",
4+
"shape": [
5+
1
6+
],
7+
"data_type": "uint8",
8+
"chunk_grid": {
9+
"name": "regular",
10+
"configuration": {
11+
"chunk_shape": [
12+
1
13+
]
14+
}
15+
},
16+
"chunk_key_encoding": {
17+
"name": "default",
18+
"configuration": {
19+
"separator": "/"
20+
}
21+
},
22+
"fill_value": 0,
23+
"codecs": [
24+
{
25+
"name": "bytes",
26+
"configuration": {
27+
"endian": "little"
28+
}
29+
}
30+
],
31+
"attributes": {},
32+
"storage_transformers": []
33+
}

0 commit comments

Comments
 (0)