Array Creation
JZarr has several functions for creating arrays.
Arrays can be created with or without a given storage.
If no storage is given a store in memory is used as default.
Arrays can be created with or without additional user defined attributes.
The shape is the only mandatory information which must be given to create arrays.
Simple small array
ZarrArray jZarray = ZarrArray.create(new ArrayParams()
.shape(10, 8)
);
A System.out.println(array); then creates the following output
com.bc.zarr.ZarrArray{'/' shape=[10, 8], chunks=[10, 8], dataType=f8, fillValue=0, compressor=blosc/cname=lz4/clevel=5/blocksize=0/shuffle=1, store=InMemoryStore, byteOrder=BIG_ENDIAN}
The output describes that an array with the following characteristics has been created
property |
value |
|---|---|
shape |
y:10 x:8 |
chunks |
y:10 x:8 |
data type |
f8 |
data type |
f8 |
fill value |
|
compressor |
blosc compressor with default settings |
store |
InMemoryStore |
byte order |
BIG_ENDIAN |
- Why are chunks dimensions the same as shape dimension?
- If chunks is not given, a default chunks size of 512 in each dimension, will be applied.If a chunk dimension is bigger than the corresponding shape dimension, the chunk dimension will be trimmed to shape dimension.For detailed explanation see Array Parameter explanation
Array with automatically computed chunk size
ZarrArray jZarray = ZarrArray.create(new ArrayParams()
.shape(4000, 3500)
);
A System.out.println(array); then creates the following output
com.bc.zarr.ZarrArray{'/' shape=[4000, 3500], chunks=[500, 500], dataType=f8, fillValue=0, compressor=blosc/cname=lz4/clevel=5/blocksize=0/shuffle=1, store=InMemoryStore, byteOrder=BIG_ENDIAN}
As you can see now, the chunk size in both dimensions is 500. This is an autogenerated chunk size.
Array with disabled chunking
ZarrArray jZarray = ZarrArray.create(new ArrayParams()
.shape(4000, 3500)
.chunked(false)
);
A System.out.println(array); then creates the following output
com.bc.zarr.ZarrArray{'/' shape=[4000, 3500], chunks=[4000, 3500], dataType=f8, fillValue=0, compressor=blosc/cname=lz4/clevel=5/blocksize=0/shuffle=1, store=InMemoryStore, byteOrder=BIG_ENDIAN}
Now you can see, the chunk size ins the same as shape size.
Array with user defined chunks
ZarrArray jZarray = ZarrArray.create(new ArrayParams()
.shape(4000, 3500)
.chunks(400, 350)
);
A System.out.println(array); then creates the following output
com.bc.zarr.ZarrArray{'/' shape=[4000, 3500], chunks=[400, 350], dataType=f8, fillValue=0, compressor=blosc/cname=lz4/clevel=5/blocksize=0/shuffle=1, store=InMemoryStore, byteOrder=BIG_ENDIAN}
Chunk size now are user defined [400, 350] .