Package eu.stratosphere.nephele.services.iomanager

Examples of eu.stratosphere.nephele.services.iomanager.BlockChannelReader


      // first set up the reader with some memory.
      final List<MemorySegment> segments = new ArrayList<MemorySegment>(2);
      segments.add(getNextBuffer());
      segments.add(getNextBuffer());
     
      final BlockChannelReader inReader = this.ioManager.createBlockChannelReader(p.getBuildSideChannel().getChannelID());
      final ChannelReaderInputView inView = new HeaderlessChannelReaderInputView(inReader, segments,
            p.getBuildSideBlockCount(), p.getLastSegmentLimit(), false);
      final ChannelReaderInputViewIterator<BT> inIter = new ChannelReaderInputViewIterator<BT>(inView,
          this.availableMemory, this.buildSideSerializer);
      final TypeComparator<BT> btComparator = this.buildSideComparator;
View Full Code Here


      for (int i = 0; i < channelIDs.size(); i++) {
        final ChannelWithBlockCount channel = channelIDs.get(i);
        final List<MemorySegment> segsForChannel = inputSegments.get(i);
       
        // create a reader. if there are multiple segments for the reader, issue multiple together per I/O request
        final BlockChannelReader reader = segsForChannel.size() >= 4 ?
          this.ioManager.createBlockChannelReader(channel.getChannel(), segsForChannel.size() / 2) :
          this.ioManager.createBlockChannelReader(channel.getChannel());
         
        readerList.add(reader);
        registerOpenChannelToBeRemovedAtShudown(reader);
View Full Code Here

        numBuffersSpilled += toSpill;
      }

      // now close the writer and create the reader
      currentWriter.close();
      final BlockChannelReader reader = ioManager.createBlockChannelReader(currentWriter.getChannelID());

      // gather some memory segments to circulate while reading back the data
      final ArrayList<MemorySegment> readSegments = new ArrayList<MemorySegment>();
      try {
        while (readSegments.size() < minBuffersForSpilledReadEnd) {
          readSegments.add(emptyBuffers.take());
        }

        // read the first segment
        MemorySegment firstSeg = readSegments.remove(readSegments.size() - 1);
        reader.readBlock(firstSeg);
        firstSeg = reader.getReturnQueue().take();

        // create the read end reading one less buffer, because the first buffer is already read back
        readEnd = new ReadEnd(firstSeg, emptyBuffers, fullBuffers, reader, readSegments, segmentSize,
          numBuffersSpilled - 1);
      } catch (InterruptedException e) {
View Full Code Here

    }
    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++) {
      generator.next(rec);
      readRec.read(inView);
     
      Key k1 = rec.getField(0, Key.class);
      Value v1 = rec.getField(1, Value.class);
     
      Key k2 = readRec.getField(0, Key.class);
      Value v2 = readRec.getField(1, Value.class);
     
      Assert.assertTrue("The re-generated and the read record do not match.", k1.equals(k2) && v1.equals(v2));
    }
   
    this.memoryManager.release(inView.close());
    reader.deleteChannel();
  }
View Full Code Here

    }
    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++) {
      generator.next(rec);
      readRec.read(inView);
      final Key k1 = rec.getField(0, Key.class);
      final Value v1 = rec.getField(1, Value.class);
      final Key k2 = readRec.getField(0, Key.class);
      final Value v2 = readRec.getField(1, Value.class);
      Assert.assertTrue("The re-generated and the read record do not match.", k1.equals(k2) && v1.equals(v2));
    }
   
    this.memoryManager.release(inView.close());
    reader.deleteChannel();
  }
View Full Code Here

    }
    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();
      for (int i = 0; i < NUM_PAIRS_SHORT + 1; i++) {
        generator.next(rec);
        readRec.read(inView);
        final Key k1 = rec.getField(0, Key.class);
        final Value v1 = rec.getField(1, Value.class);
        final Key k2 = readRec.getField(0, Key.class);
        final Value v2 = readRec.getField(1, Value.class);
        Assert.assertTrue("The re-generated and the read record do not match.", k1.equals(k2) && v1.equals(v2));
      }
      Assert.fail("Expected an EOFException which did not occur.");
    }
    catch (EOFException eofex) {
      // expected
    }
    catch (Throwable t) {
      // unexpected
      Assert.fail("Unexpected Exception: " + t.getMessage());
    }
   
    this.memoryManager.release(inView.close());
    reader.deleteChannel();
  }
View Full Code Here

    }
    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);
    generator.reset();
   
    // read and re-generate all records and cmpare them
    final Record readRec = new Record();
    for (int i = 0; i < NUM_PAIRS_SHORT; i++) {
      generator.next(rec);
      readRec.read(inView);
     
      Key k1 = rec.getField(0, Key.class);
      Value v1 = rec.getField(1, Value.class);
     
      Key k2 = readRec.getField(0, Key.class);
      Value v2 = readRec.getField(1, Value.class);
     
      Assert.assertTrue("The re-generated and the read record do not match.", k1.equals(k2) && v1.equals(v2));
    }
   
    this.memoryManager.release(inView.close());
    reader.deleteChannel();
  }
View Full Code Here

    }
    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++) {
      generator.next(rec);
      readRec.read(inView);
     
      Key k1 = rec.getField(0, Key.class);
      Value v1 = rec.getField(1, Value.class);
     
      Key k2 = readRec.getField(0, Key.class);
      Value v2 = readRec.getField(1, Value.class);
     
      Assert.assertTrue("The re-generated and the read record do not match.", k1.equals(k2) && v1.equals(v2));
    }
   
    this.memoryManager.release(inView.close());
    reader.deleteChannel();
  }
View Full Code Here

    }
    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++) {
      generator.next(rec);
      readRec.read(inView);
     
      Key k1 = rec.getField(0, Key.class);
      Value v1 = rec.getField(1, Value.class);
     
      Key k2 = readRec.getField(0, Key.class);
      Value v2 = readRec.getField(1, Value.class);
     
      Assert.assertTrue("The re-generated and the read record do not match.", k1.equals(k2) && v1.equals(v2));
    }
   
    this.memoryManager.release(inView.close());
    reader.deleteChannel();
  }
View Full Code Here

      // recollect memory from a previous view
      if (this.externalInView != null) {
        this.externalInView.close();
      }
     
      final BlockChannelReader reader = this.ioManager.createBlockChannelReader(this.writer.getChannelID());
      this.externalInView = new HeaderlessChannelReaderInputView(reader, this.fullSegments, this.blockCount, this.numBytesInLastSegment, false);
      return this.externalInView;
    }
  }
View Full Code Here

TOP

Related Classes of eu.stratosphere.nephele.services.iomanager.BlockChannelReader

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.