Skip to content

Commit

Permalink
Add test for empty iterator in UnsafeSorter
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshRosen committed May 1, 2015
1 parent 57a4ea0 commit e900152
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.junit.Assert;
import org.junit.Test;
import static org.mockito.Mockito.*;

import org.apache.spark.HashPartitioner;
import org.apache.spark.unsafe.PlatformDependent;
Expand All @@ -43,6 +44,18 @@ private static String getStringFromDataPage(Object baseObject, long baseOffset)
return new String(strBytes);
}

@Test
public void testSortingEmptyInput() {
final UnsafeSorter sorter = new UnsafeSorter(
new TaskMemoryManager(new ExecutorMemoryManager(MemoryAllocator.HEAP)),
mock(UnsafeSorter.RecordComparator.class),
mock(UnsafeSorter.PrefixComputer.class),
mock(UnsafeSorter.PrefixComparator.class),
100);
final Iterator<UnsafeSorter.KeyPointerAndPrefix> iter = sorter.getSortedIterator();
assert(!iter.hasNext());
}

/**
* Tests the type of sorting that's used in the non-combiner path of sort-based shuffle.
*/
Expand Down

0 comments on commit e900152

Please sign in to comment.