Package org.apache.flink.types

Examples of org.apache.flink.types.StringValue


   */
  @Override
  public void join(Record value1, Record value2, Collector<Record> out) throws Exception
  {
    StringIntPair amountYearPair = value1.getField(1, this.amountYearPair);
    StringValue nationName = value2.getField(1, this.nationName);
   
    IntValue year = amountYearPair.getSecond();
    StringValue amount = amountYearPair.getFirst();
    StringIntPair key = new StringIntPair(nationName, year);
    value1.setField(0, key);
    value1.setField(1, amount);
    out.collect(value1);
  }
View Full Code Here


    // mutable output record
    private final Record result = new Record();
   
    // initialize list of non-matching vertices for one vertex
    public BuildTriads() {
      this.otherVertices.add(new StringValue());
    }
View Full Code Here

      while (records.hasNext()) {

        // read the next edge
        final Record next = records.next();
       
        final StringValue myVertex;
        // obtain an object to store the non-matching vertex
        if (numEdges >= this.otherVertices.size()) {
          // we need an additional vertex object
          // create the object
          myVertex = new StringValue();
          // and put it in the list
          this.otherVertices.add(myVertex);
        } else {
          // we reuse a previously created object from the list
          myVertex = this.otherVertices.get(numEdges);
        }
        // read the non-matching vertex into the obtained object
        next.getFieldInto(1, myVertex);
       
        // combine the current edge with all vertices in the non-matching vertex list
        for (int i = 0; i < numEdges; i++) {
          // get the other non-matching vertex
          final StringValue otherVertex = this.otherVertices.get(i);
          // add my and other vertex to the output record depending on their ordering
          if (otherVertex.compareTo(myVertex) < 0) {
            this.result.setField(1, otherVertex);
            this.result.setField(2, myVertex);
            out.collect(this.result);
          } else {
            next.setField(2, otherVertex);
View Full Code Here

      String line = record.getField(0, StringValue.class).getValue();
      String [] element = line.split(" ");
      String word = element[0];
      int count = Integer.parseInt(element[1]);
      if (stringList.contains(word)) {
        collector.collect(new Record(new StringValue(word), new IntValue(count)));
      }
    }
View Full Code Here

      // rec1 has matching start, rec2 matching end
      // Therefore, rec2's end node and rec1's start node are identical
      // First half of new path will be rec2, second half will be rec1
     
      // Get from-node and to-node of new path 
      final StringValue fromNode = rec2.getField(0, StringValue.class);
      final StringValue toNode = rec1.getField(1, StringValue.class);
     
      // Check whether from-node = to-node to prevent circles!
      if (fromNode.equals(toNode)) {
        return;
      }
View Full Code Here

    @Override
    public void coGroup(Iterator<Record> inputRecords, Iterator<Record> concatRecords, Collector<Record> out) {

      // init minimum length and minimum path
      Record pathRec = null;
      StringValue path = null;
      if(inputRecords.hasNext()) {
        // path is in input paths
        pathRec = inputRecords.next();
      } else {
        // path must be in concat paths
        pathRec = concatRecords.next();
      }
      // get from node (common for all paths)
      StringValue fromNode = pathRec.getField(0, StringValue.class);
      // get to node (common for all paths)
      StringValue toNode = pathRec.getField(1, StringValue.class);
      // get length of path
      minLength.setValue(pathRec.getField(2, IntValue.class).getValue());
      // store path and hop count
      path = new StringValue(pathRec.getField(4, StringValue.class));
      shortestPaths.add(path);
      hopCnts.put(path, new IntValue(pathRec.getField(3, IntValue.class).getValue()));
           
      // find shortest path of all input paths
      while (inputRecords.hasNext()) {
        pathRec = inputRecords.next();
        IntValue length = pathRec.getField(2, IntValue.class);
       
        if (length.getValue() == minLength.getValue()) {
          // path has also minimum length add to list
          path = new StringValue(pathRec.getField(4, StringValue.class));
          if(shortestPaths.add(path)) {
            hopCnts.put(path, new IntValue(pathRec.getField(3, IntValue.class).getValue()));
          }
        } else if (length.getValue() < minLength.getValue()) {
          // path has minimum length
          minLength.setValue(length.getValue());
          // clear lists
          hopCnts.clear();
          shortestPaths.clear();
          // get path and add path and hop count
          path = new StringValue(pathRec.getField(4, StringValue.class));
          shortestPaths.add(path);
          hopCnts.put(path, new IntValue(pathRec.getField(3, IntValue.class).getValue()));
        }
      }

      // find shortest path of all input and concatenated paths
      while (concatRecords.hasNext()) {
        pathRec = concatRecords.next();
        IntValue length = pathRec.getField(2, IntValue.class);
       
        if (length.getValue() == minLength.getValue()) {
          // path has also minimum length add to list
          path = new StringValue(pathRec.getField(4, StringValue.class));
          if(shortestPaths.add(path)) {
            hopCnts.put(path, new IntValue(pathRec.getField(3, IntValue.class).getValue()));
          }
        } else if (length.getValue() < minLength.getValue()) {
          // path has minimum length
          minLength.setValue(length.getValue());
          // clear lists
          hopCnts.clear();
          shortestPaths.clear();
          // get path and add path and hop count
          path = new StringValue(pathRec.getField(4, StringValue.class));
          shortestPaths.add(path);
          hopCnts.put(path, new IntValue(pathRec.getField(3, IntValue.class).getValue()));
        }
      }
     
View Full Code Here

    rec.setField(0, inputKey);
    rec.setField(1, input);
   
    Collector<Record> collector = new RecordOutputCollector(writerList);
   
    StringValue returnFlag = new StringValue(RETURN_FLAG);
   
    out.map(rec, collector);
   
    ArgumentCaptor<Record> argument = ArgumentCaptor.forClass(Record.class);
    verify(recordWriterMock).emit(argument.capture());
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

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.