@@ -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 }
0 commit comments