Skip to content

Commit 3000b4b

Browse files
dongjoon-hyunsrowen
authored andcommitted
[MINOR][BUILD] Fix Java linter errors
## What changes were proposed in this pull request? This PR fixes the minor Java linter errors like the following. ``` - public int read(char cbuf[], int off, int len) throws IOException { + public int read(char[] cbuf, int off, int len) throws IOException { ``` ## How was this patch tested? Manual. ``` $ build/mvn -T 4 -q -DskipTests -Pyarn -Phadoop-2.3 -Pkinesis-asl -Phive -Phive-thriftserver install $ dev/lint-java Using `mvn` from path: /usr/local/bin/mvn Checkstyle checks passed. ``` Author: Dongjoon Hyun <[email protected]> Closes #14017 from dongjoon-hyun/minor_build_java_linter_error.
1 parent 0bd7cd1 commit 3000b4b

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

core/src/main/java/org/apache/spark/shuffle/sort/ShuffleExternalSorter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ public void insertRecord(Object recordBase, long recordOffset, int length, int p
376376
// for tests
377377
assert(inMemSorter != null);
378378
if (inMemSorter.numRecords() >= numElementsForSpillThreshold) {
379-
logger.info("Spilling data because number of spilledRecords crossed the threshold " + numElementsForSpillThreshold);
379+
logger.info("Spilling data because number of spilledRecords crossed the threshold " +
380+
numElementsForSpillThreshold);
380381
spill();
381382
}
382383

core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.slf4j.Logger;
2828
import org.slf4j.LoggerFactory;
2929

30-
import org.apache.spark.SparkEnv;
3130
import org.apache.spark.TaskContext;
3231
import org.apache.spark.executor.ShuffleWriteMetrics;
3332
import org.apache.spark.memory.MemoryConsumer;
@@ -99,8 +98,8 @@ public static UnsafeExternalSorter createWithExistingInMemorySorter(
9998
long numElementsForSpillThreshold,
10099
UnsafeInMemorySorter inMemorySorter) throws IOException {
101100
UnsafeExternalSorter sorter = new UnsafeExternalSorter(taskMemoryManager, blockManager,
102-
serializerManager, taskContext, recordComparator, prefixComparator, initialSize, numElementsForSpillThreshold,
103-
pageSizeBytes, inMemorySorter, false /* ignored */);
101+
serializerManager, taskContext, recordComparator, prefixComparator, initialSize,
102+
numElementsForSpillThreshold, pageSizeBytes, inMemorySorter, false /* ignored */);
104103
sorter.spill(Long.MAX_VALUE, sorter);
105104
// The external sorter will be used to insert records, in-memory sorter is not needed.
106105
sorter.inMemSorter = null;
@@ -119,8 +118,8 @@ public static UnsafeExternalSorter create(
119118
long numElementsForSpillThreshold,
120119
boolean canUseRadixSort) {
121120
return new UnsafeExternalSorter(taskMemoryManager, blockManager, serializerManager,
122-
taskContext, recordComparator, prefixComparator, initialSize, pageSizeBytes, numElementsForSpillThreshold, null,
123-
canUseRadixSort);
121+
taskContext, recordComparator, prefixComparator, initialSize, pageSizeBytes,
122+
numElementsForSpillThreshold, null, canUseRadixSort);
124123
}
125124

126125
private UnsafeExternalSorter(
@@ -387,7 +386,8 @@ public void insertRecord(
387386

388387
assert(inMemSorter != null);
389388
if (inMemSorter.numRecords() >= numElementsForSpillThreshold) {
390-
logger.info("Spilling data because number of spilledRecords crossed the threshold " + numElementsForSpillThreshold);
389+
logger.info("Spilling data because number of spilledRecords crossed the threshold " +
390+
numElementsForSpillThreshold);
391391
spill();
392392
}
393393

sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/xml/UDFXPathUtil.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import java.io.IOException;
2121
import java.io.Reader;
22-
import java.io.StringReader;
2322

2423
import javax.xml.namespace.QName;
2524
import javax.xml.xpath.XPath;
@@ -71,7 +70,7 @@ public Object eval(String xml, String path, QName qname) {
7170
try {
7271
return expression.evaluate(inputSource, qname);
7372
} catch (XPathExpressionException e) {
74-
throw new RuntimeException ("Invalid expression '" + oldPath + "'", e);
73+
throw new RuntimeException("Invalid expression '" + oldPath + "'", e);
7574
}
7675
}
7776

@@ -96,7 +95,7 @@ public NodeList evalNodeList(String xml, String path) {
9695
}
9796

9897
/**
99-
* Reusable, non-threadsafe version of {@link StringReader}.
98+
* Reusable, non-threadsafe version of {@link java.io.StringReader}.
10099
*/
101100
public static class ReusableStringReader extends Reader {
102101

@@ -117,29 +116,32 @@ public void set(String s) {
117116

118117
/** Check to make sure that the stream has not been closed */
119118
private void ensureOpen() throws IOException {
120-
if (str == null)
119+
if (str == null) {
121120
throw new IOException("Stream closed");
121+
}
122122
}
123123

124124
@Override
125125
public int read() throws IOException {
126126
ensureOpen();
127-
if (next >= length)
127+
if (next >= length) {
128128
return -1;
129+
}
129130
return str.charAt(next++);
130131
}
131132

132133
@Override
133-
public int read(char cbuf[], int off, int len) throws IOException {
134+
public int read(char[] cbuf, int off, int len) throws IOException {
134135
ensureOpen();
135136
if ((off < 0) || (off > cbuf.length) || (len < 0)
136137
|| ((off + len) > cbuf.length) || ((off + len) < 0)) {
137138
throw new IndexOutOfBoundsException();
138139
} else if (len == 0) {
139140
return 0;
140141
}
141-
if (next >= length)
142+
if (next >= length) {
142143
return -1;
144+
}
143145
int n = Math.min(length - next, len);
144146
str.getChars(next, next + n, cbuf, off);
145147
next += n;
@@ -149,8 +151,9 @@ public int read(char cbuf[], int off, int len) throws IOException {
149151
@Override
150152
public long skip(long ns) throws IOException {
151153
ensureOpen();
152-
if (next >= length)
154+
if (next >= length) {
153155
return 0;
156+
}
154157
// Bound skip by beginning and end of the source
155158
long n = Math.min(length - next, ns);
156159
n = Math.max(-next, n);

sql/catalyst/src/main/java/org/apache/spark/sql/execution/UnsafeExternalRowSorter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public UnsafeExternalRowSorter(
8989
sparkEnv.conf().getInt("spark.shuffle.sort.initialBufferSize",
9090
DEFAULT_INITIAL_SORT_BUFFER_SIZE),
9191
pageSizeBytes,
92-
SparkEnv.get().conf().getLong("spark.shuffle.spill.numElementsForceSpillThreshold", UnsafeExternalSorter
93-
.DEFAULT_NUM_ELEMENTS_FOR_SPILL_THRESHOLD),
92+
SparkEnv.get().conf().getLong("spark.shuffle.spill.numElementsForceSpillThreshold",
93+
UnsafeExternalSorter.DEFAULT_NUM_ELEMENTS_FOR_SPILL_THRESHOLD),
9494
canUseRadixSort
9595
);
9696
}

sql/core/src/main/java/org/apache/spark/sql/execution/UnsafeFixedWidthAggregationMap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ public UnsafeKVExternalSorter destructAndCreateExternalSorter() throws IOExcepti
247247
SparkEnv.get().blockManager(),
248248
SparkEnv.get().serializerManager(),
249249
map.getPageSizeBytes(),
250-
SparkEnv.get().conf().getLong("spark.shuffle.spill.numElementsForceSpillThreshold", UnsafeExternalSorter
251-
.DEFAULT_NUM_ELEMENTS_FOR_SPILL_THRESHOLD),
250+
SparkEnv.get().conf().getLong("spark.shuffle.spill.numElementsForceSpillThreshold",
251+
UnsafeExternalSorter.DEFAULT_NUM_ELEMENTS_FOR_SPILL_THRESHOLD),
252252
map);
253253
}
254254
}

sql/core/src/main/java/org/apache/spark/sql/execution/UnsafeKVExternalSorter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public UnsafeKVExternalSorter(
5757
SerializerManager serializerManager,
5858
long pageSizeBytes,
5959
long numElementsForSpillThreshold) throws IOException {
60-
this(keySchema, valueSchema, blockManager, serializerManager, pageSizeBytes, numElementsForSpillThreshold, null);
60+
this(keySchema, valueSchema, blockManager, serializerManager, pageSizeBytes,
61+
numElementsForSpillThreshold, null);
6162
}
6263

6364
public UnsafeKVExternalSorter(

0 commit comments

Comments
 (0)