Skip to content

Commit c726ff8

Browse files
committed
reformat
1 parent 329e6e1 commit c726ff8

5 files changed

Lines changed: 35 additions & 47 deletions

File tree

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import dev.zarr.zarrjava.ZarrException;
44
import dev.zarr.zarrjava.core.codec.CodecPipeline;
55
import dev.zarr.zarrjava.store.FilesystemStore;
6-
import dev.zarr.zarrjava.store.Store;
76
import dev.zarr.zarrjava.store.StoreHandle;
87
import dev.zarr.zarrjava.utils.IndexingUtils;
98
import dev.zarr.zarrjava.utils.MultiArrayUtils;
@@ -17,9 +16,6 @@
1716
import java.nio.file.Path;
1817
import java.nio.file.Paths;
1918
import java.util.Arrays;
20-
import java.util.List;
21-
import java.util.Set;
22-
import java.util.stream.Collectors;
2319
import java.util.stream.Stream;
2420

2521
public abstract class Array extends AbstractNode {

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public void testParallelWriteDataSafety() throws IOException, ZarrException {
2020
// Test internal parallelism of write method (using parallel=true)
2121
Path path = TESTOUTPUT.resolve("parallel_write_safety");
2222
StoreHandle storeHandle = new FilesystemStore(path).resolve();
23-
23+
2424
int shape = 1000;
2525
int chunk = 100;
26-
26+
2727
Array array = Array.create(storeHandle, Array.metadataBuilder()
2828
.withShape(shape, shape)
2929
.withDataType(DataType.INT32)
@@ -36,16 +36,16 @@ public void testParallelWriteDataSafety() throws IOException, ZarrException {
3636
for (int i = 0; i < shape * shape; i++) {
3737
data[i] = i;
3838
}
39-
39+
4040
ucar.ma2.Array outputData = ucar.ma2.Array.factory(ucar.ma2.DataType.INT, new int[]{shape, shape}, data);
41-
41+
4242
// Write in parallel
4343
array.write(outputData, true);
44-
44+
4545
// Read back
4646
ucar.ma2.Array readData = array.read();
4747
int[] readArr = (int[]) readData.get1DJavaArray(ucar.ma2.DataType.INT);
48-
48+
4949
Assertions.assertArrayEquals(data, readArr, "Data read back should match data written in parallel");
5050
}
5151

@@ -54,11 +54,11 @@ public void testParallelWriteWithSharding() throws IOException, ZarrException {
5454
// Test internal parallelism with Sharding (nested chunks + shared codec state potential)
5555
Path path = TESTOUTPUT.resolve("parallel_write_sharding");
5656
StoreHandle storeHandle = new FilesystemStore(path).resolve();
57-
57+
5858
int shape = 128; // 128x128
5959
int shardSize = 64; // Shards are 64x64
6060
int innerChunk = 32; // Inner chunks 32x32
61-
61+
6262
// Metadata with sharding
6363
// With shape 128 and shardSize 64, we have 2x2 = 4 shards.
6464
// Array.write(parallel=true) will likely process these shards concurrently.
@@ -71,20 +71,20 @@ public void testParallelWriteWithSharding() throws IOException, ZarrException {
7171
.build();
7272

7373
Array array = Array.create(storeHandle, metadata);
74-
74+
7575
int[] data = new int[shape * shape];
7676
for (int i = 0; i < shape * shape; i++) {
7777
data[i] = i;
7878
}
79-
79+
8080
ucar.ma2.Array outputData = ucar.ma2.Array.factory(ucar.ma2.DataType.INT, new int[]{shape, shape}, data);
81-
81+
8282
// Write in parallel
8383
array.write(outputData, true);
84-
84+
8585
ucar.ma2.Array readData = array.read();
8686
int[] readArr = (int[]) readData.get1DJavaArray(ucar.ma2.DataType.INT);
87-
87+
8888
Assertions.assertArrayEquals(data, readArr, "Sharded data written in parallel should match");
8989
}
9090

@@ -93,7 +93,7 @@ public void testConcurrentWritesDifferentChunks() throws IOException, ZarrExcept
9393
// Test external parallelism (multiple threads calling write on same Array instance)
9494
Path path = TESTOUTPUT.resolve("concurrent_write_safety");
9595
StoreHandle storeHandle = new FilesystemStore(path).resolve();
96-
96+
9797
int chunksX = 10;
9898
int chunksY = 10;
9999
int chunkSize = 50;
@@ -118,20 +118,20 @@ public void testConcurrentWritesDifferentChunks() throws IOException, ZarrExcept
118118
int[] chunkData = new int[chunkSize * chunkSize];
119119
int val = cx * chunksY + cy; // Unique value per chunk
120120
java.util.Arrays.fill(chunkData, val);
121-
121+
122122
ucar.ma2.Array ucarArray = ucar.ma2.Array.factory(ucar.ma2.DataType.INT, new int[]{chunkSize, chunkSize}, chunkData);
123-
123+
124124
// Write to specific chunk offset
125125
long[] offset = new long[]{cx * chunkSize, cy * chunkSize};
126126
// Use internal parallelism false to isolate external concurrency test mechanism
127-
array.write(offset, ucarArray, false);
127+
array.write(offset, ucarArray, false);
128128
return null;
129129
});
130130
}
131131
}
132132

133133
List<Future<Void>> futures = executor.invokeAll(tasks);
134-
134+
135135
for (Future<Void> f : futures) {
136136
f.get(); // Check for exceptions
137137
}
@@ -141,13 +141,13 @@ public void testConcurrentWritesDifferentChunks() throws IOException, ZarrExcept
141141
ucar.ma2.Array readData = array.read();
142142
for (int i = 0; i < chunksX; i++) {
143143
for (int j = 0; j < chunksY; j++) {
144-
int expectedVal = i * chunksY + j;
145-
int originX = i * chunkSize;
146-
int originY = j * chunkSize;
147-
148-
// Verify a pixel in the chunk
149-
int val = readData.getInt(readData.getIndex().set(originX, originY));
150-
Assertions.assertEquals(expectedVal, val, "Value at chunk " + i + "," + j + " mismatch");
144+
int expectedVal = i * chunksY + j;
145+
int originX = i * chunkSize;
146+
int originY = j * chunkSize;
147+
148+
// Verify a pixel in the chunk
149+
int val = readData.getInt(readData.getIndex().set(originX, originY));
150+
Assertions.assertEquals(expectedVal, val, "Value at chunk " + i + "," + j + " mismatch");
151151
}
152152
}
153153
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void testInversePermutation() {
3030
}
3131

3232
@Test
33-
public void testComputeChunkCoords(){
33+
public void testComputeChunkCoords() {
3434
long[] arrayShape = new long[]{100, 100};
3535
int[] chunkShape = new int[]{30, 30};
3636
long[] selOffset = new long[]{50, 20};
@@ -56,7 +56,7 @@ public void testComputeChunkCoords(){
5656
}
5757

5858
@Test
59-
public void testComputeProjection(){
59+
public void testComputeProjection() {
6060
// chunk (0,2) contains indexes 34-50 along axis 1
6161
// thus the overlap with selection 32-52 is 34-50
6262
// which is offset 2 in the selection and offset 0 in the chunk
@@ -71,8 +71,8 @@ public void testComputeProjection(){
7171
chunkCoords, arrayShape, chunkShape, selOffset, selShape
7272
);
7373
Assertions.assertArrayEquals(chunkCoords, projection.chunkCoords);
74-
Assertions.assertArrayEquals(new int[]{0,0}, projection.chunkOffset);
75-
Assertions.assertArrayEquals(new int[]{0,2}, projection.outOffset);
74+
Assertions.assertArrayEquals(new int[]{0, 0}, projection.chunkOffset);
75+
Assertions.assertArrayEquals(new int[]{0, 2}, projection.outOffset);
7676
Assertions.assertArrayEquals(new int[]{1, 17}, projection.shape);
7777
}
7878

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,10 @@ public void testUpdateAttributesBehavior() throws IOException, ZarrException {
348348
Assertions.assertNotSame(array1, array2);
349349
Assertions.assertEquals("val1", array1.metadata().attributes().get("key1"));
350350
Assertions.assertNull(array1.metadata().attributes().get("key2"));
351-
351+
352352
Assertions.assertEquals("val1", array2.metadata().attributes().get("key1"));
353353
Assertions.assertEquals("val2", array2.metadata().attributes().get("key2"));
354-
354+
355355
// Re-opening should show the updated attributes
356356
Array array3 = Array.open(storeHandle);
357357
Assertions.assertEquals("val2", array3.metadata().attributes().get("key2"));
@@ -409,9 +409,7 @@ public void testResizeArrayShrink() throws IOException, ZarrException {
409409
ucar.ma2.Array data = array.read();
410410
int[] expectedData = new int[5 * 5];
411411
for (int i = 0; i < 5; i++) {
412-
for (int j = 0; j < 5; j++) {
413-
expectedData[i * 5 + j] = testData[i * 10 + j];
414-
}
412+
System.arraycopy(testData, i * 10 + 0, expectedData, i * 5 + 0, 5);
415413
}
416414
Assertions.assertArrayEquals(expectedData, (int[]) data.get1DJavaArray(ma2DataType));
417415
}
@@ -451,9 +449,7 @@ public void testResizeArrayShrinkWithChunkCleanup() throws IOException, ZarrExce
451449
ucar.ma2.Array data = array.read();
452450
int[] expectedData = new int[5 * 5];
453451
for (int i = 0; i < 5; i++) {
454-
for (int j = 0; j < 5; j++) {
455-
expectedData[i * 5 + j] = testData[i * 10 + j];
456-
}
452+
System.arraycopy(testData, i * 10 + 0, expectedData, i * 5 + 0, 5);
457453
}
458454
Assertions.assertArrayEquals(expectedData, (int[]) data.get1DJavaArray(ma2DataType));
459455
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,7 @@ public void testResizeArrayShrink() throws IOException, ZarrException {
785785
ucar.ma2.Array data = array.read();
786786
int[] expectedData = new int[5 * 5];
787787
for (int i = 0; i < 5; i++) {
788-
for (int j = 0; j < 5; j++) {
789-
expectedData[i * 5 + j] = testData[i * 10 + j];
790-
}
788+
System.arraycopy(testData, i * 10 + 0, expectedData, i * 5 + 0, 5);
791789
}
792790
Assertions.assertArrayEquals(expectedData, (int[]) data.get1DJavaArray(ma2DataType));
793791
}
@@ -827,9 +825,7 @@ public void testResizeArrayShrinkWithChunkCleanup() throws IOException, ZarrExce
827825
ucar.ma2.Array data = array.read();
828826
int[] expectedData = new int[5 * 5];
829827
for (int i = 0; i < 5; i++) {
830-
for (int j = 0; j < 5; j++) {
831-
expectedData[i * 5 + j] = testData[i * 10 + j];
832-
}
828+
System.arraycopy(testData, i * 10 + 0, expectedData, i * 5 + 0, 5);
833829
}
834830
Assertions.assertArrayEquals(expectedData, (int[]) data.get1DJavaArray(ma2DataType));
835831
}

0 commit comments

Comments
 (0)