Package org.apache.flink.types

Examples of org.apache.flink.types.IntValue


   
    @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


 
  public static final class ConcatSumMutableReducer extends RichGroupReduceFunction<Tuple2<StringValue, IntValue>, Tuple2<StringValue, IntValue>> {

    @Override
    public void reduce(Iterable<Tuple2<StringValue, IntValue>> values, Collector<Tuple2<StringValue, IntValue>> out) {
      Tuple2<StringValue, IntValue> current = new Tuple2<StringValue, IntValue>(new StringValue(""), new IntValue(0));
     
      for (Tuple2<StringValue, IntValue> next : values) {
        next.f0.append(current.f0);
        next.f1.setValue(current.f1.getValue() + next.f1.getValue());
        current = next;
View Full Code Here

   
    private int numLeft;
   
    public ConstantsKeyValuePairsIterator(int key, int value, int count)
    {
      this.key = new IntValue(key);
      this.value = new IntValue(value);
      this.numLeft = count;
    }
View Full Code Here

      Assert.assertEquals("Field 2 should be String", StringValue.class, record.getField(2, StringValue.class).getClass());
      Assert.assertEquals("Field 3 should be float", DoubleValue.class, record.getField(3, DoubleValue.class).getClass());
      Assert.assertEquals("Field 4 should be int", IntValue.class, record.getField(4, IntValue.class).getClass());

      int[] pos = {0, 1, 2, 3, 4};
      Value[] values = {new IntValue(), new StringValue(), new StringValue(), new DoubleValue(), new IntValue()};
      Assert.assertTrue(record.equalsFields(pos, dbData[recordCount], values));

      recordCount++;
    }
    Assert.assertEquals(5, recordCount);
View Full Code Here

    }
    if(hadoopType instanceof org.apache.hadoop.io.Text) {
      return new StringValue(((Text)hadoopType).toString());
    }
    if(hadoopType instanceof org.apache.hadoop.io.IntWritable) {
      return new IntValue(((IntWritable)hadoopType).get());
    }
    if(hadoopType instanceof org.apache.hadoop.io.FloatWritable) {
      return new FloatValue(((FloatWritable)hadoopType).get());
    }
    if(hadoopType instanceof org.apache.hadoop.io.DoubleWritable) {
View Full Code Here

      Assert.assertEquals("Field 2 should be String", StringValue.class, record.getField(2, StringValue.class).getClass());
      Assert.assertEquals("Field 3 should be float", DoubleValue.class, record.getField(3, DoubleValue.class).getClass());
      Assert.assertEquals("Field 4 should be int", IntValue.class, record.getField(4, IntValue.class).getClass());

      int[] pos = {0, 1, 2, 3, 4};
      Value[] values = {new IntValue(), new StringValue(), new StringValue(), new DoubleValue(), new IntValue()};
      Assert.assertTrue(record.equalsFields(pos, dbData[recordCount], values));

      recordCount++;
    }
    Assert.assertEquals(5, recordCount);
View Full Code Here

      StringTokenizer tokenizer = new StringTokenizer(line);
      while (tokenizer.hasMoreTokens()) {
        String word = tokenizer.nextToken();
       
        // we emit a (word, 1) pair
        collector.collect(new Record(new StringValue(word), new IntValue(1)));
      }
    }
View Full Code Here

        element = records.next();
        int cnt = element.getField(1, IntValue.class).getValue();
        sum += cnt;
      }

      element.setField(1, new IntValue(sum));
      out.collect(element);
    }
View Full Code Here

      break;
    case java.sql.Types.BIGINT:
      record.setField(pos, new LongValue(resultSet.getLong(pos + 1)));
      break;
    case java.sql.Types.INTEGER:
      record.setField(pos, new IntValue(resultSet.getInt(pos + 1)));
      break;
    case java.sql.Types.FLOAT:
      record.setField(pos, new DoubleValue(resultSet.getDouble(pos + 1)));
      break;
    case java.sql.Types.REAL:
View Full Code Here

      while (records.hasNext()) {
        record = records.next();
        reduceValue = record.getField(1, reduceValue);
        sum += Integer.parseInt(reduceValue.toString());
      }
      record.setField(1, new IntValue(sum));
      out.collect(record);
    }
View Full Code Here

TOP

Related Classes of org.apache.flink.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.