Package eu.stratosphere.pact.runtime.test.util

Examples of eu.stratosphere.pact.runtime.test.util.RandomIntPairGenerator


  public void testWriteAndRead() throws Exception {
    final int numSegments = MEMORY_SIZE / MEMORY_PAGE_SIZE;
    final List<MemorySegment> memory = this.memoryManager.allocatePages(new DummyInvokable(), numSegments);
   
    FixedLengthRecordSorter<IntPair> sorter = newSortBuffer(memory);
    RandomIntPairGenerator generator = new RandomIntPairGenerator(SEED);
   
//    long startTime = System.currentTimeMillis();
    // write the records
    IntPair record = new IntPair();
    int num = -1;
    do {
      generator.next(record);
      num++;
    }
    while (sorter.write(record) && num < 3354624);
//    System.out.println("WRITE TIME " + (System.currentTimeMillis() - startTime));
   
    // re-read the records
    generator.reset();
    IntPair readTarget = new IntPair();
   
//    startTime = System.currentTimeMillis();
    int i = 0;
    while (i < num) {
      generator.next(record);
      readTarget = sorter.getRecord(readTarget, i++);
     
      int rk = readTarget.getKey();
      int gk = record.getKey();
     
View Full Code Here


  public void testWriteAndIterator() throws Exception {
    final int numSegments = MEMORY_SIZE / MEMORY_PAGE_SIZE;
    final List<MemorySegment> memory = this.memoryManager.allocatePages(new DummyInvokable(), numSegments);
   
    FixedLengthRecordSorter<IntPair> sorter = newSortBuffer(memory);
    RandomIntPairGenerator generator = new RandomIntPairGenerator(SEED);
   
    // write the records
    IntPair record = new IntPair();
    int num = -1;
    do {
      generator.next(record);
      num++;
    }
    while (sorter.write(record));
   
    // re-read the records
    generator.reset();
   
    MutableObjectIterator<IntPair> iter = sorter.getIterator();
    IntPair readTarget = new IntPair();
    int count = 0;
   
    while ((readTarget = iter.next(readTarget)) != null) {
      count++;
     
      generator.next(record);
     
      int rk = readTarget.getKey();
      int gk = record.getKey();
     
      int rv = readTarget.getValue();
View Full Code Here

  public void testReset() throws Exception {
    final int numSegments = MEMORY_SIZE / MEMORY_PAGE_SIZE;
    final List<MemorySegment> memory = this.memoryManager.allocatePages(new DummyInvokable(), numSegments);
   
    FixedLengthRecordSorter<IntPair> sorter = newSortBuffer(memory);
    RandomIntPairGenerator generator = new RandomIntPairGenerator(SEED);
   
    // write the buffer full with the first set of records
    IntPair record = new IntPair();
    int num = -1;
    do {
      generator.next(record);
      num++;
    }
    while (sorter.write(record) && num < 3354624);
   
    sorter.reset();
   
    // write a second sequence of records. since the values are of fixed length, we must be able to write an equal number
    generator.reset();
   
    // write the buffer full with the first set of records
    int num2 = -1;
    do {
      generator.next(record);
      num2++;
    }
    while (sorter.write(record) && num2 < 3354624);
   
    Assert.assertEquals("The number of records written after the reset was not the same as before.", num, num2);
   
    // re-read the records
    generator.reset();
    IntPair readTarget = new IntPair();
   
    int i = 0;
    while (i < num) {
      generator.next(record);
      readTarget = sorter.getRecord(readTarget, i++);
     
      int rk = readTarget.getKey();
      int gk = record.getKey();
     
View Full Code Here

  public void testSwap() throws Exception {
    final int numSegments = MEMORY_SIZE / MEMORY_PAGE_SIZE;
    final List<MemorySegment> memory = this.memoryManager.allocatePages(new DummyInvokable(), numSegments);
   
    FixedLengthRecordSorter<IntPair> sorter = newSortBuffer(memory);
    RandomIntPairGenerator generator = new RandomIntPairGenerator(SEED);
   
    // write the records
    IntPair record = new IntPair();
    int num = -1;
    do {
      generator.next(record);
      num++;
    }
    while (sorter.write(record) && num < 3354624);
   
    // swap the records
    int start = 0, end = num - 1;
    while (start < end) {
      sorter.swap(start++, end--);
    }
   
    // re-read the records
    generator.reset();
    IntPair readTarget = new IntPair();
   
    int i = num - 1;
    while (i >= 0) {
      generator.next(record);
      readTarget = sorter.getRecord(readTarget, i--);
     
      int rk = readTarget.getKey();
      int gk = record.getKey();
     
View Full Code Here

    final int NUM_RECORDS = 559273;
    final int numSegments = MEMORY_SIZE / MEMORY_PAGE_SIZE;
    final List<MemorySegment> memory = this.memoryManager.allocatePages(new DummyInvokable(), numSegments);
   
    FixedLengthRecordSorter<IntPair> sorter = newSortBuffer(memory);
    RandomIntPairGenerator generator = new RandomIntPairGenerator(SEED);
   
    // write the records
    IntPair record = new IntPair();
    int num = -1;
    do {
      generator.next(record);
      num++;
    }
    while (sorter.write(record) && num < NUM_RECORDS);
   
    QuickSort qs = new QuickSort();
View Full Code Here

  public void testSpillingSortWithIntermediateMergeIntPair() throws Exception {
    // amount of pairs
    final int PAIRS = 50000000;

    // comparator
    final RandomIntPairGenerator generator = new RandomIntPairGenerator(12345678, PAIRS);
   
    final TypeSerializerFactory<IntPair> serializerFactory = new IntPairSerializer.IntPairSerializerFactory();
    final TypeComparator<IntPair> comparator = new IntPairComparator();
   
    // merge iterator
View Full Code Here

TOP

Related Classes of eu.stratosphere.pact.runtime.test.util.RandomIntPairGenerator

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.