Package org.apache.flink.types

Examples of org.apache.flink.types.StringValue


      // Progression first though haNext() and next(), then through hasNext() - Key 3, Values C, D
      Assert.assertTrue("KeyGroupedIterator must have another key.", this.psi.nextKey());
      Assert.assertTrue("KeyGroupedIterator must have another value.", this.psi.getValues().hasNext());
      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.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("C"), this.psi.getValues().next().getField(1, StringValue.class));
      Assert.assertTrue("KeyGroupedIterator must have another value.", this.psi.getValues().hasNext());
      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());
     
      // Progression first via next() only, then hasNext() only Key 4, Values E, F, G
      Assert.assertTrue("KeyGroupedIterator must have another key.", this.psi.nextKey());
      Assert.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("E"), this.psi.getValues().next().getField(1, StringValue.class));
      Assert.assertTrue("KeyGroupedIterator must have another value.", this.psi.getValues().hasNext());
     
      // Key 5, Values H, I, J, K, L
      Assert.assertTrue("KeyGroupedIterator must have another key.", this.psi.nextKey());
      Assert.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("H"), this.psi.getValues().next().getField(1, StringValue.class));
      Assert.assertTrue("KeyGroupedIterator must have another value.", this.psi.getValues().hasNext());
      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.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("I"), this.psi.getValues().next().getField(1, StringValue.class));
      Assert.assertTrue("KeyGroupedIterator must have another value.", this.psi.getValues().hasNext());
     
      // end
      Assert.assertFalse("KeyGroupedIterator must not have another key.", this.psi.nextKey());
      Assert.assertFalse("KeyGroupedIterator must not have another key.", this.psi.nextKey());
View Full Code Here


      valsIter = this.psi.getValues();
      Assert.assertNotNull("Returned Iterator must not be null", valsIter);
      Assert.assertTrue("KeyGroupedIterator's value iterator must have another value.", valsIter.hasNext());
      rec = valsIter.next();
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 1, rec.getField(0, IntValue.class).getValue());
      Assert.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("A"), rec.getField(1, StringValue.class));
      Assert.assertFalse("KeyGroupedIterator must have another value.", valsIter.hasNext());
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 1, rec.getField(0, IntValue.class).getValue());
      Assert.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("A"), rec.getField(1, StringValue.class));     
      Assert.assertFalse("KeyGroupedIterator's value iterator must not have another value.", valsIter.hasNext());
     
      Assert.assertTrue("KeyGroupedIterator must have another key.", this.psi.nextKey());
      valsIter = this.psi.getValues();
      Assert.assertNotNull("Returned Iterator must not be null", valsIter);
      Assert.assertTrue("KeyGroupedIterator's value iterator must have another value.", valsIter.hasNext());
      rec = valsIter.next();
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 2, rec.getField(0, IntValue.class).getValue());
      Assert.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("B"), rec.getField(1, StringValue.class));
      Assert.assertFalse("KeyGroupedIterator must have another value.", valsIter.hasNext());
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 2, rec.getField(0, IntValue.class).getValue());
      Assert.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("B"), rec.getField(1, StringValue.class));
      Assert.assertFalse("KeyGroupedIterator's value iterator must not have another value.", valsIter.hasNext());
     
      Assert.assertTrue("KeyGroupedIterator must have another key.", this.psi.nextKey());
      valsIter = this.psi.getValues();
      Assert.assertNotNull("Returned Iterator must not be null", valsIter);
      Assert.assertTrue("KeyGroupedIterator's value iterator must have another value.", valsIter.hasNext());
      rec = valsIter.next();
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 3, rec.getField(0, IntValue.class).getValue());
      Assert.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("C"), rec.getField(1, StringValue.class));
      Assert.assertTrue("KeyGroupedIterator's value iterator must have another value.", valsIter.hasNext());
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 3, rec.getField(0, IntValue.class).getValue());
      Assert.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("C"), rec.getField(1, StringValue.class));
      rec = valsIter.next();
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 3, rec.getField(0, IntValue.class).getValue());
      Assert.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("D"), rec.getField(1, StringValue.class));
      Assert.assertFalse("KeyGroupedIterator's value iterator must have another value.", valsIter.hasNext());
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 3, rec.getField(0, IntValue.class).getValue());
      Assert.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("D"), rec.getField(1, StringValue.class));
      Assert.assertFalse("KeyGroupedIterator's value iterator must have another value.", valsIter.hasNext());
      Assert.assertEquals("KeyGroupedIterator returned a wrong key.", 3, rec.getField(0, IntValue.class).getValue());
      Assert.assertEquals("KeyGroupedIterator returned a wrong value.", new StringValue("D"), rec.getField(1, StringValue.class));
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail("The test encountered an unexpected exception.");
    }
  }
View Full Code Here

  /**
   * Returns the record to write at the given position
   */
  protected Record getRecord(int index) {
    return new Record(new IntValue(index), new StringValue(String.valueOf(index)));
  }
View Full Code Here

    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

    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

    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[] 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

 
  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

      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

  protected Value convert(Object hadoopType) {
    if(hadoopType instanceof org.apache.hadoop.io.LongWritable ) {
      return new LongValue(((LongWritable)hadoopType).get());
    }
    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) {
View Full Code Here

TOP

Related Classes of org.apache.flink.types.StringValue

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.