Skip to content

Commit

Permalink
[MINOR][BUILD] Fix Java linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dongjoon-hyun committed Jul 1, 2016
1 parent c553976 commit 1da6767
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ public void insertRecord(Object recordBase, long recordOffset, int length, int p
// for tests
assert(inMemSorter != null);
if (inMemSorter.numRecords() >= numElementsForSpillThreshold) {
logger.info("Spilling data because number of spilledRecords crossed the threshold " + numElementsForSpillThreshold);
logger.info("Spilling data because number of spilledRecords crossed the threshold " +
numElementsForSpillThreshold);
spill();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.spark.SparkEnv;
import org.apache.spark.TaskContext;
import org.apache.spark.executor.ShuffleWriteMetrics;
import org.apache.spark.memory.MemoryConsumer;
Expand Down Expand Up @@ -99,8 +98,8 @@ public static UnsafeExternalSorter createWithExistingInMemorySorter(
long numElementsForSpillThreshold,
UnsafeInMemorySorter inMemorySorter) throws IOException {
UnsafeExternalSorter sorter = new UnsafeExternalSorter(taskMemoryManager, blockManager,
serializerManager, taskContext, recordComparator, prefixComparator, initialSize, numElementsForSpillThreshold,
pageSizeBytes, inMemorySorter, false /* ignored */);
serializerManager, taskContext, recordComparator, prefixComparator, initialSize,
numElementsForSpillThreshold, pageSizeBytes, inMemorySorter, false /* ignored */);
sorter.spill(Long.MAX_VALUE, sorter);
// The external sorter will be used to insert records, in-memory sorter is not needed.
sorter.inMemSorter = null;
Expand All @@ -119,8 +118,8 @@ public static UnsafeExternalSorter create(
long numElementsForSpillThreshold,
boolean canUseRadixSort) {
return new UnsafeExternalSorter(taskMemoryManager, blockManager, serializerManager,
taskContext, recordComparator, prefixComparator, initialSize, pageSizeBytes, numElementsForSpillThreshold, null,
canUseRadixSort);
taskContext, recordComparator, prefixComparator, initialSize, pageSizeBytes,
numElementsForSpillThreshold, null, canUseRadixSort);
}

private UnsafeExternalSorter(
Expand Down Expand Up @@ -387,7 +386,8 @@ public void insertRecord(

assert(inMemSorter != null);
if (inMemSorter.numRecords() >= numElementsForSpillThreshold) {
logger.info("Spilling data because number of spilledRecords crossed the threshold " + numElementsForSpillThreshold);
logger.info("Spilling data because number of spilledRecords crossed the threshold " +
numElementsForSpillThreshold);
spill();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;

import javax.xml.namespace.QName;
import javax.xml.xpath.XPath;
Expand Down Expand Up @@ -71,7 +70,7 @@ public Object eval(String xml, String path, QName qname) {
try {
return expression.evaluate(inputSource, qname);
} catch (XPathExpressionException e) {
throw new RuntimeException ("Invalid expression '" + oldPath + "'", e);
throw new RuntimeException("Invalid expression '" + oldPath + "'", e);
}
}

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

/**
* Reusable, non-threadsafe version of {@link StringReader}.
* Reusable, non-threadsafe version of {@link java.io.StringReader}.
*/
public static class ReusableStringReader extends Reader {

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

/** Check to make sure that the stream has not been closed */
private void ensureOpen() throws IOException {
if (str == null)
if (str == null) {
throw new IOException("Stream closed");
}
}

@Override
public int read() throws IOException {
ensureOpen();
if (next >= length)
if (next >= length) {
return -1;
}
return str.charAt(next++);
}

@Override
public int read(char cbuf[], int off, int len) throws IOException {
public int read(char[] cbuf, int off, int len) throws IOException {
ensureOpen();
if ((off < 0) || (off > cbuf.length) || (len < 0)
|| ((off + len) > cbuf.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return 0;
}
if (next >= length)
if (next >= length) {
return -1;
}
int n = Math.min(length - next, len);
str.getChars(next, next + n, cbuf, off);
next += n;
Expand All @@ -149,8 +151,9 @@ public int read(char cbuf[], int off, int len) throws IOException {
@Override
public long skip(long ns) throws IOException {
ensureOpen();
if (next >= length)
if (next >= length) {
return 0;
}
// Bound skip by beginning and end of the source
long n = Math.min(length - next, ns);
n = Math.max(-next, n);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public UnsafeExternalRowSorter(
sparkEnv.conf().getInt("spark.shuffle.sort.initialBufferSize",
DEFAULT_INITIAL_SORT_BUFFER_SIZE),
pageSizeBytes,
SparkEnv.get().conf().getLong("spark.shuffle.spill.numElementsForceSpillThreshold", UnsafeExternalSorter
.DEFAULT_NUM_ELEMENTS_FOR_SPILL_THRESHOLD),
SparkEnv.get().conf().getLong("spark.shuffle.spill.numElementsForceSpillThreshold",
UnsafeExternalSorter.DEFAULT_NUM_ELEMENTS_FOR_SPILL_THRESHOLD),
canUseRadixSort
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ public UnsafeKVExternalSorter destructAndCreateExternalSorter() throws IOExcepti
SparkEnv.get().blockManager(),
SparkEnv.get().serializerManager(),
map.getPageSizeBytes(),
SparkEnv.get().conf().getLong("spark.shuffle.spill.numElementsForceSpillThreshold", UnsafeExternalSorter
.DEFAULT_NUM_ELEMENTS_FOR_SPILL_THRESHOLD),
SparkEnv.get().conf().getLong("spark.shuffle.spill.numElementsForceSpillThreshold",
UnsafeExternalSorter.DEFAULT_NUM_ELEMENTS_FOR_SPILL_THRESHOLD),
map);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public UnsafeKVExternalSorter(
SerializerManager serializerManager,
long pageSizeBytes,
long numElementsForSpillThreshold) throws IOException {
this(keySchema, valueSchema, blockManager, serializerManager, pageSizeBytes, numElementsForSpillThreshold, null);
this(keySchema, valueSchema, blockManager, serializerManager, pageSizeBytes,
numElementsForSpillThreshold, null);
}

public UnsafeKVExternalSorter(
Expand Down

0 comments on commit 1da6767

Please sign in to comment.