Package eu.stratosphere.types

Examples of eu.stratosphere.types.StringValue


  @Test
  public void testParseValidQuotedStringsWithoutWhitespaces() {
   
    // 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 == 11);
    assertTrue(s.getValue().equals("abcdefgh"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 15);
    assertTrue(s.getValue().equals("i"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 24);
    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 == 7);
    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 == 8);
    assertTrue(s.getValue().equals("abcde"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 12);
    assertTrue(s.getValue().equals("fg"));
   
    // check delimiter in quotes
    recBytes = "\"abcde|fg\"|\"hij|kl|mn|op\"|".getBytes();
    startPos = 0;
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 11);
    assertTrue(s.getValue().equals("abcde|fg"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 26);
    assertTrue(s.getValue().equals("hij|kl|mn|op"));
   
    // check delimiter in quotes last field not terminated
    recBytes = "\"abcde|fg\"|\"hij|kl|mn|op\"".getBytes();
    startPos = 0;
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 11);
    assertTrue(s.getValue().equals("abcde|fg"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 25);
    assertTrue(s.getValue().equals("hij|kl|mn|op"));
  }
View Full Code Here


  @Test
  public void testParseValidQuotedStringsWithWhitespaces() {
   
    // check valid strings with out whitespaces and trailing delimiter
    byte[] recBytes = "  \"abcdefgh\"|     \"i\"\t\t\t|\t \t\"jklmno\"  |".getBytes();
    StringValue s = new StringValue();
   
    int startPos = 0;
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 13);
    assertTrue(s.getValue().equals("abcdefgh"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 25);
    assertTrue(s.getValue().equals("i"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 39);
    assertTrue(s.getValue().equals("jklmno"));
   
    // check valid strings with out whitespaces without trailing delimiter
    recBytes = "  \"abcdefgh\"|     \"i\"\t\t\t|\t \t\"jklmno\"  ".getBytes();
    s = new StringValue();
   
    startPos = 0;
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 13);
    assertTrue(s.getValue().equals("abcdefgh"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 25);
    assertTrue(s.getValue().equals("i"));
   
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 38);
    assertTrue(s.getValue().equals("jklmno"));
   
    // check single field not terminated
    recBytes = "  \t\"abcde\"\t\t  \t ".getBytes();
    startPos = 0;
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 16);
    assertTrue(s.getValue().equals("abcde"));
   
    // check single field terminated
    recBytes = "  \t\"abcde\"\t\t  \t |".getBytes();
    startPos = 0;
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos == 17);
    assertTrue(s.getValue().equals("abcde"));
  }
View Full Code Here

  @Test
  public void testParseInvalidQuotedStrings() {
   
    // check valid strings with out whitespaces and trailing delimiter
    byte[] recBytes = "  \"abcdefgh\" gh |     \"i\"\t\t\t|\t \t\"jklmno\"  |".getBytes();
    StringValue s = new StringValue();
   
    int startPos = 0;
    startPos = parser.parseField(recBytes, startPos, recBytes.length, '|', s);
    assertTrue(startPos < 0);
  }
View Full Code Here

    return false;
  }
 
  @Override
  public StringValue createInstance() {
    return new 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.