Package eu.stratosphere.types

Examples of eu.stratosphere.types.StringValue


      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


      Assert.fail();
    }
   
    // check incorrect key types
    try {
      new SimpleDistribution(new Key[] {new IntValue(1), new StringValue("ABC"), new IntValue(3)});
      Assert.fail("Data distribution accepts inconsistent key types");
    } catch(IllegalArgumentException iae) {
      // do nothing
    }
   
View Full Code Here

  @Test
  public void testConstructorMultiKey() {
   
    // check correct data distribution
    SimpleDistribution dd = new SimpleDistribution(
        new Key[][] {{new IntValue(1), new StringValue("A"), new IntValue(1)},
              {new IntValue(2), new StringValue("A"), new IntValue(1)},
              {new IntValue(3), new StringValue("A"), new IntValue(1)}});
    Assert.assertEquals(3, dd.getNumberOfFields());
   
    // check inconsistent key types
    try {
      new SimpleDistribution(
          new Key[][] {{new IntValue(1), new StringValue("A"), new DoubleValue(1.3d)},
                {new IntValue(2), new StringValue("B"), new IntValue(1)}});
      Assert.fail("Data distribution accepts incorrect key types");
    } catch(IllegalArgumentException iae) {
      // do nothing
    }
   
View Full Code Here

 
  @Test
  public void testWriteRead() {
   
    SimpleDistribution ddWrite = new SimpleDistribution(
        new Key[][] {{new IntValue(1), new StringValue("A"), new IntValue(1)},
              {new IntValue(2), new StringValue("A"), new IntValue(1)},
              {new IntValue(2), new StringValue("B"), new IntValue(4)},
              {new IntValue(2), new StringValue("B"), new IntValue(3)},
              {new IntValue(2), new StringValue("B"), new IntValue(2)}});
    Assert.assertEquals(3, ddWrite.getNumberOfFields());
   
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final DataOutputStream dos = new DataOutputStream(baos);
    try {
View Full Code Here

 
  @Test
  public void testGetBucketBoundary() {
   
    SimpleDistribution dd = new SimpleDistribution(
        new Key[][] {{new IntValue(1), new StringValue("A")},
              {new IntValue(2), new StringValue("B")},
              {new IntValue(3), new StringValue("C")},
              {new IntValue(4), new StringValue("D")},
              {new IntValue(5), new StringValue("E")},
              {new IntValue(6), new StringValue("F")},
              {new IntValue(7), new StringValue("G")}});
   
    Key<?>[] boundRec = dd.getBucketBoundary(0, 8);
    Assert.assertEquals(((IntValue) boundRec[0]).getValue(), 1);
    Assert.assertTrue(((StringValue) boundRec[1]).getValue().equals("A"));
   
View Full Code Here

    }
  }
 
  @Override
  public StringValue createValue() {
    return new StringValue();
  }
View Full Code Here

        r = records.next();
        names += " - " + r.getField(0, SUser.class).datum().getFavoriteColor().toString();
      }
     
      result.setField(0, new IntValue(num));
      result.setField(1new StringValue(names));
      out.collect(result);
    }
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

  }
 
  @Override
  public StringValue[] getValidTestResults() {
    return new StringValue[] {
      new StringValue("abcdefgh"), new StringValue("i"), new StringValue("jklmno"),
      new StringValue("abcdefgh"), new StringValue("i"), new StringValue("jklmno"),
      new StringValue("ab,cde|fg"), new StringValue("hij|m|n|op"),
      new StringValue("abcdefgh"), new StringValue("i"), new StringValue("jklmno"),
      new StringValue("     abcd    ")
    };
  }
View Full Code Here

  @Test
  public void testParseValidUnquotedStrings() {
   
    // check valid strings with out whitespaces and trailing delimiter
    byte[] recBytes = "abcdefgh|i|jklmno|".getBytes();
    StringValue s = new StringValue();
   
    int startPos = 0;
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 9);
    assertTrue(s.getValue().equals("abcdefgh"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 11);
    assertTrue(s.getValue().equals("i"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 18);
    assertTrue(s.getValue().equals("jklmno"));
   
   
    // check single field not terminated
    recBytes = "abcde".getBytes();
    startPos = 0;
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 5);
    assertTrue(s.getValue().equals("abcde"));
   
    // check last field not terminated
    recBytes = "abcde|fg".getBytes();
    startPos = 0;
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 6);
    assertTrue(s.getValue().equals("abcde"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 8);
    assertTrue(s.getValue().equals("fg"));
  }
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.