Skip to content

Commit 56781a1

Browse files
committed
Rename UnsafeShuffleSorter to UnsafeShuffleInMemorySorter
1 parent e995d1a commit 56781a1

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

core/src/main/java/org/apache/spark/shuffle/unsafe/UnsafeShuffleExternalSorter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
* <p>
4343
* Incoming records are appended to data pages. When all records have been inserted (or when the
4444
* current thread's shuffle memory limit is reached), the in-memory records are sorted according to
45-
* their partition ids (using a {@link UnsafeShuffleSorter}). The sorted records are then written
46-
* to a single output file (or multiple files, if we've spilled). The format of the output files is
47-
* the same as the format of the final output file written by
45+
* their partition ids (using a {@link UnsafeShuffleInMemorySorter}). The sorted records are then
46+
* written to a single output file (or multiple files, if we've spilled). The format of the output
47+
* files is the same as the format of the final output file written by
4848
* {@link org.apache.spark.shuffle.sort.SortShuffleWriter}: each output partition's records are
4949
* written as a single serialized, compressed stream that can be read with a new decompression and
5050
* deserialization stream.
@@ -86,7 +86,7 @@ final class UnsafeShuffleExternalSorter {
8686
private final LinkedList<SpillInfo> spills = new LinkedList<SpillInfo>();
8787

8888
// All three of these variables are reset after spilling:
89-
private UnsafeShuffleSorter sorter;
89+
private UnsafeShuffleInMemorySorter sorter;
9090
private MemoryBlock currentPage = null;
9191
private long currentPagePosition = -1;
9292
private long freeSpaceInCurrentPage = 0;
@@ -128,7 +128,7 @@ private void openSorter() throws IOException {
128128
}
129129
}
130130

131-
this.sorter = new UnsafeShuffleSorter(initialSize);
131+
this.sorter = new UnsafeShuffleInMemorySorter(initialSize);
132132
}
133133

134134
/**
@@ -153,7 +153,7 @@ private void writeSpillFile(boolean isSpill) throws IOException {
153153
}
154154

155155
// This call performs the actual sort.
156-
final UnsafeShuffleSorter.UnsafeShuffleSorterIterator sortedRecords =
156+
final UnsafeShuffleInMemorySorter.UnsafeShuffleSorterIterator sortedRecords =
157157
sorter.getSortedIterator();
158158

159159
// Currently, we need to open a new DiskBlockObjectWriter for each partition; we can avoid this

core/src/main/java/org/apache/spark/shuffle/unsafe/UnsafeShuffleSorter.java renamed to core/src/main/java/org/apache/spark/shuffle/unsafe/UnsafeShuffleInMemorySorter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import org.apache.spark.util.collection.Sorter;
2323

24-
final class UnsafeShuffleSorter {
24+
final class UnsafeShuffleInMemorySorter {
2525

2626
private final Sorter<PackedRecordPointer, long[]> sorter;
2727
private static final class SortComparator implements Comparator<PackedRecordPointer> {
@@ -39,7 +39,7 @@ public int compare(PackedRecordPointer left, PackedRecordPointer right) {
3939
*/
4040
private int sortBufferInsertPosition = 0;
4141

42-
public UnsafeShuffleSorter(int initialSize) {
42+
public UnsafeShuffleInMemorySorter(int initialSize) {
4343
assert (initialSize > 0);
4444
this.sortBuffer = new long[initialSize];
4545
this.sorter = new Sorter<PackedRecordPointer, long[]>(UnsafeShuffleSortDataFormat.INSTANCE);

core/src/test/java/org/apache/spark/shuffle/unsafe/UnsafeShuffleSorterSuite.java renamed to core/src/test/java/org/apache/spark/shuffle/unsafe/UnsafeShuffleInMemorySorterSuite.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.apache.spark.unsafe.memory.MemoryBlock;
3131
import org.apache.spark.unsafe.memory.TaskMemoryManager;
3232

33-
public class UnsafeShuffleSorterSuite {
33+
public class UnsafeShuffleInMemorySorterSuite {
3434

3535
private static String getStringFromDataPage(Object baseObject, long baseOffset, int strLength) {
3636
final byte[] strBytes = new byte[strLength];
@@ -44,8 +44,8 @@ private static String getStringFromDataPage(Object baseObject, long baseOffset,
4444

4545
@Test
4646
public void testSortingEmptyInput() {
47-
final UnsafeShuffleSorter sorter = new UnsafeShuffleSorter(100);
48-
final UnsafeShuffleSorter.UnsafeShuffleSorterIterator iter = sorter.getSortedIterator();
47+
final UnsafeShuffleInMemorySorter sorter = new UnsafeShuffleInMemorySorter(100);
48+
final UnsafeShuffleInMemorySorter.UnsafeShuffleSorterIterator iter = sorter.getSortedIterator();
4949
assert(!iter.hasNext());
5050
}
5151

@@ -66,7 +66,7 @@ public void testBasicSorting() throws Exception {
6666
new TaskMemoryManager(new ExecutorMemoryManager(MemoryAllocator.HEAP));
6767
final MemoryBlock dataPage = memoryManager.allocatePage(2048);
6868
final Object baseObject = dataPage.getBaseObject();
69-
final UnsafeShuffleSorter sorter = new UnsafeShuffleSorter(4);
69+
final UnsafeShuffleInMemorySorter sorter = new UnsafeShuffleInMemorySorter(4);
7070
final HashPartitioner hashPartitioner = new HashPartitioner(4);
7171

7272
// Write the records into the data page and store pointers into the sorter
@@ -87,7 +87,7 @@ public void testBasicSorting() throws Exception {
8787
}
8888

8989
// Sort the records
90-
final UnsafeShuffleSorter.UnsafeShuffleSorterIterator iter = sorter.getSortedIterator();
90+
final UnsafeShuffleInMemorySorter.UnsafeShuffleSorterIterator iter = sorter.getSortedIterator();
9191
int prevPartitionId = -1;
9292
Arrays.sort(dataToSort);
9393
for (int i = 0; i < dataToSort.length; i++) {
@@ -111,7 +111,7 @@ public void testBasicSorting() throws Exception {
111111

112112
@Test
113113
public void testSortingManyNumbers() throws Exception {
114-
UnsafeShuffleSorter sorter = new UnsafeShuffleSorter(4);
114+
UnsafeShuffleInMemorySorter sorter = new UnsafeShuffleInMemorySorter(4);
115115
int[] numbersToSort = new int[128000];
116116
Random random = new Random(16);
117117
for (int i = 0; i < numbersToSort.length; i++) {
@@ -120,7 +120,7 @@ public void testSortingManyNumbers() throws Exception {
120120
}
121121
Arrays.sort(numbersToSort);
122122
int[] sorterResult = new int[numbersToSort.length];
123-
UnsafeShuffleSorter.UnsafeShuffleSorterIterator iter = sorter.getSortedIterator();
123+
UnsafeShuffleInMemorySorter.UnsafeShuffleSorterIterator iter = sorter.getSortedIterator();
124124
int j = 0;
125125
while (iter.hasNext()) {
126126
iter.loadNext();

0 commit comments

Comments
 (0)