Skip to content

Commit 17bdb5a

Browse files
ARROW-7429: [Java] Enhance code style checking for Java code (remove consecutive spaces)
This issue is opened in response to a discussion in apache#5861 (comment). We found the current style checking for Java code is not sufficient. So we want to enhace it in a series of "small" steps, in order to avoid having to change too many files at once. In this issue, we remove consecutive spaces between tokens, so that tokens are separated by single spaces. Closes apache#6060 from liyafan82/fly_1217_style and squashes the following commits: d14b8d5 <emkornfield> Merge branch 'master' into fly_1217_style 6d4fe3d <liyafan82> Enhance code style checking for Java code (remove consecutive spaces) Lead-authored-by: liyafan82 <fan_li_ya@foxmail.com> Co-authored-by: emkornfield <emkornfield@gmail.com> Signed-off-by: Micah Kornfield <emkornfield@gmail.com>
1 parent 7f905a6 commit 17bdb5a

44 files changed

Lines changed: 131 additions & 127 deletions

File tree

Some content is hidden

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

‎java/adapter/avro/src/main/java/org/apache/arrow/AvroToArrowConfigBuilder.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
public class AvroToArrowConfigBuilder {
3030

31-
private BufferAllocator allocator;
31+
private BufferAllocator allocator;
3232

3333
private int targetBatchSize;
3434

‎java/adapter/avro/src/main/java/org/apache/arrow/AvroToArrowUtils.java‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -183,98 +183,98 @@ private static Consumer createConsumer(
183183
break;
184184
case STRING:
185185
arrowType = new ArrowType.Utf8();
186-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
186+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
187187
vector = createVector(consumerVector, fieldType, name, allocator);
188-
consumer = new AvroStringConsumer((VarCharVector) vector);
188+
consumer = new AvroStringConsumer((VarCharVector) vector);
189189
break;
190190
case FIXED:
191191
if (logicalType instanceof LogicalTypes.Decimal) {
192192
arrowType = createDecimalArrowType((LogicalTypes.Decimal) logicalType);
193-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
193+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
194194
vector = createVector(consumerVector, fieldType, name, allocator);
195195
consumer = new AvroDecimalConsumer.FixedDecimalConsumer((DecimalVector) vector, schema.getFixedSize());
196196
} else {
197197
arrowType = new ArrowType.FixedSizeBinary(schema.getFixedSize());
198-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
198+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
199199
vector = createVector(consumerVector, fieldType, name, allocator);
200200
consumer = new AvroFixedConsumer((FixedSizeBinaryVector) vector, schema.getFixedSize());
201201
}
202202
break;
203203
case INT:
204204
if (logicalType instanceof LogicalTypes.Date) {
205205
arrowType = new ArrowType.Date(DateUnit.DAY);
206-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
206+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
207207
vector = createVector(consumerVector, fieldType, name, allocator);
208208
consumer = new AvroDateConsumer((DateDayVector) vector);
209209
} else if (logicalType instanceof LogicalTypes.TimeMillis) {
210210
arrowType = new ArrowType.Time(TimeUnit.MILLISECOND, 32);
211-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
211+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
212212
vector = createVector(consumerVector, fieldType, name, allocator);
213213
consumer = new AvroTimeMillisConsumer((TimeMilliVector) vector);
214214
} else {
215215
arrowType = new ArrowType.Int(32, /*signed=*/true);
216-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
216+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
217217
vector = createVector(consumerVector, fieldType, name, allocator);
218218
consumer = new AvroIntConsumer((IntVector) vector);
219219
}
220220
break;
221221
case BOOLEAN:
222222
arrowType = new ArrowType.Bool();
223-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
223+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
224224
vector = createVector(consumerVector, fieldType, name, allocator);
225225
consumer = new AvroBooleanConsumer((BitVector) vector);
226226
break;
227227
case LONG:
228228
if (logicalType instanceof LogicalTypes.TimeMicros) {
229229
arrowType = new ArrowType.Time(TimeUnit.MICROSECOND, 64);
230-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
230+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
231231
vector = createVector(consumerVector, fieldType, name, allocator);
232-
consumer = new AvroTimeMicroConsumer((TimeMicroVector) vector);
232+
consumer = new AvroTimeMicroConsumer((TimeMicroVector) vector);
233233
} else if (logicalType instanceof LogicalTypes.TimestampMillis) {
234234
arrowType = new ArrowType.Timestamp(TimeUnit.MILLISECOND, null);
235-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
235+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
236236
vector = createVector(consumerVector, fieldType, name, allocator);
237-
consumer = new AvroTimestampMillisConsumer((TimeStampMilliVector) vector);
237+
consumer = new AvroTimestampMillisConsumer((TimeStampMilliVector) vector);
238238
} else if (logicalType instanceof LogicalTypes.TimestampMicros) {
239239
arrowType = new ArrowType.Timestamp(TimeUnit.MICROSECOND, null);
240-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
240+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
241241
vector = createVector(consumerVector, fieldType, name, allocator);
242-
consumer = new AvroTimestampMicrosConsumer((TimeStampMicroVector) vector);
242+
consumer = new AvroTimestampMicrosConsumer((TimeStampMicroVector) vector);
243243
} else {
244244
arrowType = new ArrowType.Int(64, /*signed=*/true);
245-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
245+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
246246
vector = createVector(consumerVector, fieldType, name, allocator);
247-
consumer = new AvroLongConsumer((BigIntVector) vector);
247+
consumer = new AvroLongConsumer((BigIntVector) vector);
248248
}
249249
break;
250250
case FLOAT:
251-
arrowType = new ArrowType.FloatingPoint(SINGLE);
252-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
251+
arrowType = new ArrowType.FloatingPoint(SINGLE);
252+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
253253
vector = createVector(consumerVector, fieldType, name, allocator);
254254
consumer = new AvroFloatConsumer((Float4Vector) vector);
255255
break;
256256
case DOUBLE:
257257
arrowType = new ArrowType.FloatingPoint(DOUBLE);
258-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
258+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
259259
vector = createVector(consumerVector, fieldType, name, allocator);
260260
consumer = new AvroDoubleConsumer((Float8Vector) vector);
261261
break;
262262
case BYTES:
263263
if (logicalType instanceof LogicalTypes.Decimal) {
264264
arrowType = createDecimalArrowType((LogicalTypes.Decimal) logicalType);
265-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
265+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
266266
vector = createVector(consumerVector, fieldType, name, allocator);
267267
consumer = new AvroDecimalConsumer.BytesDecimalConsumer((DecimalVector) vector);
268268
} else {
269269
arrowType = new ArrowType.Binary();
270-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
270+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
271271
vector = createVector(consumerVector, fieldType, name, allocator);
272272
consumer = new AvroBytesConsumer((VarBinaryVector) vector);
273273
}
274274
break;
275275
case NULL:
276276
arrowType = new ArrowType.Null();
277-
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
277+
fieldType = new FieldType(nullable, arrowType, /*dictionary=*/null, getMetaData(schema));
278278
vector = fieldType.createNewSingleVector(name, allocator, /*schemaCallback=*/null);
279279
consumer = new AvroNullConsumer((NullVector) vector);
280280
break;
@@ -308,7 +308,7 @@ private static Consumer createSkipConsumer(Schema schema) {
308308
case UNION:
309309
List<Consumer> unionDelegates = schema.getTypes().stream().map(s ->
310310
createSkipConsumer(s)).collect(Collectors.toList());
311-
skipFunction = decoder -> unionDelegates.get(decoder.readInt()).consume(decoder);
311+
skipFunction = decoder -> unionDelegates.get(decoder.readInt()).consume(decoder);
312312

313313
break;
314314
case ARRAY:
@@ -326,7 +326,7 @@ private static Consumer createSkipConsumer(Schema schema) {
326326
skipFunction = decoder -> {
327327
for (long i = decoder.skipMap(); i != 0; i = decoder.skipMap()) {
328328
for (long j = 0; j < i; j++) {
329-
decoder.skipString(); // Discard key
329+
decoder.skipString(); // Discard key
330330
valueDelegate.consume(decoder);
331331
}
332332
}

‎java/adapter/orc/src/main/java/org/apache/arrow/adapter/orc/OrcReader.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public OrcReader(String filePath, BufferAllocator allocator) throws IOException,
5555
* @param rowNumber the rows number to seek
5656
* @return true if seek operation is succeeded
5757
*/
58-
public boolean seek(int rowNumber) throws IllegalArgumentException {
58+
public boolean seek(int rowNumber) throws IllegalArgumentException {
5959
return jniWrapper.seek(nativeInstanceId, rowNumber);
6060
}
6161

@@ -79,7 +79,7 @@ public ArrowReader nextStripeReader(long batchSize) throws IllegalArgumentExcept
7979
*
8080
* @return number of stripes
8181
*/
82-
public int getNumberOfStripes() throws IllegalArgumentException {
82+
public int getNumberOfStripes() throws IllegalArgumentException {
8383
return jniWrapper.getNumberOfStripes(nativeInstanceId);
8484
}
8585

‎java/algorithm/src/main/java/org/apache/arrow/algorithm/deduplicate/DeduplicationUtils.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static <V extends ValueVector> void populateRunStartIndicators(V vector,
6060
* @param runLengths the run length vector to populate.
6161
* @param valueCount the number of values in the bit set.
6262
*/
63-
public static void populateRunLengths(ArrowBuf runStarts, IntVector runLengths, int valueCount) {
63+
public static void populateRunLengths(ArrowBuf runStarts, IntVector runLengths, int valueCount) {
6464
int curStart = 0;
6565
int lengthIndex = 0;
6666
for (int i = 1; i < valueCount; i++) {

‎java/algorithm/src/main/java/org/apache/arrow/algorithm/sort/CompositeVectorComparator.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* been used.
3030
* </p>
3131
*/
32-
public class CompositeVectorComparator extends VectorValueComparator<ValueVector> {
32+
public class CompositeVectorComparator extends VectorValueComparator<ValueVector> {
3333

3434
private final VectorValueComparator[] innerComparators;
3535

‎java/algorithm/src/main/java/org/apache/arrow/algorithm/sort/OffHeapIntStack.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public int getCount() {
6666
}
6767

6868
@Override
69-
public void close() {
69+
public void close() {
7070
intVector.close();
7171
}
7272
}

‎java/algorithm/src/test/java/org/apache/arrow/algorithm/dictionary/TestHashTableDictionaryEncoder.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void testEncodeAndDecode() {
103103

104104
// perform decoding
105105
Dictionary dict = new Dictionary(dictionary, new DictionaryEncoding(1L, false, null));
106-
try (VarCharVector decodedVector = (VarCharVector) DictionaryEncoder.decode(encodedVector, dict)) {
106+
try (VarCharVector decodedVector = (VarCharVector) DictionaryEncoder.decode(encodedVector, dict)) {
107107

108108
// verify decoding results
109109
assertEquals(encodedVector.getValueCount(), decodedVector.getValueCount());
@@ -161,7 +161,7 @@ public void testEncodeAndDecodeWithNull() {
161161

162162
// perform decoding
163163
Dictionary dict = new Dictionary(dictionary, new DictionaryEncoding(1L, false, null));
164-
try (VarCharVector decodedVector = (VarCharVector) DictionaryEncoder.decode(encodedVector, dict)) {
164+
try (VarCharVector decodedVector = (VarCharVector) DictionaryEncoder.decode(encodedVector, dict)) {
165165
// verify decoding results
166166
assertEquals(encodedVector.getValueCount(), decodedVector.getValueCount());
167167
for (int i = 0; i < VECTOR_LENGTH; i++) {

‎java/dev/checkstyle/checkstyle.xml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@
207207
<property name="option" value="top"/>
208208
<property name="sortStaticImportsAlphabetically" value="true"/>
209209
</module>
210+
<module name="SingleSpaceSeparator">
211+
<property name="validateComments" value="true"/>
212+
</module>
210213
<module name="MethodParamPad"/>
211214
<module name="OperatorWrap">
212215
<property name="option" value="eol"/>

‎java/flight/src/main/java/org/apache/arrow/flight/ArrowMessage.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public ArrowRecordBatch asRecordBatch() throws IOException {
187187
ArrowBuf underlying = bufs.get(0);
188188

189189
underlying.getReferenceManager().retain();
190-
return MessageSerializer.deserializeRecordBatch(message, underlying);
190+
return MessageSerializer.deserializeRecordBatch(message, underlying);
191191
}
192192

193193
public ArrowDictionaryBatch asDictionaryBatch() throws IOException {

‎java/flight/src/main/java/org/apache/arrow/flight/example/FlightHolder.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public FlightInfo getFlightInfo(final Location l) {
104104
l));
105105
i++;
106106
}
107-
return new FlightInfo(schema, descriptor, endpoints, bytes, records);
107+
return new FlightInfo(schema, descriptor, endpoints, bytes, records);
108108
}
109109

110110
@Override

0 commit comments

Comments
 (0)