@@ -662,7 +662,7 @@ public void testMetadataAcceptsEmptyStorageTransformer() throws ZarrException, I
662662
663663 @ ParameterizedTest
664664 @ CsvSource ({"blosclz,noshuffle,0" , "lz4,shuffle,6" , "lz4hc,bitshuffle,3" , "zlib,shuffle,5" , "zstd,bitshuffle,9" })
665- public void testV2create (String cname , String shuffle , int clevel ) throws IOException , ZarrException {
665+ public void testV2createBlosc (String cname , String shuffle , int clevel ) throws IOException , ZarrException {
666666 dev .zarr .zarrjava .v2 .Array array = dev .zarr .zarrjava .v2 .Array .create (
667667 new FilesystemStore (TESTOUTPUT ).resolve ("v2_create" , cname + "_" + shuffle + "_" + clevel ),
668668 dev .zarr .zarrjava .v2 .Array .metadataBuilder ()
@@ -679,4 +679,66 @@ public void testV2create(String cname, String shuffle, int clevel) throws IOExce
679679 Assertions .assertEquals (outArray .getSize (), 8 * 8 );
680680 Assertions .assertEquals (outArray .getByte (0 ), 0 );
681681 }
682+
683+ @ Test
684+ public void testV2create () throws IOException , ZarrException {
685+ DataType dataType = DataType .UINT32 ;
686+
687+ dev .zarr .zarrjava .v2 .Array array = dev .zarr .zarrjava .v2 .Array .create (
688+ new FilesystemStore (TESTOUTPUT ).resolve ("v2_create" ),
689+ dev .zarr .zarrjava .v2 .Array .metadataBuilder ()
690+ .withShape (10 , 10 )
691+ .withDataType (dataType )
692+ .withChunks (5 , 5 )
693+ .withFillValue (2 )
694+ .build ()
695+ );
696+ array .write (new long []{2 , 2 }, ucar .ma2 .Array .factory (dataType .getMA2DataType (), new int []{8 , 8 }));
697+
698+ ucar .ma2 .Array outArray = array .read (new long []{2 , 2 }, new int []{8 , 8 });
699+ Assertions .assertEquals (outArray .getSize (), 8 * 8 );
700+ Assertions .assertEquals (outArray .getByte (0 ), 0 );
701+ }
702+
703+ @ Test
704+ public void testV2Filters () throws IOException , ZarrException {
705+ DataType dataType = DataType .UINT32 ;
706+
707+ dev .zarr .zarrjava .v2 .Array array = dev .zarr .zarrjava .v2 .Array .create (
708+ new FilesystemStore (TESTOUTPUT ).resolve ("v2_create" ),
709+ dev .zarr .zarrjava .v2 .Array .metadataBuilder ()
710+ .withShape (10 , 10 )
711+ .withDataType (dataType )
712+ .withChunks (5 , 5 )
713+ .withFillValue (2 )
714+ .withFilters (f -> f .withTranspose (new int []{1 , 0 }))
715+ .build ()
716+ );
717+ array .write (new long []{2 , 2 }, ucar .ma2 .Array .factory (dataType .getMA2DataType (), new int []{8 , 8 }));
718+
719+ ucar .ma2 .Array outArray = array .read (new long []{2 , 2 }, new int []{8 , 8 });
720+ Assertions .assertEquals (outArray .getSize (), 8 * 8 );
721+ Assertions .assertEquals (outArray .getByte (0 ), 0 );
722+ }
723+
724+
725+ @ ParameterizedTest
726+ @ ValueSource (ints = {0 , 1 , 5 , 9 })
727+ public void testV2createZlib (int level ) throws IOException , ZarrException {
728+ dev .zarr .zarrjava .v2 .Array array = dev .zarr .zarrjava .v2 .Array .create (
729+ new FilesystemStore (TESTOUTPUT ).resolve ("v2_create_zlib" , String .valueOf (level )),
730+ dev .zarr .zarrjava .v2 .Array .metadataBuilder ()
731+ .withShape (15 , 10 )
732+ .withDataType (DataType .UINT8 )
733+ .withChunks (4 , 5 )
734+ .withFillValue (5 )
735+ .withZlibCompressor (level )
736+ .build ()
737+ );
738+ array .write (new long []{2 , 2 }, ucar .ma2 .Array .factory (ucar .ma2 .DataType .UBYTE , new int []{7 , 6 }));
739+
740+ ucar .ma2 .Array outArray = array .read (new long []{2 , 2 }, new int []{7 , 6 });
741+ Assertions .assertEquals (outArray .getSize (), 7 * 6 );
742+ Assertions .assertEquals (outArray .getByte (0 ), 0 );
743+ }
682744}
0 commit comments