Package eu.stratosphere.types

Examples of eu.stratosphere.types.Record


    private final IntValue value = new IntValue();

    @Override
    public void reduce(Iterator<Record> records, Collector<Record> out)
        throws Exception {
      Record element = null;
      int cnt = 0;
      while (records.hasNext()) {
        element = records.next();
        cnt++;
      }
      element.getField(0, this.key);
      this.value.setValue(cnt - this.key.getValue());
      element.setField(1, this.value);
      out.collect(element);
    }
View Full Code Here


    private final IntValue combineValue = new IntValue();

    @Override
    public void reduce(Iterator<Record> records, Collector<Record> out)
        throws Exception {
      Record element = null;
      int sum = 0;
      while (records.hasNext()) {
        element = records.next();
        element.getField(1, this.value);
       
        sum += this.value.getValue();
      }
      element.getField(0, this.key);
      this.value.setValue(sum - this.key.getValue());
      element.setField(1, this.value);
      out.collect(element);
    }
View Full Code Here

    }
   
    @Override
    public void combine(Iterator<Record> records, Collector<Record> out)
        throws Exception {
      Record element = null;
      int sum = 0;
      while (records.hasNext()) {
        element = records.next();
        element.getField(1, this.combineValue);
       
        sum += this.combineValue.getValue();
      }
     
      this.combineValue.setValue(sum);
      element.setField(1, this.combineValue);
      out.collect(element);
    }
View Full Code Here

    private final IntValue value = new IntValue();

    @Override
    public void reduce(Iterator<Record> records, Collector<Record> out)
        throws Exception {
      Record element = null;
      int valCnt = 0;
      while (records.hasNext()) {
        element = records.next();
        valCnt++;
      }
     
      if (++this.cnt >= 10) {
        throw new ExpectedTestException();
      }
     
      element.getField(0, this.key);
      this.value.setValue(valCnt - this.key.getValue());
      element.setField(1, this.value);
      out.collect(element);
    }
View Full Code Here

    int numRecs = 50000;
    int[] hit = new int[numChans];

    for (int i = 0; i < numRecs; i++) {
      IntValue k = new IntValue(i);
      Record rec = new Record(k);
     
      int[] chans = oe1.selectChannels(rec, hit.length);
      for(int j=0; j < chans.length; j++) {
        hit[chans[j]]++;
      }
    }

    int cnt = 0;
    for (int i = 0; i < hit.length; i++) {
      assertTrue(hit[i] > 0);
      cnt += hit[i];
    }
    assertTrue(cnt == numRecs);

    // Test for StringValue
    @SuppressWarnings("unchecked")
    final RecordComparator stringComp = new RecordComparator(new int[] {0}, new Class[] {StringValue.class});
    ChannelSelector<Record> oe2 = new RecordOutputEmitter(ShipStrategyType.PARTITION_HASH, stringComp);

    numChans = 100;
    numRecs = 10000;
   
    hit = new int[numChans];

    for (int i = 0; i < numRecs; i++) {
      StringValue k = new StringValue(i + "");
      Record rec = new Record(k);
       
      int[] chans = oe2.selectChannels(rec, hit.length);
      for(int j=0; j < chans.length; j++) {
        hit[chans[j]]++;
      }
View Full Code Here

   
    int[] hit = new int[numChannels];

    for (int i = 0; i < numRecords; i++) {
      IntValue k = new IntValue(i);
      Record rec = new Record(k);
     
      int[] chans = oe1.selectChannels(rec, hit.length);
      for(int j=0; j < chans.length; j++) {
        hit[chans[j]]++;
      }
    }

    int cnt = 0;
    for (int i = 0; i < hit.length; i++) {
      assertTrue(hit[i] == (numRecords/numChannels) || hit[i] == (numRecords/numChannels)-1);
      cnt += hit[i];
    }
    assertTrue(cnt == numRecords);

    // Test for StringValue
    @SuppressWarnings("unchecked")
    final RecordComparator stringComp = new RecordComparator(new int[] {0}, new Class[] {StringValue.class});
    final ChannelSelector<Record> oe2 = new RecordOutputEmitter(ShipStrategyType.FORWARD, stringComp);

    numChannels = 100;
    numRecords = 10000;
   
    hit = new int[numChannels];

    for (int i = 0; i < numRecords; i++) {
      StringValue k = new StringValue(i + "");
      Record rec = new Record(k);
       
      int[] chans = oe2.selectChannels(rec, hit.length);
      for(int j=0; j < chans.length; j++) {
        hit[chans[j]]++;
      }
View Full Code Here

   
    int[] hit = new int[numChannels];

    for (int i = 0; i < numRecords; i++) {
      IntValue k = new IntValue(i);
      Record rec = new Record(k);
     
      int[] chans = oe1.selectChannels(rec, hit.length);
      for(int j=0; j < chans.length; j++) {
        hit[chans[j]]++;
      }
    }

    for (int i = 0; i < hit.length; i++) {
      assertTrue(hit[i]+"", hit[i] == numRecords);
    }
   
    // Test for StringValue
    @SuppressWarnings("unchecked")
    final RecordComparator stringComp = new RecordComparator(new int[] {0}, new Class[] {StringValue.class});
    final ChannelSelector<Record> oe2 = new RecordOutputEmitter(ShipStrategyType.BROADCAST, stringComp);

    numChannels = 100;
    numRecords = 5000;
   
    hit = new int[numChannels];

    for (int i = 0; i < numRecords; i++) {
      StringValue k = new StringValue(i + "");
      Record rec = new Record(k);
       
      int[] chans = oe2.selectChannels(rec, hit.length);
      for(int j=0; j < chans.length; j++) {
        hit[chans[j]]++;
      }
View Full Code Here

    int numRecords = 5000;
   
    int[] hit = new int[numChannels];

    for (int i = 0; i < numRecords; i++) {
      Record rec = new Record(4);
      rec.setField(0, new IntValue(i));
      rec.setField(1, new StringValue("AB"+i+"CD"+i));
      rec.setField(3, new DoubleValue(i*3.141d));
     
      int[] chans = oe1.selectChannels(rec, hit.length);
      for(int j=0; j < chans.length; j++) {
        hit[chans[j]]++;
      }
View Full Code Here

    // Test for IntValue
    @SuppressWarnings("unchecked")
    final RecordComparator intComp = new RecordComparator(new int[] {1}, new Class[] {IntValue.class});
    final ChannelSelector<Record> oe1 = new RecordOutputEmitter(ShipStrategyType.PARTITION_HASH, intComp);

    Record rec = new Record(0);
    rec.setField(0, new IntValue(1));
   
    try {
      oe1.selectChannels(rec, 100);
    } catch (KeyFieldOutOfBoundsException re) {
      Assert.assertEquals(1, re.getFieldNumber());
View Full Code Here

    // Test for IntValue
    @SuppressWarnings("unchecked")
    final RecordComparator intComp = new RecordComparator(new int[] {0}, new Class[] {IntValue.class});
    final ChannelSelector<Record> oe1 = new RecordOutputEmitter(ShipStrategyType.PARTITION_HASH, intComp);

    Record rec = new Record(2);
    rec.setField(1, new IntValue(1));

    try {
      oe1.selectChannels(rec, 100);
    } catch (NullKeyFieldException re) {
      Assert.assertEquals(0, re.getFieldNumber());
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.