use of org.apache.flink.types.StringValue in project flink by apache.
the class StringValueUtilsTest method testToLowerCaseConverting.
@Test
public void testToLowerCaseConverting() {
StringValue testString = new StringValue("TEST");
StringValueUtils.toLowerCase(testString);
assertEquals(new StringValue("test"), testString);
}
use of org.apache.flink.types.StringValue in project flink by apache.
the class StringValueUtilsTest method testTokenizerOnStringOnlyWithDelimiter.
@Test
public void testTokenizerOnStringOnlyWithDelimiter() {
StringValue testString = new StringValue(" ");
StringValueUtils.WhitespaceTokenizer tokenizer = new WhitespaceTokenizer();
tokenizer.setStringToTokenize(testString);
assertFalse(tokenizer.next(testString));
}
use of org.apache.flink.types.StringValue in project flink by apache.
the class VarLengthStringParserTest method testParseValidMixedStringsWithCharset.
@Test
public void testParseValidMixedStringsWithCharset() {
Charset charset = StandardCharsets.US_ASCII;
this.parser = new StringValueParser();
this.parser.enableQuotedStringParsing((byte) '@');
// check valid strings with out whitespaces and trailing delimiter
byte[] recBytes = "@abcde|gh@|@i@|jklmnopq|@rs@|tuv".getBytes(ConfigConstants.DEFAULT_CHARSET);
StringValue s = new StringValue();
int startPos = 0;
parser.setCharset(charset);
startPos = parser.parseField(recBytes, startPos, recBytes.length, new byte[] { '|' }, s);
assertEquals(11, startPos);
assertEquals("abcde|gh", s.getValue());
}
use of org.apache.flink.types.StringValue in project flink by apache.
the class VarLengthStringParserTest method testParseValidUnquotedStrings.
@Test
public void testParseValidUnquotedStrings() {
this.parser = new StringValueParser();
// check valid strings with out whitespaces and trailing delimiter
byte[] recBytes = "abcdefgh|i|jklmno|".getBytes(ConfigConstants.DEFAULT_CHARSET);
StringValue s = new StringValue();
int startPos = 0;
startPos = parser.parseField(recBytes, startPos, recBytes.length, new byte[] { '|' }, s);
assertTrue(startPos == 9);
assertTrue(s.getValue().equals("abcdefgh"));
startPos = parser.parseField(recBytes, startPos, recBytes.length, new byte[] { '|' }, s);
assertTrue(startPos == 11);
assertTrue(s.getValue().equals("i"));
startPos = parser.parseField(recBytes, startPos, recBytes.length, new byte[] { '|' }, s);
assertTrue(startPos == 18);
assertTrue(s.getValue().equals("jklmno"));
// check single field not terminated
recBytes = "abcde".getBytes(ConfigConstants.DEFAULT_CHARSET);
startPos = 0;
startPos = parser.parseField(recBytes, startPos, recBytes.length, new byte[] { '|' }, s);
assertTrue(startPos == 5);
assertTrue(s.getValue().equals("abcde"));
// check last field not terminated
recBytes = "abcde|fg".getBytes(ConfigConstants.DEFAULT_CHARSET);
startPos = 0;
startPos = parser.parseField(recBytes, startPos, recBytes.length, new byte[] { '|' }, s);
assertTrue(startPos == 6);
assertTrue(s.getValue().equals("abcde"));
startPos = parser.parseField(recBytes, startPos, recBytes.length, new byte[] { '|' }, s);
assertTrue(startPos == 8);
assertTrue(s.getValue().equals("fg"));
}
use of org.apache.flink.types.StringValue in project flink by apache.
the class StringValueArraySerializerTest method getTestData.
@Override
protected StringValueArray[] getTestData() {
int defaultElements = StringValueArray.DEFAULT_CAPACITY_IN_BYTES;
Random rnd = new Random(874597969123412341L);
long rndLong = rnd.nextLong();
StringValueArray sva0 = new StringValueArray();
StringValueArray sva1 = new StringValueArray();
sva1.addAll(sva0);
sva1.add(new StringValue(String.valueOf(0)));
StringValueArray sva2 = new StringValueArray();
sva2.addAll(sva1);
sva2.add(new StringValue(String.valueOf(1)));
StringValueArray sva3 = new StringValueArray();
sva3.addAll(sva2);
sva3.add(new StringValue(String.valueOf(-1)));
StringValueArray sva4 = new StringValueArray();
sva4.addAll(sva3);
sva4.add(new StringValue(String.valueOf(Long.MAX_VALUE)));
StringValueArray sva5 = new StringValueArray();
sva5.addAll(sva4);
sva5.add(new StringValue(String.valueOf(Long.MIN_VALUE)));
StringValueArray sva6 = new StringValueArray();
sva6.addAll(sva5);
sva6.add(new StringValue(String.valueOf(rndLong)));
StringValueArray sva7 = new StringValueArray();
sva7.addAll(sva6);
sva7.add(new StringValue(String.valueOf(-rndLong)));
StringValueArray sva8 = new StringValueArray();
sva8.addAll(sva7);
for (int i = 0; i < 1.5 * defaultElements; i++) {
sva8.add(new StringValue(String.valueOf(i)));
}
sva8.addAll(sva8);
return new StringValueArray[] { sva0, sva1, sva2, sva3, sva4, sva5, sva6, sva7, sva8 };
}
Aggregations