Skip to content

Commit d584375

Browse files
Copilotbrokkoli71
andcommitted
Address code review feedback and add detailed documentation
Co-authored-by: brokkoli71 <44113112+brokkoli71@users.noreply.github.com>
1 parent f379ea1 commit d584375

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/main/java/dev/zarr/zarrjava/v2/Array.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ private static Separator detectDimensionSeparator(StoreHandle storeHandle, int[]
288288
}
289289

290290
try {
291-
// List all files in the array directory
291+
// List all files in the array directory, excluding metadata files (.zarray, .zattrs, .zgroup)
292292
String[] chunkFiles = storeHandle.list()
293-
.filter(key -> !key.startsWith(".z")) // Exclude metadata files
293+
.filter(key -> !key.startsWith(".z"))
294294
.toArray(String[]::new);
295295

296296
if (chunkFiles.length == 0) {

src/main/java/dev/zarr/zarrjava/v2/ArrayMetadataBuilder.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,14 @@ public ArrayMetadata build() throws ZarrException {
171171

172172
/**
173173
* Calculate default chunk shape when not specified.
174-
* Similar to JZarr's ArrayParams.build() logic, targeting chunks of about size 512.
174+
* This implements JZarr's ArrayParams.build() logic, targeting chunks of approximately 512 elements.
175+
*
176+
* The algorithm divides each dimension by 512 to determine the number of ~512-sized chunks,
177+
* then calculates chunk sizes that will cover the dimension. Note that the total coverage
178+
* may slightly exceed the dimension size (e.g., for shape=1024, chunks=342 results in
179+
* 3 chunks covering 1026 elements). This is intentional and matches JZarr behavior -
180+
* Zarr handles out-of-bounds gracefully, and the goal is approximate chunk sizes rather
181+
* than perfect tiling.
175182
*/
176183
private int[] calculateDefaultChunks(long[] shape) {
177184
int[] chunks = new int[shape.length];

0 commit comments

Comments
 (0)