Package org.apache.flink.types

Examples of org.apache.flink.types.IntValue


  }
 
  private static IntValue[][] packIntegers(int[] values) {
    IntValue[][] packed = new IntValue[values.length][];
    for (int i = 0; i < values.length; i++) {
      packed[i] = new IntValue[] { new IntValue(values[i]) };
    }
   
    return packed;
  }
View Full Code Here


    @Override
    public void map(Record record, Collector<Record> out) throws Exception {
      final int d1 = record.getField(2, IntValue.class).getValue();
      final int d2 = record.getField(3, IntValue.class).getValue();
      if (d1 > d2) {
        IntValue first = record.getField(1, IntValue.class);
        IntValue second = record.getField(0, IntValue.class);
        record.setField(0, first);
        record.setField(1, second);
      }
      record.setNumFields(2);
      out.collect(record);
View Full Code Here

      format.setFieldTypesGeneric(StringValue.class, IntValue.class, StringValue.class, IntValue.class);
     
      format.configure(parameters);
      format.open(split);
     
      Value[] values = new Value[] { new StringValue(), new IntValue(), new StringValue(), new IntValue() };
     
      assertNotNull(format.nextRecord(values));
     
      try {
        format.nextRecord(values);
View Full Code Here

      format.setLenient(true);
     
      format.configure(parameters);
      format.open(split);
     
      Value[] values = new Value[] { new StringValue(), new IntValue(), new StringValue(), new IntValue() };
     
      assertNotNull(format.nextRecord(values));
      assertNull(format.nextRecord(values));
    }
    catch (Exception ex) {
View Full Code Here

      format.setLenient(true);
     
      format.configure(parameters);
      format.open(split);
     
      Value[] values = new Value[] { new StringValue(), new IntValue()};
     
      assertNotNull(format.nextRecord(values));
      assertNull(format.nextRecord(values));
      assertNull(format.nextRecord(values));
      assertNotNull(format.nextRecord(values));
View Full Code Here

      format.setSkipFirstLineAsHeader(true);
     
      format.configure(parameters);
      format.open(split);
     
      Value[] values = new Value[] { new IntValue(), new StringValue(), new IntValue(), new StringValue()};
     
      // first line is skipped as header
      assertNotNull(format.nextRecord(values));   //  first row (= second line)
      assertNotNull(format.nextRecord(values));   // second row (= third line)
      assertNull(format.nextRecord(values))// exhausted
View Full Code Here

      format.setSkipFirstLineAsHeader(true);
     
      format.configure(parameters);
      format.open(split);
     
      Value[] values = new Value[] { new IntValue(), new StringValue(), new IntValue(), new StringValue()};
     
      // first line is skipped as header
      assertNotNull(format.nextRecord(values));   //  first row (= second line)
     
      try {
View Full Code Here

 
  private final Value[] createIntValues(int num) {
    Value[] v = new Value[num];
   
    for (int i = 0; i < num; i++) {
      v[i] = new IntValue();
    }
   
    return v;
  }
View Full Code Here

  @Before
  public void setup() {
    final ArrayList<IntStringPair> source = new ArrayList<IntStringPair>();
   
    // add elements to the source
    source.add(new IntStringPair(new IntValue(1), new StringValue("A")));
    source.add(new IntStringPair(new IntValue(2), new StringValue("B")));
    source.add(new IntStringPair(new IntValue(3), new StringValue("C")));
    source.add(new IntStringPair(new IntValue(3), new StringValue("D")));
    source.add(new IntStringPair(new IntValue(4), new StringValue("E")));
    source.add(new IntStringPair(new IntValue(4), new StringValue("F")));
    source.add(new IntStringPair(new IntValue(4), new StringValue("G")));
    source.add(new IntStringPair(new IntValue(5), new StringValue("H")));
    source.add(new IntStringPair(new IntValue(5), new StringValue("I")));
    source.add(new IntStringPair(new IntValue(5), new StringValue("J")));
    source.add(new IntStringPair(new IntValue(5), new StringValue("K")));
    source.add(new IntStringPair(new IntValue(5), new StringValue("L")));
   
   
    this.sourceIter = new MutableObjectIterator<Record>() {
      final Iterator<IntStringPair> it = source.iterator();
     
View Full Code Here

  @Test
  public void testNextKeyOnly() throws Exception {
    try {
      Assert.assertTrue("KeyGroupedIterator must have another key.", this.psi.nextKey());
      Assert.assertTrue("KeyGroupedIterator returned a wrong key.", this.psi.getComparatorWithCurrentReference().equalToReference(new Record(new IntValue(1))));
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 1, this.psi.getCurrent().getField(0, IntValue.class).getValue());
     
      Assert.assertTrue("KeyGroupedIterator must have another key.", this.psi.nextKey());
      Assert.assertTrue("KeyGroupedIterator returned a wrong key.", this.psi.getComparatorWithCurrentReference().equalToReference(new Record(new IntValue(2))));
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 2, this.psi.getCurrent().getField(0, IntValue.class).getValue());
     
      Assert.assertTrue("KeyGroupedIterator must have another key.", this.psi.nextKey());
      Assert.assertTrue("KeyGroupedIterator returned a wrong key.", this.psi.getComparatorWithCurrentReference().equalToReference(new Record(new IntValue(3))));
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 3, this.psi.getCurrent().getField(0, IntValue.class).getValue());
     
      Assert.assertTrue("KeyGroupedIterator must have another key.", this.psi.nextKey());
      Assert.assertTrue("KeyGroupedIterator returned a wrong key.", this.psi.getComparatorWithCurrentReference().equalToReference(new Record(new IntValue(4))));
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 4, this.psi.getCurrent().getField(0, IntValue.class).getValue());
     
      Assert.assertTrue("KeyGroupedIterator must have another key.", this.psi.nextKey());
      Assert.assertTrue("KeyGroupedIterator returned a wrong key.", this.psi.getComparatorWithCurrentReference().equalToReference(new Record(new IntValue(5))));
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 5, this.psi.getCurrent().getField(0, IntValue.class).getValue());
     
      Assert.assertFalse("KeyGroupedIterator must not have another key.", this.psi.nextKey());
      Assert.assertNull("KeyGroupedIterator must not have another value.", this.psi.getValues());
     
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.