public class AsynchronousPartialSorterCollector<E> extends AsynchronousPartialSorter<E>
AsynchronousPartialSorterCollector is a simple sort implementation that sorts
bulks inside its buffers, and returns them directly, without merging them. Therefore,
it establishes an order within certain windows, but not across them.
In contract to the AsynchronousPartialSorter, this class has no dedicated reading thread that
pulls records from an iterator, but offers a collector into which data to be sorted is pushed.
UnilateralSortMerger.ChannelWithBlockCount, UnilateralSortMerger.CircularElement<E>, UnilateralSortMerger.CircularQueues<E>, UnilateralSortMerger.InputDataCollector<E>, UnilateralSortMerger.ReadingThread<E>, UnilateralSortMerger.SortingThread<E>, UnilateralSortMerger.SpillingThread, UnilateralSortMerger.ThreadBase<E>closed, iterator, iteratorException, iteratorLock, MAX_NUM_WRITE_BUFFERS, memoryManager, MIN_NUM_SORT_MEM_SEGMENTS, MIN_NUM_WRITE_BUFFERS, sortReadMemory, writeMemory| Constructor and Description |
|---|
AsynchronousPartialSorterCollector(MemoryManager memoryManager,
AbstractInvokable parentTask,
TypeSerializerFactory<E> serializerFactory,
TypeComparator<E> comparator,
double memoryFraction) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Shuts down all the threads initiated by this sort/merger.
|
UnilateralSortMerger.InputDataCollector<E> |
getInputCollector()
Gets the collector that writes into the sort buffers.
|
protected UnilateralSortMerger.ThreadBase<E> |
getReadingThread(ExceptionHandler<IOException> exceptionHandler,
MutableObjectIterator<E> reader,
UnilateralSortMerger.CircularQueues<E> queues,
AbstractInvokable parentTask,
TypeSerializer<E> serializer,
long startSpillingBytes)
Creates the reading thread.
|
getSpillingThreadendMarker, getIterator, getSortingThread, setResultIterator, setResultIteratorException, spillingMarker, startThreadspublic AsynchronousPartialSorterCollector(MemoryManager memoryManager, AbstractInvokable parentTask, TypeSerializerFactory<E> serializerFactory, TypeComparator<E> comparator, double memoryFraction) throws IOException, MemoryAllocationException
memoryManager - The memory manager from which to allocate the memory.parentTask - The parent task, which owns all resources used by this sorter.serializerFactory - The type serializer.comparator - The type comparator establishing the order relation.memoryFraction - The fraction of memory dedicated to sorting.IOException - Thrown, if an error occurs initializing the resources for external sorting.MemoryAllocationException - Thrown, if not enough memory can be obtained from the memory manager to
perform the sort.public UnilateralSortMerger.InputDataCollector<E> getInputCollector()
protected UnilateralSortMerger.ThreadBase<E> getReadingThread(ExceptionHandler<IOException> exceptionHandler, MutableObjectIterator<E> reader, UnilateralSortMerger.CircularQueues<E> queues, AbstractInvokable parentTask, TypeSerializer<E> serializer, long startSpillingBytes)
UnilateralSortMergerThe returned thread is not yet started.
getReadingThread in class UnilateralSortMerger<E>exceptionHandler - The handler for exceptions in the thread.reader - The reader from which the thread reads.queues - The queues through which the thread communicates with the other threads.parentTask - The task at which the thread registers itself (for profiling purposes).serializer - The serializer used to serialize records.startSpillingBytes - The number of bytes after which the reader thread will send the notification to
start the spilling.public void close()
UnilateralSortMergerThe 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 Closeableclose in interface AutoCloseableclose in class AsynchronousPartialSorter<E>Closeable.close()Copyright © 2014 The Apache Software Foundation. All rights reserved.