1515 * See the License for the specific language governing permissions and
1616 * limitations under the License.
1717 */
18+
1819package org .apache .arrow .memory ;
1920
2021import static org .junit .Assert .assertEquals ;
@@ -59,13 +60,13 @@ public void checkBuffers() {
5960
6061 @ Test
6162 public void test_privateMax () throws Exception {
62- try (final RootAllocator rootAllocator =
63- new RootAllocator (MAX_ALLOCATION )) {
63+ try (final RootAllocator rootAllocator =
64+ new RootAllocator (MAX_ALLOCATION )) {
6465 final ArrowBuf arrowBuf1 = rootAllocator .buffer (MAX_ALLOCATION / 2 );
6566 assertNotNull ("allocation failed" , arrowBuf1 );
6667
67- try (final BufferAllocator childAllocator =
68- rootAllocator .newChildAllocator ("noLimits" , 0 , MAX_ALLOCATION )) {
68+ try (final BufferAllocator childAllocator =
69+ rootAllocator .newChildAllocator ("noLimits" , 0 , MAX_ALLOCATION )) {
6970 final ArrowBuf arrowBuf2 = childAllocator .buffer (MAX_ALLOCATION / 2 );
7071 assertNotNull ("allocation failed" , arrowBuf2 );
7172 arrowBuf2 .release ();
@@ -75,11 +76,11 @@ public void test_privateMax() throws Exception {
7576 }
7677 }
7778
78- @ Test (expected = IllegalStateException .class )
79+ @ Test (expected = IllegalStateException .class )
7980 public void testRootAllocator_closeWithOutstanding () throws Exception {
8081 try {
81- try (final RootAllocator rootAllocator =
82- new RootAllocator (MAX_ALLOCATION )) {
82+ try (final RootAllocator rootAllocator =
83+ new RootAllocator (MAX_ALLOCATION )) {
8384 final ArrowBuf arrowBuf = rootAllocator .buffer (512 );
8485 assertNotNull ("allocation failed" , arrowBuf );
8586 }
@@ -100,8 +101,8 @@ public void testRootAllocator_closeWithOutstanding() throws Exception {
100101
101102 @ Test
102103 public void testRootAllocator_getEmpty () throws Exception {
103- try (final RootAllocator rootAllocator =
104- new RootAllocator (MAX_ALLOCATION )) {
104+ try (final RootAllocator rootAllocator =
105+ new RootAllocator (MAX_ALLOCATION )) {
105106 final ArrowBuf arrowBuf = rootAllocator .buffer (0 );
106107 assertNotNull ("allocation failed" , arrowBuf );
107108 assertEquals ("capacity was non-zero" , 0 , arrowBuf .capacity ());
@@ -112,17 +113,17 @@ public void testRootAllocator_getEmpty() throws Exception {
112113 @ Ignore // TODO(DRILL-2740)
113114 @ Test (expected = IllegalStateException .class )
114115 public void testAllocator_unreleasedEmpty () throws Exception {
115- try (final RootAllocator rootAllocator =
116- new RootAllocator (MAX_ALLOCATION )) {
116+ try (final RootAllocator rootAllocator =
117+ new RootAllocator (MAX_ALLOCATION )) {
117118 @ SuppressWarnings ("unused" )
118119 final ArrowBuf arrowBuf = rootAllocator .buffer (0 );
119120 }
120121 }
121122
122123 @ Test
123124 public void testAllocator_transferOwnership () throws Exception {
124- try (final RootAllocator rootAllocator =
125- new RootAllocator (MAX_ALLOCATION )) {
125+ try (final RootAllocator rootAllocator =
126+ new RootAllocator (MAX_ALLOCATION )) {
126127 final BufferAllocator childAllocator1 =
127128 rootAllocator .newChildAllocator ("changeOwnership1" , 0 , MAX_ALLOCATION );
128129 final BufferAllocator childAllocator2 =
@@ -197,7 +198,7 @@ public void testRootAllocator_createChildAndUse() throws Exception {
197198 }
198199 }
199200
200- @ Test (expected = IllegalStateException .class )
201+ @ Test (expected = IllegalStateException .class )
201202 public void testRootAllocator_createChildDontClose () throws Exception {
202203 try {
203204 try (final RootAllocator rootAllocator = new RootAllocator (MAX_ALLOCATION )) {
@@ -232,33 +233,33 @@ private static void allocateAndFree(final BufferAllocator allocator) {
232233
233234 final int nBufs = 8 ;
234235 final ArrowBuf [] arrowBufs = new ArrowBuf [nBufs ];
235- for (int i = 0 ; i < arrowBufs .length ; ++i ) {
236+ for (int i = 0 ; i < arrowBufs .length ; ++i ) {
236237 ArrowBuf arrowBufi = allocator .buffer (MAX_ALLOCATION / nBufs );
237238 assertNotNull ("allocation failed" , arrowBufi );
238239 arrowBufs [i ] = arrowBufi ;
239240 }
240- for (ArrowBuf arrowBufi : arrowBufs ) {
241+ for (ArrowBuf arrowBufi : arrowBufs ) {
241242 arrowBufi .release ();
242243 }
243244 }
244245
245246 @ Test
246247 public void testAllocator_manyAllocations () throws Exception {
247- try (final RootAllocator rootAllocator =
248- new RootAllocator (MAX_ALLOCATION )) {
249- try (final BufferAllocator childAllocator =
250- rootAllocator .newChildAllocator ("manyAllocations" , 0 , MAX_ALLOCATION )) {
248+ try (final RootAllocator rootAllocator =
249+ new RootAllocator (MAX_ALLOCATION )) {
250+ try (final BufferAllocator childAllocator =
251+ rootAllocator .newChildAllocator ("manyAllocations" , 0 , MAX_ALLOCATION )) {
251252 allocateAndFree (childAllocator );
252253 }
253254 }
254255 }
255256
256257 @ Test
257258 public void testAllocator_overAllocate () throws Exception {
258- try (final RootAllocator rootAllocator =
259- new RootAllocator (MAX_ALLOCATION )) {
260- try (final BufferAllocator childAllocator =
261- rootAllocator .newChildAllocator ("overAllocate" , 0 , MAX_ALLOCATION )) {
259+ try (final RootAllocator rootAllocator =
260+ new RootAllocator (MAX_ALLOCATION )) {
261+ try (final BufferAllocator childAllocator =
262+ rootAllocator .newChildAllocator ("overAllocate" , 0 , MAX_ALLOCATION )) {
262263 allocateAndFree (childAllocator );
263264
264265 try {
@@ -273,10 +274,10 @@ public void testAllocator_overAllocate() throws Exception {
273274
274275 @ Test
275276 public void testAllocator_overAllocateParent () throws Exception {
276- try (final RootAllocator rootAllocator =
277- new RootAllocator (MAX_ALLOCATION )) {
278- try (final BufferAllocator childAllocator =
279- rootAllocator .newChildAllocator ("overAllocateParent" , 0 , MAX_ALLOCATION )) {
277+ try (final RootAllocator rootAllocator =
278+ new RootAllocator (MAX_ALLOCATION )) {
279+ try (final BufferAllocator childAllocator =
280+ rootAllocator .newChildAllocator ("overAllocateParent" , 0 , MAX_ALLOCATION )) {
280281 final ArrowBuf arrowBuf1 = rootAllocator .buffer (MAX_ALLOCATION / 2 );
281282 assertNotNull ("allocation failed" , arrowBuf1 );
282283 final ArrowBuf arrowBuf2 = childAllocator .buffer (MAX_ALLOCATION / 2 );
@@ -326,7 +327,7 @@ public void testAllocator_createSlices() throws Exception {
326327
327328 try (final BufferAllocator childAllocator = rootAllocator .newChildAllocator ("createSlices" , 0 , MAX_ALLOCATION )) {
328329 try (final BufferAllocator childAllocator2 =
329- childAllocator .newChildAllocator ("createSlices" , 0 , MAX_ALLOCATION )) {
330+ childAllocator .newChildAllocator ("createSlices" , 0 , MAX_ALLOCATION )) {
330331 final ArrowBuf arrowBuf1 = childAllocator2 .buffer (MAX_ALLOCATION / 8 );
331332 @ SuppressWarnings ("unused" )
332333 final ArrowBuf arrowBuf2 = arrowBuf1 .slice (MAX_ALLOCATION / 16 , MAX_ALLOCATION / 16 );
@@ -345,8 +346,8 @@ public void testAllocator_createSlices() throws Exception {
345346 @ Test
346347 public void testAllocator_sliceRanges () throws Exception {
347348// final AllocatorOwner allocatorOwner = new NamedOwner("sliceRanges");
348- try (final RootAllocator rootAllocator =
349- new RootAllocator (MAX_ALLOCATION )) {
349+ try (final RootAllocator rootAllocator =
350+ new RootAllocator (MAX_ALLOCATION )) {
350351 // Populate a buffer with byte values corresponding to their indices.
351352 final ArrowBuf arrowBuf = rootAllocator .buffer (256 );
352353 assertEquals (256 , arrowBuf .capacity ());
@@ -362,7 +363,7 @@ public void testAllocator_sliceRanges() throws Exception {
362363// assertEquals(256, slice3.capacity());
363364// assertEquals(256, slice3.writableBytes());
364365
365- for (int i = 0 ; i < 256 ; ++i ) {
366+ for (int i = 0 ; i < 256 ; ++i ) {
366367 arrowBuf .writeByte (i );
367368 }
368369 assertEquals (0 , arrowBuf .readerIndex ());
@@ -373,18 +374,18 @@ public void testAllocator_sliceRanges() throws Exception {
373374 final ArrowBuf slice1 = (ArrowBuf ) arrowBuf .slice ();
374375 assertEquals (0 , slice1 .readerIndex ());
375376 assertEquals (256 , slice1 .readableBytes ());
376- for (int i = 0 ; i < 10 ; ++i ) {
377+ for (int i = 0 ; i < 10 ; ++i ) {
377378 assertEquals (i , slice1 .readByte ());
378379 }
379380 assertEquals (256 - 10 , slice1 .readableBytes ());
380- for (int i = 0 ; i < 256 ; ++i ) {
381+ for (int i = 0 ; i < 256 ; ++i ) {
381382 assertEquals ((byte ) i , slice1 .getByte (i ));
382383 }
383384
384385 final ArrowBuf slice2 = arrowBuf .slice (25 , 25 );
385386 assertEquals (0 , slice2 .readerIndex ());
386387 assertEquals (25 , slice2 .readableBytes ());
387- for (int i = 25 ; i < 50 ; ++i ) {
388+ for (int i = 25 ; i < 50 ; ++i ) {
388389 assertEquals (i , slice2 .readByte ());
389390 }
390391
@@ -404,32 +405,32 @@ public void testAllocator_sliceRanges() throws Exception {
404405 @ Test
405406 public void testAllocator_slicesOfSlices () throws Exception {
406407// final AllocatorOwner allocatorOwner = new NamedOwner("slicesOfSlices");
407- try (final RootAllocator rootAllocator =
408- new RootAllocator (MAX_ALLOCATION )) {
408+ try (final RootAllocator rootAllocator =
409+ new RootAllocator (MAX_ALLOCATION )) {
409410 // Populate a buffer with byte values corresponding to their indices.
410411 final ArrowBuf arrowBuf = rootAllocator .buffer (256 );
411- for (int i = 0 ; i < 256 ; ++i ) {
412+ for (int i = 0 ; i < 256 ; ++i ) {
412413 arrowBuf .writeByte (i );
413414 }
414415
415416 // Slice it up.
416417 final ArrowBuf slice0 = arrowBuf .slice (0 , arrowBuf .capacity ());
417- for (int i = 0 ; i < 256 ; ++i ) {
418+ for (int i = 0 ; i < 256 ; ++i ) {
418419 assertEquals ((byte ) i , arrowBuf .getByte (i ));
419420 }
420421
421422 final ArrowBuf slice10 = slice0 .slice (10 , arrowBuf .capacity () - 10 );
422- for (int i = 10 ; i < 256 ; ++i ) {
423+ for (int i = 10 ; i < 256 ; ++i ) {
423424 assertEquals ((byte ) i , slice10 .getByte (i - 10 ));
424425 }
425426
426427 final ArrowBuf slice20 = slice10 .slice (10 , arrowBuf .capacity () - 20 );
427- for (int i = 20 ; i < 256 ; ++i ) {
428+ for (int i = 20 ; i < 256 ; ++i ) {
428429 assertEquals ((byte ) i , slice20 .getByte (i - 20 ));
429430 }
430431
431- final ArrowBuf slice30 = slice20 .slice (10 , arrowBuf .capacity () - 30 );
432- for (int i = 30 ; i < 256 ; ++i ) {
432+ final ArrowBuf slice30 = slice20 .slice (10 , arrowBuf .capacity () - 30 );
433+ for (int i = 30 ; i < 256 ; ++i ) {
433434 assertEquals ((byte ) i , slice30 .getByte (i - 30 ));
434435 }
435436
@@ -556,8 +557,8 @@ public void testAllocator_transferShared() throws Exception {
556557 public void testAllocator_unclaimedReservation () throws Exception {
557558 try (final RootAllocator rootAllocator = new RootAllocator (MAX_ALLOCATION )) {
558559 try (final BufferAllocator childAllocator1 =
559- rootAllocator .newChildAllocator ("unclaimedReservation" , 0 , MAX_ALLOCATION )) {
560- try (final AllocationReservation reservation = childAllocator1 .newReservation ()) {
560+ rootAllocator .newChildAllocator ("unclaimedReservation" , 0 , MAX_ALLOCATION )) {
561+ try (final AllocationReservation reservation = childAllocator1 .newReservation ()) {
561562 assertTrue (reservation .add (64 ));
562563 }
563564 rootAllocator .verify ();
0 commit comments