RussellSpitzer commented on code in PR #13284: URL: https://github.com/apache/iceberg/pull/13284#discussion_r2138593825
########## core/src/main/java/org/apache/iceberg/variants/PrimitiveWrapper.java: ########## @@ -208,15 +213,22 @@ public int writeTo(ByteBuffer outBuffer, int offset) { VariantUtil.writeBufferAbsolute(outBuffer, offset + 5, binary); return 5 + binary.remaining(); case STRING: - // TODO: use short string when possible + byte[] valueBytes = ((String) value).getBytes(StandardCharsets.UTF_8); Review Comment: Similar comment to above, I think we can do ```java if (null == buffer) { this.buffer = ByteBuffer.wrap(((String) value).getBytes(StandardCharsets.UTF_8)); } If (buffer.remaining() < MAX_SHORT_STRING_LENGTH) { outBuffer.put(offset, shortStringHeader(buffer.remaining)); VariantUtil.writeBufferAbsolute(outBuffer, offset + 1, buffer); return 1 + buffer.remaining(); } else { outBuffer.put(offset, STRING_HEADER); outBuffer.putInt(offset + 1, buffer.remaining()); VariantUtil.writeBufferAbsolute(outBuffer, offset + 5, buffer); return 5 + buffer.remaining(); } // This goes in VarientUtil.java static byte shortStringHeader(int length) { return (byte) ((length << 2) | BASIC_TYPE_SHORT_STRING); } ``` Note I think we should probably also extract out that bit magic I wrote there to ```java } ``` -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org