Package eu.stratosphere.types

Examples of eu.stratosphere.types.Record


    this.memoryManager.allocatePages(this.parentTask, memory, NUM_MEMORY_SEGMENTS);
    final SpillingBuffer outView = new SpillingBuffer(this.ioManager,
              new ListMemorySegmentSource(memory), this.memoryManager.getPageSize());
   
    // write a number of pairs
    final Record rec = new Record();
    for (int i = 0; i < NUM_PAIRS_INMEM; i++) {
      generator.next(rec);
      rec.write(outView);
    }
   
    // create the reader input view
    DataInputView inView = outView.flip();
    generator.reset();
   
    // read and re-generate all records and compare them
    final Record readRec = new Record();
    for (int i = 0; i < NUM_PAIRS_INMEM; 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));
    }
   
    // re-read the data
    inView = outView.flip();
    generator.reset();
   
    // read and re-generate all records and compare them
    for (int i = 0; i < NUM_PAIRS_INMEM; 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(outView.close());
View Full Code Here


    this.memoryManager.allocatePages(this.parentTask, memory, NUM_MEMORY_SEGMENTS);
    final SpillingBuffer outView = new SpillingBuffer(this.ioManager,
              new ListMemorySegmentSource(memory), this.memoryManager.getPageSize());
   
    // write a number of pairs
    final Record rec = new Record();
    for (int i = 0; i < NUM_PAIRS_INMEM; i++) {
      generator.next(rec);
      rec.write(outView);
    }
   
    // create the reader input view
    DataInputView inView = outView.flip();
    generator.reset();
   
    // read and re-generate all records and compare them
    final Record readRec = new Record();
    try {
      for (int i = 0; i < NUM_PAIRS_INMEM + 1; 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));
      }
      Assert.fail("Read too much, expected EOFException.");
    }
    catch (EOFException eofex) {
      // expected
    }
   
    // re-read the data
    inView = outView.flip();
    generator.reset();
   
    // read and re-generate all records and compare them
    for (int i = 0; i < NUM_PAIRS_INMEM; 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(outView.close());
View Full Code Here

    this.memoryManager.allocatePages(this.parentTask, memory, NUM_MEMORY_SEGMENTS);
    final SpillingBuffer outView = new SpillingBuffer(this.ioManager,
              new ListMemorySegmentSource(memory), this.memoryManager.getPageSize());
   
    // write a number of pairs
    final Record rec = new Record();
    for (int i = 0; i < NUM_PAIRS_EXTERNAL; i++) {
      generator.next(rec);
      rec.write(outView);
    }
   
    // create the reader input view
    DataInputView inView = outView.flip();
    generator.reset();
   
    // read and re-generate all records and compare them
    final Record readRec = new Record();
    for (int i = 0; i < NUM_PAIRS_EXTERNAL; 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));
    }
   
    // re-read the data
    inView = outView.flip();
    generator.reset();
   
    // read and re-generate all records and compare them
    for (int i = 0; i < NUM_PAIRS_EXTERNAL; 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(outView.close());
View Full Code Here

    this.memoryManager.allocatePages(this.parentTask, memory, NUM_MEMORY_SEGMENTS);
    final SpillingBuffer outView = new SpillingBuffer(this.ioManager,
              new ListMemorySegmentSource(memory), this.memoryManager.getPageSize());
   
    // write a number of pairs
    final Record rec = new Record();
    for (int i = 0; i < NUM_PAIRS_EXTERNAL; i++) {
      generator.next(rec);
      rec.write(outView);
    }
   
    // create the reader input view
    DataInputView inView = outView.flip();
    generator.reset();
   
    // read and re-generate all records and compare them
    final Record readRec = new Record();
    try {
      for (int i = 0; i < NUM_PAIRS_EXTERNAL + 1; 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));
      }
      Assert.fail("Read too much, expected EOFException.");
    }
    catch (EOFException eofex) {
      // expected
    }
   
    // re-read the data
    inView = outView.flip();
    generator.reset();
   
    // read and re-generate all records and compare them
    for (int i = 0; i < NUM_PAIRS_EXTERNAL; 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(outView.close());
View Full Code Here

    return false;
  }
 
  @Override
  public Record createInstance() {
    return new Record();
  }
View Full Code Here

    this.memman = new DefaultMemoryManager(MEMORY_CAPACITY);
   
    // create test objects
    this.objects = new ArrayList<Record>(20000);
    for (int i = 0; i < NUM_VALUES; ++i) {
      this.objects.add(new Record(new IntValue(i)));
    }
   
    // create the reader
    this.reader = new MutableObjectIteratorWrapper(this.objects.iterator());
  }
View Full Code Here

      int upper = 0;
      do {
        lower = upper;
        upper = lower;
        // find the upper bound
        Record target = new Record();
        while ((target = iterator.next(target)) != null) {
          int val = target.getField(0, IntValue.class).getValue();
          Assert.assertEquals(upper++, val);
        }
        // now reset the buffer a few times
        for (int i = 0; i < 5; ++i) {
          iterator.reset();
          target = new Record();
          int count = 0;
          while ((target = iterator.next(target)) != null) {
            int val = target.getField(0, IntValue.class).getValue();
            Assert.assertEquals(lower + (count++), val);
          }
          Assert.assertEquals(upper - lower, count);
        }
      } while (iterator.nextBlock());
View Full Code Here

      int upper = 0;
      do {
        lower = upper;
        upper = lower;

        Record target = new Record();
        // find the upper bound
        while ((target = iterator.next(target)) != null) {
          int val = target.getField(0, IntValue.class).getValue();
          Assert.assertEquals(upper++, val);
        }
        // now reset the buffer a few times
        for (int i = 0; i < 5; ++i) {
          iterator.reset();
          target = new Record();
          int count = 0;
          while ((target = iterator.next(target)) != null) {
            int val = target.getField(0, IntValue.class).getValue();
            Assert.assertEquals(lower + (count++), val);
          }
          Assert.assertEquals(upper - lower, count);
        }
      } while (iterator.nextBlock());
View Full Code Here

 
  static Map<TestData.Key, Collection<TestData.Value>> collectRecordData(MutableObjectIterator<Record> iter)
  throws Exception
  {
    Map<TestData.Key, Collection<TestData.Value>> map = new HashMap<TestData.Key, Collection<TestData.Value>>();
    Record pair = new Record();
   
    while ((pair = iter.next(pair)) != null) {

      TestData.Key key = pair.getField(0, TestData.Key.class);
      if (!map.containsKey(key)) {
        map.put(new TestData.Key(key.getKey()), new ArrayList<TestData.Value>());
      }

      Collection<TestData.Value> values = map.get(key);
      values.add(new TestData.Value(pair.getField(1, TestData.Value.class).getValue()));
    }

    return map;
  }
View Full Code Here

      this.recordBuildSideComparator, this.recordProbeSideComparator, this.pactRecordComparator,
      memSegments, ioManager);
    join.open(buildInput, probeInput);
   
   
    final Record recordReuse = new Record();
    int numRecordsInJoinResult = 0;
   
    while (join.nextRecord()) {
      HashBucketIterator<Record, Record> buildSide = join.getBuildSideIterator();
      while (buildSide.next(recordReuse) != null) {
View Full Code Here

TOP

Related Classes of eu.stratosphere.types.Record

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.