Package eu.stratosphere.types

Examples of eu.stratosphere.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


    // use getForClass()
    Assert.assertTrue(TypeExtractor.getForClass(StringValue.class) instanceof ValueTypeInfo);
    Assert.assertEquals(TypeExtractor.getForClass(StringValue.class).getTypeClass(), ti.getTypeClass());

    // use getForObject()
    StringValue v = new StringValue("Hello");
    Assert.assertTrue(TypeExtractor.getForObject(v) instanceof ValueTypeInfo);
    Assert.assertEquals(TypeExtractor.getForObject(v).getTypeClass(), ti.getTypeClass());
  }
View Full Code Here

    Assert.assertTrue(ti.isTupleType());
    Assert.assertEquals(StringValue.class, ((TupleTypeInfo<?>) ti).getTypeAt(0).getTypeClass());
    Assert.assertEquals(IntValue.class, ((TupleTypeInfo<?>) ti).getTypeAt(1).getTypeClass());

    // use getForObject()
    Tuple2<StringValue, IntValue> t = new Tuple2<StringValue, IntValue>(new StringValue("x"), new IntValue(1));
    TypeInformation<?> ti2 = TypeExtractor.getForObject(t);

    Assert.assertFalse(ti2.isBasicType());
    Assert.assertTrue(ti2.isTupleType());
    Assert.assertEquals(((TupleTypeInfo<?>) ti2).getTypeAt(0).getTypeClass(), StringValue.class);
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

      // 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

      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

    @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

public class InstantiationUtilsTest {

  @Test
  public void testInstatiationOfStringValue() {
    StringValue stringValue = InstantiationUtil.instantiate(
        StringValue.class, null);
    assertNotNull(stringValue);
  }
View Full Code Here

    assertNotNull(stringValue);
  }

  @Test
  public void testInstatiationOfStringValueAndCastToValue() {
    StringValue stringValue = InstantiationUtil.instantiate(
        StringValue.class, Value.class);
    assertNotNull(stringValue);
  }
View Full Code Here

TOP

Related Classes of eu.stratosphere.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.