Search in sources :

Example 6 with ChannelReaderInputViewIterator

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

the class LongHybridHashTable method prepareNextPartition.

private boolean prepareNextPartition() throws IOException {
    // finalize and cleanup the partitions of the current table
    for (final LongHashPartition p : this.partitionsBeingBuilt) {
        p.finalizeProbePhase(this.partitionsPending);
    }
    this.partitionsBeingBuilt.clear();
    if (this.currentSpilledProbeSide != null) {
        this.currentSpilledProbeSide.getChannel().closeAndDelete();
        this.currentSpilledProbeSide = null;
    }
    if (this.partitionsPending.isEmpty()) {
        // no more data
        return false;
    }
    // there are pending partitions
    final LongHashPartition p = this.partitionsPending.get(0);
    LOG.info(String.format("Begin to process spilled partition [%d]", p.getPartitionNumber()));
    if (p.probeSideRecordCounter == 0) {
        this.partitionsPending.remove(0);
        return prepareNextPartition();
    }
    // build the next table; memory must be allocated after this call
    buildTableFromSpilledPartition(p);
    // set the probe side
    ChannelWithMeta channelWithMeta = new ChannelWithMeta(p.probeSideBuffer.getChannel().getChannelID(), p.probeSideBuffer.getBlockCount(), p.probeNumBytesInLastSeg);
    this.currentSpilledProbeSide = FileChannelUtil.createInputView(ioManager, channelWithMeta, new ArrayList<>(), compressionEnable, compressionCodecFactory, compressionBlockSize, segmentSize);
    ChannelReaderInputViewIterator<BinaryRowData> probeReader = new ChannelReaderInputViewIterator(this.currentSpilledProbeSide, new ArrayList<>(), this.probeSideSerializer);
    this.probeIterator.set(probeReader);
    this.probeIterator.setReuse(probeSideSerializer.createInstance());
    // unregister the pending partition
    this.partitionsPending.remove(0);
    this.currentRecursionDepth = p.getRecursionLevel() + 1;
    // recursively get the next
    return nextMatching();
}
Also used : ArrayList(java.util.ArrayList) BinaryRowData(org.apache.flink.table.data.binary.BinaryRowData) ChannelReaderInputViewIterator(org.apache.flink.runtime.io.disk.ChannelReaderInputViewIterator) ChannelWithMeta(org.apache.flink.table.runtime.io.ChannelWithMeta)

Aggregations

ChannelReaderInputViewIterator (org.apache.flink.runtime.io.disk.ChannelReaderInputViewIterator)6 ArrayList (java.util.ArrayList)4 MemorySegment (org.apache.flink.core.memory.MemorySegment)4 ChannelReaderInputView (org.apache.flink.runtime.io.disk.iomanager.ChannelReaderInputView)4 ChannelWriterOutputView (org.apache.flink.runtime.io.disk.iomanager.ChannelWriterOutputView)2 FileIOChannel (org.apache.flink.runtime.io.disk.iomanager.FileIOChannel)2 HeaderlessChannelReaderInputView (org.apache.flink.runtime.io.disk.iomanager.HeaderlessChannelReaderInputView)2 DummyInvokable (org.apache.flink.runtime.operators.testutils.DummyInvokable)2 UniformIntPairGenerator (org.apache.flink.runtime.operators.testutils.UniformIntPairGenerator)2 IntPair (org.apache.flink.runtime.operators.testutils.types.IntPair)2 BinaryRowData (org.apache.flink.table.data.binary.BinaryRowData)2 ChannelWithMeta (org.apache.flink.table.runtime.io.ChannelWithMeta)2 Test (org.junit.Test)2 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 BulkBlockChannelReader (org.apache.flink.runtime.io.disk.iomanager.BulkBlockChannelReader)1 BinaryRowChannelInputViewIterator (org.apache.flink.table.runtime.io.BinaryRowChannelInputViewIterator)1