public class ExternalSorter<E> extends Object implements Sorter<E>
ExternalSorter
is a full fledged sorter. It implements a multi-way merge sort.
Internally, the logic is factored into two or three threads (read, sort, spill) which communicate
through a set of blocking queues, forming a closed loop. Memory is allocated using the MemoryManager
interface. Thus the component will not exceed the provided memory limits.Modifier and Type | Method and Description |
---|---|
void |
close()
Shuts down all the threads initiated by this sort/merger.
|
MutableObjectIterator<E> |
getIterator()
Gets the iterator over this input.
|
boolean |
isClosed() |
static <E> ExternalSorterBuilder<E> |
newBuilder(MemoryManager memoryManager,
AbstractInvokable parentTask,
TypeSerializer<E> serializer,
TypeComparator<E> comparator)
Creates a builder for the
ExternalSorter . |
static <E> ExternalSorterBuilder<E> |
newBuilder(MemoryManager memoryManager,
TaskInvokable parentTask,
TypeSerializer<E> serializer,
TypeComparator<E> comparator,
ExecutionConfig executionConfig)
Creates a builder for the
ExternalSorter . |
public void close()
The threads are set to exit directly, but depending on their operation, it may take a while to actually happen. The sorting thread will for example not finish before the current batch is sorted. This method attempts to wait for the working thread to exit. If it is however interrupted, the method exits immediately and is not guaranteed how long the threads continue to exist and occupy resources afterwards.
close
in interface Closeable
close
in interface AutoCloseable
Closeable.close()
public boolean isClosed()
public MutableObjectIterator<E> getIterator() throws InterruptedException
CloseableInputProvider
getIterator
in interface CloseableInputProvider<E>
InterruptedException
public static <E> ExternalSorterBuilder<E> newBuilder(MemoryManager memoryManager, TaskInvokable parentTask, TypeSerializer<E> serializer, TypeComparator<E> comparator, ExecutionConfig executionConfig)
ExternalSorter
.public static <E> ExternalSorterBuilder<E> newBuilder(MemoryManager memoryManager, AbstractInvokable parentTask, TypeSerializer<E> serializer, TypeComparator<E> comparator)
ExternalSorter
.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.