shen created FLINK-28341: ---------------------------- Summary: Fix comment in BytesKeyNormalizationUtil.java Key: FLINK-28341 URL: https://issues.apache.org/jira/browse/FLINK-28341 Project: Flink Issue Type: Improvement Reporter: shen
The comment [here|https://github.com/apache/flink/blob/release-1.15.1-rc1/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/sort/BytesKeyNormalizationUtil.java#L74] is not correct since [Byte.MIN_VALUE|https://docs.oracle.com/javase/7/docs/api/java/lang/Byte.html#MIN_VALUE] = -128, [Byte.MAX_VALUE|https://docs.oracle.com/javase/7/docs/api/java/lang/Byte.html#MAX_VALUE] = 127. And I think [code below|https://github.com/apache/flink/blob/release-1.15.1-rc1/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/sort/BytesKeyNormalizationUtil.java#L77-L79] can be simplified as: {code:java} import org.junit.Assert; import org.junit.Test; public class TestIntegerConvertion { @Test public void testConvertByteInteger() { for (byte i = Byte.MIN_VALUE; ; ++i) { Assert.assertEquals(convertByFlink(i), convertSimplified(i)); if (i == Byte.MAX_VALUE) break; } } private byte convertByFlink(byte originValue) { int highByte = originValue & 0xff; highByte -= Byte.MIN_VALUE; return (byte)highByte; } private byte convertSimplified(byte originValue) { return (byte) (originValue - Byte.MIN_VALUE); // no need to byte and 0xFF. } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)