Search in sources :

Example 1 with AbstractChannelReaderInputView

use of org.apache.flink.runtime.io.disk.iomanager.AbstractChannelReaderInputView in project flink by apache.

the class AbstractBinaryExternalMerger method getMergingIterator.

/**
 * Returns an iterator that iterates over the merged result from all given channels.
 *
 * @param channelIDs The channels that are to be merged and returned.
 * @return An iterator over the merged records of the input channels.
 * @throws IOException Thrown, if the readers encounter an I/O problem.
 */
public BinaryMergeIterator<Entry> getMergingIterator(List<ChannelWithMeta> channelIDs, List<FileIOChannel> openChannels) throws IOException {
    // create one iterator per channel id
    if (LOG.isDebugEnabled()) {
        LOG.debug("Performing merge of " + channelIDs.size() + " sorted streams.");
    }
    final List<MutableObjectIterator<Entry>> iterators = new ArrayList<>(channelIDs.size() + 1);
    for (ChannelWithMeta channel : channelIDs) {
        AbstractChannelReaderInputView view = FileChannelUtil.createInputView(ioManager, channel, openChannels, compressionEnable, compressionCodecFactory, compressionBlockSize, pageSize);
        iterators.add(channelReaderInputViewIterator(view));
    }
    return new BinaryMergeIterator<>(iterators, mergeReusedEntries(channelIDs.size()), mergeComparator());
}
Also used : MutableObjectIterator(org.apache.flink.util.MutableObjectIterator) ArrayList(java.util.ArrayList) AbstractChannelReaderInputView(org.apache.flink.runtime.io.disk.iomanager.AbstractChannelReaderInputView) ChannelWithMeta(org.apache.flink.table.runtime.io.ChannelWithMeta)

Aggregations

ArrayList (java.util.ArrayList)1 AbstractChannelReaderInputView (org.apache.flink.runtime.io.disk.iomanager.AbstractChannelReaderInputView)1 ChannelWithMeta (org.apache.flink.table.runtime.io.ChannelWithMeta)1 MutableObjectIterator (org.apache.flink.util.MutableObjectIterator)1