Skip to content

Commit 9d571f9

Browse files
committed
reformat src/main
1 parent 8c2cf89 commit 9d571f9

61 files changed

Lines changed: 4285 additions & 4272 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/dev/zarr/zarrjava/ZarrException.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
public class ZarrException extends Exception {
44

5-
public ZarrException(String message, Throwable cause) {
6-
super(message, cause);
7-
}
5+
public ZarrException(String message, Throwable cause) {
6+
super(message, cause);
7+
}
88

9-
public ZarrException(String message) {
10-
super(message);
11-
}
9+
public ZarrException(String message) {
10+
super(message);
11+
}
1212
}

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

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package dev.zarr.zarrjava.core;
22

33
import dev.zarr.zarrjava.ZarrException;
4+
import dev.zarr.zarrjava.core.codec.CodecPipeline;
45
import dev.zarr.zarrjava.store.FilesystemStore;
56
import dev.zarr.zarrjava.store.StoreHandle;
67
import dev.zarr.zarrjava.utils.IndexingUtils;
78
import dev.zarr.zarrjava.utils.MultiArrayUtils;
89
import dev.zarr.zarrjava.utils.Utils;
9-
import dev.zarr.zarrjava.core.codec.CodecPipeline;
1010
import ucar.ma2.InvalidRangeException;
1111

1212
import javax.annotation.Nonnull;
@@ -21,6 +21,7 @@
2121
public abstract class Array extends AbstractNode {
2222

2323
protected CodecPipeline codecPipeline;
24+
2425
public abstract ArrayMetadata metadata();
2526

2627
protected Array(StoreHandle storeHandle) throws ZarrException {
@@ -47,7 +48,8 @@ public static Array open(StoreHandle storeHandle) throws IOException, ZarrExcept
4748
throw new ZarrException("No Zarr array found at the specified location.");
4849
}
4950
}
50-
/**
51+
52+
/**
5153
* Opens an existing Zarr array at a specified storage location. Automatically detects the Zarr version.
5254
*
5355
* @param path the storage location of the Zarr array
@@ -94,32 +96,32 @@ public void write(long[] offset, ucar.ma2.Array array, boolean parallel) {
9496
chunkStream = chunkStream.parallel();
9597
}
9698
chunkStream.forEach(
97-
chunkCoords -> {
98-
try {
99-
final IndexingUtils.ChunkProjection chunkProjection =
100-
IndexingUtils.computeProjection(chunkCoords, metadata.shape, chunkShape, offset,
101-
shape
102-
);
103-
104-
ucar.ma2.Array chunkArray;
105-
if (IndexingUtils.isFullChunk(chunkProjection.chunkOffset, chunkProjection.shape,
106-
chunkShape
107-
)) {
108-
chunkArray = array.sectionNoReduce(chunkProjection.outOffset,
109-
chunkProjection.shape,
110-
null
111-
);
112-
} else {
113-
chunkArray = readChunk(chunkCoords);
114-
MultiArrayUtils.copyRegion(array, chunkProjection.outOffset, chunkArray,
115-
chunkProjection.chunkOffset, chunkProjection.shape
116-
);
99+
chunkCoords -> {
100+
try {
101+
final IndexingUtils.ChunkProjection chunkProjection =
102+
IndexingUtils.computeProjection(chunkCoords, metadata.shape, chunkShape, offset,
103+
shape
104+
);
105+
106+
ucar.ma2.Array chunkArray;
107+
if (IndexingUtils.isFullChunk(chunkProjection.chunkOffset, chunkProjection.shape,
108+
chunkShape
109+
)) {
110+
chunkArray = array.sectionNoReduce(chunkProjection.outOffset,
111+
chunkProjection.shape,
112+
null
113+
);
114+
} else {
115+
chunkArray = readChunk(chunkCoords);
116+
MultiArrayUtils.copyRegion(array, chunkProjection.outOffset, chunkArray,
117+
chunkProjection.chunkOffset, chunkProjection.shape
118+
);
119+
}
120+
writeChunk(chunkCoords, chunkArray);
121+
} catch (ZarrException | InvalidRangeException e) {
122+
throw new RuntimeException(e);
117123
}
118-
writeChunk(chunkCoords, chunkArray);
119-
} catch (ZarrException | InvalidRangeException e) {
120-
throw new RuntimeException(e);
121-
}
122-
});
124+
});
123125

124126
}
125127

@@ -246,7 +248,7 @@ boolean chunkIsInArray(long[] chunkCoords) {
246248
final int[] chunkShape = metadata().chunkShape();
247249
for (int dimIdx = 0; dimIdx < metadata().ndim(); dimIdx++) {
248250
if (chunkCoords[dimIdx] < 0
249-
|| chunkCoords[dimIdx] * chunkShape[dimIdx] >= metadata().shape[dimIdx]) {
251+
|| chunkCoords[dimIdx] * chunkShape[dimIdx] >= metadata().shape[dimIdx]) {
250252
return false;
251253
}
252254
}
@@ -282,47 +284,47 @@ public ucar.ma2.Array read(final long[] offset, final int[] shape, final boolean
282284
}
283285

284286
final ucar.ma2.Array outputArray = ucar.ma2.Array.factory(metadata.dataType().getMA2DataType(),
285-
shape);
287+
shape);
286288
Stream<long[]> chunkStream = Arrays.stream(IndexingUtils.computeChunkCoords(metadata.shape, chunkShape, offset, shape));
287289
if (parallel) {
288290
chunkStream = chunkStream.parallel();
289291
}
290292
chunkStream.forEach(
291-
chunkCoords -> {
292-
try {
293-
final IndexingUtils.ChunkProjection chunkProjection =
294-
IndexingUtils.computeProjection(chunkCoords, metadata.shape, chunkShape, offset,
295-
shape
296-
);
297-
298-
if (chunkIsInArray(chunkCoords)) {
299-
MultiArrayUtils.copyRegion(metadata.allocateFillValueChunk(),
300-
chunkProjection.chunkOffset, outputArray, chunkProjection.outOffset,
301-
chunkProjection.shape
302-
);
293+
chunkCoords -> {
294+
try {
295+
final IndexingUtils.ChunkProjection chunkProjection =
296+
IndexingUtils.computeProjection(chunkCoords, metadata.shape, chunkShape, offset,
297+
shape
298+
);
299+
300+
if (chunkIsInArray(chunkCoords)) {
301+
MultiArrayUtils.copyRegion(metadata.allocateFillValueChunk(),
302+
chunkProjection.chunkOffset, outputArray, chunkProjection.outOffset,
303+
chunkProjection.shape
304+
);
305+
}
306+
307+
final String[] chunkKeys = metadata.chunkKeyEncoding().encodeChunkKey(chunkCoords);
308+
final StoreHandle chunkHandle = storeHandle.resolve(chunkKeys);
309+
if (!chunkHandle.exists()) {
310+
return;
311+
}
312+
if (codecPipeline.supportsPartialDecode()) {
313+
final ucar.ma2.Array chunkArray = codecPipeline.decodePartial(chunkHandle,
314+
Utils.toLongArray(chunkProjection.chunkOffset), chunkProjection.shape);
315+
MultiArrayUtils.copyRegion(chunkArray, new int[metadata.ndim()], outputArray,
316+
chunkProjection.outOffset, chunkProjection.shape
317+
);
318+
} else {
319+
MultiArrayUtils.copyRegion(readChunk(chunkCoords), chunkProjection.chunkOffset,
320+
outputArray, chunkProjection.outOffset, chunkProjection.shape
321+
);
322+
}
323+
324+
} catch (ZarrException e) {
325+
throw new RuntimeException(e);
303326
}
304-
305-
final String[] chunkKeys = metadata.chunkKeyEncoding().encodeChunkKey(chunkCoords);
306-
final StoreHandle chunkHandle = storeHandle.resolve(chunkKeys);
307-
if (!chunkHandle.exists()) {
308-
return;
309-
}
310-
if (codecPipeline.supportsPartialDecode()) {
311-
final ucar.ma2.Array chunkArray = codecPipeline.decodePartial(chunkHandle,
312-
Utils.toLongArray(chunkProjection.chunkOffset), chunkProjection.shape);
313-
MultiArrayUtils.copyRegion(chunkArray, new int[metadata.ndim()], outputArray,
314-
chunkProjection.outOffset, chunkProjection.shape
315-
);
316-
} else {
317-
MultiArrayUtils.copyRegion(readChunk(chunkCoords), chunkProjection.chunkOffset,
318-
outputArray, chunkProjection.outOffset, chunkProjection.shape
319-
);
320-
}
321-
322-
} catch (ZarrException e) {
323-
throw new RuntimeException(e);
324-
}
325-
});
327+
});
326328
return outputArray;
327329
}
328330

0 commit comments

Comments
 (0)