Package eu.stratosphere.types

Examples of eu.stratosphere.types.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


   
    try {
      out = new DataOutputStream(new PipedOutputStream(pipedInput));
     
      rec = new Record(1);
      rec.setField(0, new IntValue());
     
      rec.write(out);
      rec = new Record();
      rec.read(in);
   
View Full Code Here

   
    @SuppressWarnings("unchecked")
    final RecordComparator intComp = new RecordComparator(new int[] {0}, new Class[] {IntValue.class});
    final ChannelSelector<Record> oe = new RecordOutputEmitter(ShipStrategyType.PARTITION_RANGE, intComp, distri);
   
    final IntValue integer = new IntValue();
    final Record rec = new Record();
   
    for (int i = 0; i < NUM_ELEMENTS; i++) {
      final int nextValue = rnd.nextInt(DISTR_RANGE) + DISTR_MIN;
      integer.setValue(nextValue);
      rec.setField(0, integer);
     
      final int[] channels = oe.selectChannels(rec, NUM_BUCKETS);
      if (channels.length != 1) {
        Assert.fail("Resulting channels array has more than one channel.");
View Full Code Here

    // create test objects
    final ArrayList<Record> objects = new ArrayList<Record>(NUM_TESTRECORDS);

    for (int i = 0; i < NUM_TESTRECORDS; ++i) {
      Record tmp = new Record(new IntValue(i));
      objects.add(tmp);
    }
    this.reader = new MutableObjectIteratorWrapper(objects.iterator());
  }
View Full Code Here

    // create test objects
    ArrayList<IntValue> objects = new ArrayList<IntValue>(NUM_TESTRECORDS);

    for (int i = 0; i < NUM_TESTRECORDS; ++i) {
      IntValue tmp = new IntValue(i);
      objects.add(tmp);
    }
    this.reader = objects.iterator();
  }
View Full Code Here

      SpillingResettableIterator<IntValue> iterator = new SpillingResettableIterator<IntValue>(
          this.reader, this.serializer, this.memman, this.ioman, 2, this.memOwner);
      // open the iterator
      iterator.open();
 
      IntValue record;
      int cnt = 0;
      while (cnt < NUM_TESTRECORDS) {
        record = iterator.next();
        Assert.assertTrue("Record was not read from iterator", record != null);
        cnt++;
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 = objects.iterator();
  }
View Full Code Here

    }
   
    @Override
    public int serializeRecord(Record rec, byte[] target) throws Exception
    {
      IntValue key = rec.getField(0, IntValue.class);
      IntValue value = rec.getField(1, IntValue.class);
   
      this.bld.setLength(0);
      this.bld.append(key.getValue());
      this.bld.append('_');
      this.bld.append(value.getValue());
     
      byte[] bytes = this.bld.toString().getBytes();
      if (bytes.length <= target.length) {
        System.arraycopy(bytes, 0, target, 0, bytes.length);
        return bytes.length;
View Full Code Here

   
    // wee need to do the final aggregation manually in the test, because the
    // combiner is not guaranteed to do that
    final HashMap<IntValue, IntValue> aggMap = new HashMap<IntValue, IntValue>();
    for (Record record : this.outList) {
      IntValue key = new IntValue();
      IntValue value = new IntValue();
      key = record.getField(0, key);
      value = record.getField(1, value);
      IntValue prevVal = aggMap.get(key);
      if (prevVal != null) {
        aggMap.put(key, new IntValue(prevVal.getValue() + value.getValue()));
      }
      else {
        aggMap.put(key, value);
      }
    }
View Full Code Here

  }
 
  public static List<Tuple2<StringValue, IntValue>> createReduceMutableData() {
    List<Tuple2<StringValue, IntValue>> data = new ArrayList<Tuple2<StringValue, IntValue>>();
   
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("a"), new IntValue(1)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("b"), new IntValue(2)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("c"), new IntValue(3)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("d"), new IntValue(4)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("d"), new IntValue(5)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("e"), new IntValue(6)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("e"), new IntValue(7)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("e"), new IntValue(8)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("f"), new IntValue(9)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("f"), new IntValue(10)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("f"), new IntValue(11)));
    data.add(new Tuple2<StringValue, IntValue>(new StringValue("f"), new IntValue(12)));
   
    return data;
  }
View Full Code Here

TOP

Related Classes of eu.stratosphere.types.IntValue

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.