Package org.apache.flink.runtime.io.disk.iomanager

Examples of org.apache.flink.runtime.io.disk.iomanager.ChannelWriterOutputView


    final Channel.ID channel = this.ioManager.createChannel();
   
    // create the writer output view
    List<MemorySegment> memory = this.memoryManager.allocatePages(this.parentTask, NUM_MEMORY_SEGMENTS);
    final BlockChannelWriter writer = this.ioManager.createBlockChannelWriter(channel);
    final ChannelWriterOutputView outView = new ChannelWriterOutputView(writer, memory, MEMORY_PAGE_SIZE);
   
    // write a number of pairs
    final Record rec = new Record();
    for (int i = 0; i < NUM_PAIRS_SHORT; i++) {
      generator.next(rec);
      rec.write(outView);
    }
    this.memoryManager.release(outView.close());
   
    // create the reader input view
    memory = this.memoryManager.allocatePages(this.parentTask, NUM_MEMORY_SEGMENTS);
    final BlockChannelReader reader = this.ioManager.createBlockChannelReader(channel);
    final ChannelReaderInputView inView = new ChannelReaderInputView(reader, memory, outView.getBlockCount(), true);
    generator.reset();
   
    // read and re-generate all records and compare them
    final Record readRec = new Record();
    for (int i = 0; i < NUM_PAIRS_SHORT; i++) {
View Full Code Here


    final Channel.ID channel = this.ioManager.createChannel();
   
    // create the writer output view
    List<MemorySegment> memory = this.memoryManager.allocatePages(this.parentTask, NUM_MEMORY_SEGMENTS);
    final BlockChannelWriter writer = this.ioManager.createBlockChannelWriter(channel);
    final ChannelWriterOutputView outView = new ChannelWriterOutputView(writer, memory, MEMORY_PAGE_SIZE);
   
    // write a number of pairs
    final Record rec = new Record();
    for (int i = 0; i < NUM_PAIRS_LONG; i++) {
      generator.next(rec);
      rec.write(outView);
    }
    this.memoryManager.release(outView.close());
   
    // create the reader input view
    memory = this.memoryManager.allocatePages(this.parentTask, NUM_MEMORY_SEGMENTS);
    final BlockChannelReader reader = this.ioManager.createBlockChannelReader(channel);
    final ChannelReaderInputView inView = new ChannelReaderInputView(reader, memory, outView.getBlockCount(), true);
    generator.reset();
   
    // read and re-generate all records and compare them
    final Record readRec = new Record();
    for (int i = 0; i < NUM_PAIRS_LONG; i++) {
View Full Code Here

    final Channel.ID channel = this.ioManager.createChannel();
   
    // create the writer output view
    List<MemorySegment> memory = this.memoryManager.allocatePages(this.parentTask, NUM_MEMORY_SEGMENTS);
    final BlockChannelWriter writer = this.ioManager.createBlockChannelWriter(channel);
    final ChannelWriterOutputView outView = new ChannelWriterOutputView(writer, memory, MEMORY_PAGE_SIZE);

    // write a number of pairs
    final Record rec = new Record();
    for (int i = 0; i < NUM_PAIRS_SHORT; i++) {
      generator.next(rec);
      rec.write(outView);
    }
    this.memoryManager.release(outView.close());

    // create the reader input view
    memory = this.memoryManager.allocatePages(this.parentTask, NUM_MEMORY_SEGMENTS);
    final BlockChannelReader reader = this.ioManager.createBlockChannelReader(channel);
    final ChannelReaderInputView inView = new ChannelReaderInputView(reader, memory, outView.getBlockCount(), true);
    generator.reset();

    // read and re-generate all records and compare them
    try {
      final Record readRec = new Record();
View Full Code Here

    final Channel.ID channel = this.ioManager.createChannel();
   
    // create the writer output view
    List<MemorySegment> memory = this.memoryManager.allocatePages(this.parentTask, NUM_MEMORY_SEGMENTS);
    final BlockChannelWriter writer = this.ioManager.createBlockChannelWriter(channel);
    final ChannelWriterOutputView outView = new ChannelWriterOutputView(writer, memory, MEMORY_PAGE_SIZE);
   
    // write a number of pairs
    final Record rec = new Record();
    for (int i = 0; i < NUM_PAIRS_SHORT; i++) {
      generator.next(rec);
      rec.write(outView);
    }
    this.memoryManager.release(outView.close());
   
    // create the reader input view
    memory = this.memoryManager.allocatePages(this.parentTask, NUM_MEMORY_SEGMENTS);
    final BlockChannelReader reader = this.ioManager.createBlockChannelReader(channel);
    final ChannelReaderInputView inView = new ChannelReaderInputView(reader, memory, true);
View Full Code Here

    final Channel.ID channel = this.ioManager.createChannel();
   
    // create the writer output view
    List<MemorySegment> memory = this.memoryManager.allocatePages(this.parentTask, 1);
    final BlockChannelWriter writer = this.ioManager.createBlockChannelWriter(channel);
    final ChannelWriterOutputView outView = new ChannelWriterOutputView(writer, memory, MEMORY_PAGE_SIZE);
   
    // write a number of pairs
    final Record rec = new Record();
    for (int i = 0; i < NUM_PAIRS_SHORT; i++) {
      generator.next(rec);
      rec.write(outView);
    }
    this.memoryManager.release(outView.close());
   
    // create the reader input view
    memory = this.memoryManager.allocatePages(this.parentTask, 1);
    final BlockChannelReader reader = this.ioManager.createBlockChannelReader(channel);
    final ChannelReaderInputView inView = new ChannelReaderInputView(reader, memory, outView.getBlockCount(), true);
    generator.reset();
   
    // read and re-generate all records and compare them
    final Record readRec = new Record();
    for (int i = 0; i < NUM_PAIRS_SHORT; i++) {
View Full Code Here

    BlockChannelWriter writer = null;
    BlockChannelReader reader = null;
   
    try
      writer = this.ioManager.createBlockChannelWriter(channel);
      final ChannelWriterOutputView out = new ChannelWriterOutputView(writer, memory, this.memManager.getPageSize());
     
      long writeStart = System.currentTimeMillis();
     
      int valsLeft = NUM_INTS_WRITTEN;
      while (valsLeft-- > 0) {
        out.writeInt(valsLeft);
      }
     
      out.close();
      final int numBlocks = out.getBlockCount();
      writer.close();
      writer = null;
     
      long writeElapsed = System.currentTimeMillis() - writeStart;
     
View Full Code Here

    final Channel.ID channel = this.ioManager.createChannel();
   
    // create the writer output view
    List<MemorySegment> memory = this.memoryManager.allocatePages(this.parentTask, NUM_MEMORY_SEGMENTS);
    final BlockChannelWriter writer = this.ioManager.createBlockChannelWriter(channel);
    final ChannelWriterOutputView outView = new ChannelWriterOutputView(writer, memory, MEMORY_PAGE_SIZE);
   
    // write a number of pairs
    final Record rec = new Record();
    for (int i = 0; i < NUM_PAIRS_SHORT; i++) {
      generator.next(rec);
      rec.write(outView);
    }
    this.memoryManager.release(outView.close());
   
    // create the reader input view
    memory = this.memoryManager.allocatePages(this.parentTask, NUM_MEMORY_SEGMENTS);
    final BlockChannelReader reader = this.ioManager.createBlockChannelReader(channel);
    final ChannelReaderInputView inView = new ChannelReaderInputView(reader, memory, outView.getBlockCount(), true);
    generator.reset();
   
    // read and re-generate all records and compare them
    final Record readRec = new Record();
    for (int i = 0; i < NUM_PAIRS_SHORT / 2; i++) {
View Full Code Here

        // create writer
        final BlockChannelWriter writer = this.ioManager.createBlockChannelWriter(
                                channel, this.numWriteBuffersToCluster);
        registerOpenChannelToBeRemovedAtShudown(writer);
        final ChannelWriterOutputView output = new ChannelWriterOutputView(writer, this.writeMemory,
                                      this.memManager.getPageSize());

        // write sort-buffer to channel
        if (LOG.isDebugEnabled()) {
          LOG.debug("Combining buffer " + element.id + '.');
        }

        // set up the combining helpers
        final InMemorySorter<E> buffer = element.buffer;
        final CombineValueIterator<E> iter = new CombineValueIterator<E>(buffer, this.serializer.createInstance());
        final WriterCollector<E> collector = new WriterCollector<E>(output, this.serializer);

        int i = 0;
        int stop = buffer.size() - 1;

        try {
          while (i < stop) {
            int seqStart = i;
            while (i < stop && 0 == buffer.compare(i, i + 1)) {
              i++;
            }
 
            if (i == seqStart) {
              // no duplicate key, no need to combine. simply copy
              buffer.writeToOutput(output, seqStart, 1);
            } else {
              // get the iterator over the values
              iter.set(seqStart, i);
              // call the combiner to combine
              combineStub.combine(iter, collector);
            }
            i++;
          }
        }
        catch (Exception ex) {
          throw new IOException("An error occurred in the combiner user code.", ex);
        }

        // write the last pair, if it has not yet been included in the last iteration
        if (i == stop) {
          buffer.writeToOutput(output, stop, 1);
        }

        // done combining and writing out
        if (LOG.isDebugEnabled()) {
          LOG.debug("Combined and spilled buffer " + element.id + ".");
        }

        output.close();
        unregisterOpenChannelToBeRemovedAtShudown(writer);
       
        channelIDs.add(new ChannelWithBlockCount(channel, output.getBlockCount()));

        // pass empty sort-buffer to reading thread
        element.buffer.reset();
        this.queues.empty.add(element);
      }
View Full Code Here

      final Channel.ID mergedChannelID = this.ioManager.createChannel();
      registerChannelToBeRemovedAtShudown(mergedChannelID);
      final BlockChannelWriter writer = this.ioManager.createBlockChannelWriter(
                              mergedChannelID, this.numWriteBuffersToCluster);
      registerOpenChannelToBeRemovedAtShudown(writer);
      final ChannelWriterOutputView output = new ChannelWriterOutputView(writer, writeBuffers,
                                      this.memManager.getPageSize());
     
      final WriterCollector<E> collector = new WriterCollector<E>(output, this.serializer);
      final FlatCombineFunction<E> combineStub = CombiningUnilateralSortMerger.this.combineStub;

      // combine and write to disk
      try {
        while (groupedIter.nextKey()) {
          combineStub.combine(groupedIter.getValues(), collector);
        }
      }
      catch (Exception e) {
        throw new IOException("An error occurred in the combiner user code.");
      }
      output.close(); //IS VERY IMPORTANT!!!!
     
      final int numBlocksWritten = output.getBlockCount();
     
      // register merged result to be removed at shutdown
      unregisterOpenChannelToBeRemovedAtShudown(writer);
     
      // remove the merged channel readers from the clear-at-shutdown list
View Full Code Here

        // create writer
        final BlockChannelWriter writer = this.ioManager.createBlockChannelWriter(
                                channel, this.numWriteBuffersToCluster);
        registerOpenChannelToBeRemovedAtShudown(writer);
        final ChannelWriterOutputView output = new ChannelWriterOutputView(writer, this.writeMemory,
                                      this.memManager.getPageSize());

        // write sort-buffer to channel
        if (LOG.isDebugEnabled()) {
          LOG.debug("Spilling buffer " + element.id + ".");
        }
        element.buffer.writeToOutput(output);
        if (LOG.isDebugEnabled()) {
          LOG.debug("Spilled buffer " + element.id + ".");
        }

        output.close();
        unregisterOpenChannelToBeRemovedAtShudown(writer);
       
        channelIDs.add(new ChannelWithBlockCount(channel, output.getBlockCount()));

        // pass empty sort-buffer to reading thread
        element.buffer.reset();
        this.queues.empty.add(element);
      }
View Full Code Here

TOP

Related Classes of org.apache.flink.runtime.io.disk.iomanager.ChannelWriterOutputView

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.