Package org.apache.flink.types

Examples of org.apache.flink.types.StringValue


      int sum = 0;
      while (it.hasNext()) {
        sum += Integer.parseInt(it.next().getField(0, StringValue.class).getValue()) + 1;
      }
     
      out.collect(new Record(new StringValue(Integer.toString(sum))));
    }
View Full Code Here


      int numWords = 0;
     
      while (tokenizer.hasMoreTokens()) {
        String word = tokenizer.nextToken();
       
        distinctWords.add(new StringValue(word));
        ++numWords;
       
        // we emit a (word, 1) pair
        collector.collect(new Record(new StringValue(word), new IntValue(1)));
      }
     
      // Add a value to the histogram accumulator
      this.wordsPerLine.add(numWords);
    }
View Full Code Here

    dist.put(1, 1); dist.put(2, 1); dist.put(3, 1);
    Assert.assertEquals(dist, res.getAccumulatorResult("words-per-line"));
   
    // Test distinct words (custom accumulator)
    Set<StringValue> distinctWords = Sets.newHashSet();
    distinctWords.add(new StringValue("one"));
    distinctWords.add(new StringValue("two"));
    distinctWords.add(new StringValue("three"));
    Assert.assertEquals(distinctWords, res.getAccumulatorResult("distinct-words"));
  }
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

    public void flatMap(String value, Collector<Tuple2<String, Integer>> out) {
      this.cntNumLines.add(1);
      int wordsPerLine = 0;
     
      for (String token : value.toLowerCase().split("\\W+")) {
        distinctWords.add(new StringValue(token));
        out.collect(new Tuple2<String, Integer>(token, 1));
        ++ wordsPerLine;
      }
      wordsPerLineDistribution.add(wordsPerLine);
    }
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);
      delegate.setInstance(rec);
       
      int[] chans = oe2.selectChannels(delegate, hit.length);
      for(int j=0; j < chans.length; 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);
      delegate.setInstance(rec);
       
      int[] chans = oe2.selectChannels(delegate, hit.length);
      for(int j=0; j < chans.length; 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);
      delegate.setInstance(rec);
       
      int[] chans = oe2.selectChannels(delegate, hit.length);
      for(int j=0; j < chans.length; 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));
      delegate.setInstance(rec);
     
      int[] chans = oe1.selectChannels(delegate, hit.length);
      for(int j=0; j < chans.length; j++) {
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 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.