From 2d1a3b9347de8d89007cd515c624a0b55ee5a356 Mon Sep 17 00:00:00 2001 From: David Mollitor Date: Sat, 4 Jan 2025 14:26:40 -0500 Subject: [PATCH] Reduce buffer size for ASCII string optimization to 63 bytes --- .../src/main/java/org/apache/avro/io/BinaryEncoder.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lang/java/avro/src/main/java/org/apache/avro/io/BinaryEncoder.java b/lang/java/avro/src/main/java/org/apache/avro/io/BinaryEncoder.java index f8f9802edb7..97d9895c74f 100644 --- a/lang/java/avro/src/main/java/org/apache/avro/io/BinaryEncoder.java +++ b/lang/java/avro/src/main/java/org/apache/avro/io/BinaryEncoder.java @@ -37,8 +37,12 @@ */ public abstract class BinaryEncoder extends Encoder { - // Buffer used for writing ASCII strings - private final byte[] stringBuffer = new byte[128]; + /* + * Buffer used for writing ASCII strings. A string is encoded as a long followed + * by that many bytes of character data. A string of length 63 is the upper + * limit for a 1 byte variable-length long value. + */ + private final byte[] stringBuffer = new byte[63]; @Override public void writeNull() throws IOException {