public class BinaryExternalSorter extends Object implements org.apache.flink.runtime.operators.sort.Sorter<org.apache.flink.table.data.binary.BinaryRowData>
BinaryExternalSorter is a full fledged sorter for binary format.
It implements a multi-way merge sort.
Internally, it has three asynchronous threads (sort, spill, merger) which communicate through
a set of blocking circularQueues, forming a closed loop. Memory is allocated using the
MemoryManager interface. Thus the component will not exceed the provided memory limits.| 构造器和说明 |
|---|
BinaryExternalSorter(Object owner,
org.apache.flink.runtime.memory.MemoryManager memoryManager,
long reservedMemorySize,
org.apache.flink.runtime.io.disk.iomanager.IOManager ioManager,
AbstractRowDataSerializer<org.apache.flink.table.data.RowData> inputSerializer,
BinaryRowDataSerializer serializer,
NormalizedKeyComputer normalizedKeyComputer,
RecordComparator comparator,
org.apache.flink.configuration.Configuration conf) |
BinaryExternalSorter(Object owner,
org.apache.flink.runtime.memory.MemoryManager memoryManager,
long reservedMemorySize,
org.apache.flink.runtime.io.disk.iomanager.IOManager ioManager,
AbstractRowDataSerializer<org.apache.flink.table.data.RowData> inputSerializer,
BinaryRowDataSerializer serializer,
NormalizedKeyComputer normalizedKeyComputer,
RecordComparator comparator,
org.apache.flink.configuration.Configuration conf,
float startSpillingFraction) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close()
Shuts down all the threads initiated by this sorter.
|
org.apache.flink.util.MutableObjectIterator<org.apache.flink.table.data.binary.BinaryRowData> |
getIterator() |
long |
getNumSpillFiles() |
long |
getSpillInBytes() |
long |
getUsedMemoryInBytes() |
void |
startThreads()
Starts all the threads that are used by this sorter.
|
void |
write(org.apache.flink.util.MutableObjectIterator<org.apache.flink.table.data.binary.BinaryRowData> iterator) |
void |
write(org.apache.flink.table.data.RowData current) |
public BinaryExternalSorter(Object owner, org.apache.flink.runtime.memory.MemoryManager memoryManager, long reservedMemorySize, org.apache.flink.runtime.io.disk.iomanager.IOManager ioManager, AbstractRowDataSerializer<org.apache.flink.table.data.RowData> inputSerializer, BinaryRowDataSerializer serializer, NormalizedKeyComputer normalizedKeyComputer, RecordComparator comparator, org.apache.flink.configuration.Configuration conf)
public BinaryExternalSorter(Object owner, org.apache.flink.runtime.memory.MemoryManager memoryManager, long reservedMemorySize, org.apache.flink.runtime.io.disk.iomanager.IOManager ioManager, AbstractRowDataSerializer<org.apache.flink.table.data.RowData> inputSerializer, BinaryRowDataSerializer serializer, NormalizedKeyComputer normalizedKeyComputer, RecordComparator comparator, org.apache.flink.configuration.Configuration conf, float startSpillingFraction)
public void startThreads()
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 在接口中 Closeableclose 在接口中 AutoCloseablepublic void write(org.apache.flink.table.data.RowData current)
throws IOException
IOException@VisibleForTesting
public void write(org.apache.flink.util.MutableObjectIterator<org.apache.flink.table.data.binary.BinaryRowData> iterator)
throws IOException
IOExceptionpublic org.apache.flink.util.MutableObjectIterator<org.apache.flink.table.data.binary.BinaryRowData> getIterator()
throws InterruptedException
getIterator 在接口中 org.apache.flink.runtime.operators.sort.Sorter<org.apache.flink.table.data.binary.BinaryRowData>getIterator 在接口中 org.apache.flink.runtime.operators.util.CloseableInputProvider<org.apache.flink.table.data.binary.BinaryRowData>InterruptedExceptionpublic long getUsedMemoryInBytes()
public long getNumSpillFiles()
public long getSpillInBytes()
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.