diff options
Diffstat (limited to 'core/src/main/java/org/apache/spark/util')
3 files changed, 17 insertions, 18 deletions
diff --git a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/PrefixComparators.java b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/PrefixComparators.java index 21f2fde79d..c44630fbbc 100644 --- a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/PrefixComparators.java +++ b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/PrefixComparators.java @@ -22,7 +22,6 @@ import com.google.common.primitives.UnsignedLongs; import org.apache.spark.annotation.Private; import org.apache.spark.unsafe.types.ByteArray; import org.apache.spark.unsafe.types.UTF8String; -import org.apache.spark.util.Utils; @Private public class PrefixComparators { @@ -69,7 +68,7 @@ public class PrefixComparators { * Provides radix sort parameters. Comparators implementing this also are indicating that the * ordering they define is compatible with radix sort. */ - public static abstract class RadixSortSupport extends PrefixComparator { + public abstract static class RadixSortSupport extends PrefixComparator { /** @return Whether the sort should be descending in binary sort order. */ public abstract boolean sortDescending(); @@ -82,37 +81,37 @@ public class PrefixComparators { // public static final class UnsignedPrefixComparator extends RadixSortSupport { - @Override public final boolean sortDescending() { return false; } - @Override public final boolean sortSigned() { return false; } + @Override public boolean sortDescending() { return false; } + @Override public boolean sortSigned() { return false; } @Override - public final int compare(long aPrefix, long bPrefix) { + public int compare(long aPrefix, long bPrefix) { return UnsignedLongs.compare(aPrefix, bPrefix); } } public static final class UnsignedPrefixComparatorDesc extends RadixSortSupport { - @Override public final boolean sortDescending() { return true; } - @Override public final boolean sortSigned() { return false; } + @Override public boolean sortDescending() { return true; } + @Override public boolean sortSigned() { return false; } @Override - public final int compare(long bPrefix, long aPrefix) { + public int compare(long bPrefix, long aPrefix) { return UnsignedLongs.compare(aPrefix, bPrefix); } } public static final class SignedPrefixComparator extends RadixSortSupport { - @Override public final boolean sortDescending() { return false; } - @Override public final boolean sortSigned() { return true; } + @Override public boolean sortDescending() { return false; } + @Override public boolean sortSigned() { return true; } @Override - public final int compare(long a, long b) { + public int compare(long a, long b) { return (a < b) ? -1 : (a > b) ? 1 : 0; } } public static final class SignedPrefixComparatorDesc extends RadixSortSupport { - @Override public final boolean sortDescending() { return true; } - @Override public final boolean sortSigned() { return true; } + @Override public boolean sortDescending() { return true; } + @Override public boolean sortSigned() { return true; } @Override - public final int compare(long b, long a) { + public int compare(long b, long a) { return (a < b) ? -1 : (a > b) ? 1 : 0; } } diff --git a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/RadixSort.java b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/RadixSort.java index 3357b8e474..4f3f0de7b8 100644 --- a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/RadixSort.java +++ b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/RadixSort.java @@ -16,7 +16,7 @@ */ package org.apache.spark.util.collection.unsafe.sort; - + import org.apache.spark.unsafe.Platform; import org.apache.spark.unsafe.array.LongArray; @@ -227,7 +227,7 @@ public class RadixSort { } return counts; } - + /** * Specialization of sortAtByte() for key-prefix arrays. */ diff --git a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java index 3c1cd39dc2..8b6c96a4c4 100644 --- a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java +++ b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java @@ -212,8 +212,8 @@ public final class UnsafeExternalSorter extends MemoryConsumer { // written to disk. This also counts the space needed to store the sorter's pointer array. inMemSorter.reset(); // Reset the in-memory sorter's pointer array only after freeing up the memory pages holding the - // records. Otherwise, if the task is over allocated memory, then without freeing the memory pages, - // we might not be able to get memory for the pointer array. + // records. Otherwise, if the task is over allocated memory, then without freeing the memory + // pages, we might not be able to get memory for the pointer array. taskContext.taskMetrics().incMemoryBytesSpilled(spillSize); totalSpillBytes += spillSize; |