snuyanzin commented on code in PR #29370:
URL: https://github.com/apache/flink/pull/29370#discussion_r4167168251
##########
flink-core/src/test/java/org/apache/flink/types/variant/BinaryVariantInternalBuilderTest.java:
##########
@@ -201,4 +208,58 @@ void testAppendFloat() {
assertThatCode(() ->
floatList.forEach(builder::appendFloat)).doesNotThrowAnyException();
}
+
+ @ParameterizedTest
+ @ValueSource(
+ strings = {
+ "",
+ "Grüße, 世界 🚀",
+ "A string longer than 63 bytes is stored with a 4-byte length
header."
+ })
+ void testAppendStringStoresUtf8BytesAsTheyAre(final String str) {
+ final byte[] utf8 = str.getBytes(UTF_8);
+ final BinaryVariantInternalBuilder builder = new
BinaryVariantInternalBuilder(false);
+ builder.appendString(utf8);
+ final BinaryVariant variant = builder.build();
+
+ final byte[] value = variant.getValue();
+ final int headerSize = utf8.length > MAX_SHORT_STR_SIZE ? 1 + U32_SIZE
: 1;
Review Comment:
```suggestion
final int headerSize = utf8.length - 1 > MAX_SHORT_STR_SIZE ?
U32_SIZE : 0;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]