Skip to content

Commit 3db12de

Browse files
committed
Minor simplification and sanity checks in UnsafeSorter
1 parent 767d3ca commit 3db12de

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ conf/*.properties
2929
conf/*.conf
3030
conf/*.xml
3131
conf/slaves
32+
core/build/py4j/
3233
docs/_site
3334
docs/api
3435
target/

core/src/main/java/org/apache/spark/unsafe/sort/UnsafeSorter.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,22 @@ public static final class KeyPointerAndPrefix {
3030
* A pointer to a record; see {@link org.apache.spark.unsafe.memory.TaskMemoryManager} for a
3131
* description of how these addresses are encoded.
3232
*/
33-
long recordPointer;
33+
public long recordPointer;
3434

3535
/**
3636
* A key prefix, for use in comparisons.
3737
*/
38-
long keyPrefix;
38+
public long keyPrefix;
39+
40+
@Override
41+
public int hashCode() {
42+
throw new UnsupportedOperationException();
43+
}
44+
45+
@Override
46+
public boolean equals(Object obj) {
47+
throw new UnsupportedOperationException();
48+
}
3949
}
4050

4151
public static abstract class RecordComparator {
@@ -115,8 +125,9 @@ public void insertRecord(long objectAddress) {
115125
final long baseOffset = memoryManager.getOffsetInPage(objectAddress);
116126
final long keyPrefix = prefixComputer.computePrefix(baseObject, baseOffset);
117127
sortBuffer[sortBufferInsertPosition] = objectAddress;
118-
sortBuffer[sortBufferInsertPosition + 1] = keyPrefix;
119-
sortBufferInsertPosition += 2;
128+
sortBufferInsertPosition++;
129+
sortBuffer[sortBufferInsertPosition] = keyPrefix;
130+
sortBufferInsertPosition++;
120131
}
121132

122133
public Iterator<KeyPointerAndPrefix> getSortedIterator() {

core/src/main/scala/org/apache/spark/SparkEnv.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ object SparkEnv extends Logging {
313313
// Let the user specify short names for shuffle managers
314314
val shortShuffleMgrNames = Map(
315315
"hash" -> "org.apache.spark.shuffle.hash.HashShuffleManager",
316-
"sort" -> "org.apache.spark.shuffle.sort.SortShuffleManager")
316+
"sort" -> "org.apache.spark.shuffle.sort.SortShuffleManager",
317+
"unsafe" -> "org.apache.spark.shuffle.unsafe.UnsafeShuffleManager")
317318
val shuffleMgrName = conf.get("spark.shuffle.manager", "sort")
318319
val shuffleMgrClass = shortShuffleMgrNames.getOrElse(shuffleMgrName.toLowerCase, shuffleMgrName)
319320
val shuffleManager = instantiateClass[ShuffleManager](shuffleMgrClass)

core/src/main/scala/org/apache/spark/shuffle/FileShuffleBlockManager.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import org.apache.spark.storage._
3434
import org.apache.spark.util.{MetadataCleaner, MetadataCleanerType, TimeStampedHashMap}
3535
import org.apache.spark.util.collection.{PrimitiveKeyOpenHashMap, PrimitiveVector}
3636

37-
/** A group of writers for a ShuffleMapTask, one writer per reducer. */
37+
/** A group of writers for ShuffleMapTask, one writer per reducer. */
3838
private[spark] trait ShuffleWriterGroup {
3939
val writers: Array[BlockObjectWriter]
4040

0 commit comments

Comments
 (0)