Skip to content

Commit 5201687

Browse files
icexellosskou
authored andcommitted
ARROW-1304: [Java] Fix Indentation, WhitespaceAround and EmptyLineSeparator checkstyle warnings in Java
Author: Li Jin <[email protected]> Closes apache#930 from icexelloss/checkstyle-fix-ARROW-1304 and squashes the following commits: 0ba9e03 [Li Jin] ARROW-1304: [Java] Reformat java code with google_checks.xml to improve checkstyle
1 parent ebfde68 commit 5201687

File tree

144 files changed

+2102
-1792
lines changed

Some content is hidden

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

144 files changed

+2102
-1792
lines changed

memory/src/main/java/io/netty/buffer/ArrowBuf.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ public ByteBuffer internalNioBuffer(int index, int length) {
406406

407407
@Override
408408
public ByteBuffer[] nioBuffers() {
409-
return new ByteBuffer[]{nioBuffer()};
409+
return new ByteBuffer[] {nioBuffer()};
410410
}
411411

412412
@Override
413413
public ByteBuffer[] nioBuffers(int index, int length) {
414-
return new ByteBuffer[]{nioBuffer(index, length)};
414+
return new ByteBuffer[] {nioBuffer(index, length)};
415415
}
416416

417417
@Override

memory/src/main/java/org/apache/arrow/memory/Accountant.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ public long getPeakMemoryAllocation() {
249249
return peakAllocation.get();
250250
}
251251

252-
public long getHeadroom(){
252+
public long getHeadroom() {
253253
long localHeadroom = allocationLimit.get() - locallyHeldMemory.get();
254-
if(parent == null){
254+
if (parent == null) {
255255
return localHeadroom;
256256
}
257257

memory/src/main/java/org/apache/arrow/memory/AllocationManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ private void inc() {
328328
* Decrement the ledger's reference count. If the ledger is decremented to zero, this ledger
329329
* should release its
330330
* ownership back to the AllocationManager
331+
*
331332
* @param decrement amout to decrease the reference count by
332333
* @return the new reference count
333334
*/

memory/src/main/java/org/apache/arrow/memory/BaseAllocator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ public ArrowBuf buffer(final int initialRequestSize, BufferManager manager) {
274274
throw new OutOfMemoryException(e);
275275
}
276276
throw e;
277-
}
278-
finally {
277+
} finally {
279278
if (!success) {
280279
releaseBytes(actualRequestSize);
281280
}

memory/src/main/java/org/apache/arrow/memory/BufferAllocator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ public interface BufferAllocator extends AutoCloseable {
117117
* Create an allocation reservation. A reservation is a way of building up
118118
* a request for a buffer whose size is not known in advance. See
119119
*
120-
* @see AllocationReservation
121-
*
122120
* @return the newly created reservation
121+
* @see AllocationReservation
123122
*/
124123
public AllocationReservation newReservation();
125124

@@ -128,6 +127,7 @@ public interface BufferAllocator extends AutoCloseable {
128127
* special because we don't
129128
* worry about them leaking or managing reference counts on them since they don't actually
130129
* point to any memory.
130+
*
131131
* @return the empty buffer
132132
*/
133133
public ArrowBuf getEmpty();
@@ -136,6 +136,7 @@ public interface BufferAllocator extends AutoCloseable {
136136
* Return the name of this allocator. This is a human readable name that can help debugging.
137137
* Typically provides
138138
* coordinates about where this allocator was created
139+
*
139140
* @return the name of the allocator
140141
*/
141142
public String getName();
@@ -145,6 +146,7 @@ public interface BufferAllocator extends AutoCloseable {
145146
* that an allocator is
146147
* over its limit, all consumers of that allocator should aggressively try to addrss the
147148
* overlimit situation.
149+
*
148150
* @return whether or not this allocator (or one if its parents) is over its limits
149151
*/
150152
public boolean isOverLimit();

memory/src/main/java/org/apache/arrow/memory/util/HistoricalLog.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public synchronized void recordEvent(final String noteFormat, Object... args) {
9797
* includes the identifying string provided at construction time, and all the recorded
9898
* events with their stack traces.
9999
*
100-
* @param sb {@link StringBuilder} to write to
100+
* @param sb {@link StringBuilder} to write to
101101
* @param includeStackTrace whether to include the stacktrace of each event in the history
102102
*/
103103
public void buildHistory(final StringBuilder sb, boolean includeStackTrace) {
@@ -106,8 +106,9 @@ public void buildHistory(final StringBuilder sb, boolean includeStackTrace) {
106106

107107
/**
108108
* build the history and write it to sb
109-
* @param sb output
110-
* @param indent starting indent (usually "")
109+
*
110+
* @param sb output
111+
* @param indent starting indent (usually "")
111112
* @param includeStackTrace whether to include the stacktrace of each event.
112113
*/
113114
public synchronized void buildHistory(

memory/src/test/java/org/apache/arrow/memory/TestAccountant.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18+
1819
package org.apache.arrow.memory;
1920

2021
import static org.junit.Assert.assertEquals;

memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18+
1819
package org.apache.arrow.memory;
1920

2021
import 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();

memory/src/test/java/org/apache/arrow/memory/TestEndianess.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18+
1819
package org.apache.arrow.memory;
1920

2021
import static org.junit.Assert.assertEquals;
22+
2123
import io.netty.buffer.ByteBuf;
2224

2325
import org.apache.arrow.memory.BufferAllocator;

tools/src/main/java/org/apache/arrow/tools/EchoServer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ public void run() throws IOException {
7373
LOGGER.info("Closed connection with client");
7474
}
7575
} catch (java.net.SocketException ex) {
76-
if (!closed) throw ex;
76+
if (!closed) {
77+
throw ex;
78+
}
7779
} finally {
7880
serverSocket.close();
7981
LOGGER.info("Server closed.");

0 commit comments

Comments
 (0)