Copilot commented on code in PR #30171:
URL: https://github.com/apache/flink/pull/30171#discussion_r4721174731
##########
flink-core/src/test/java/org/apache/flink/util/SwarUtilsTest.java:
##########
@@ -94,6 +94,35 @@ void testContainsLessThan(byte b, int index) {
.isFalse();
}
+ @ParameterizedTest
+ @MethodSource("delimitersAtEveryIndex")
+ void testIndexOf(byte b, int index) {
+ // neighbors that differ only in the lowest bit are where a borrow
could fake a match
+ final byte[] bytes = filled((byte) (b ^ 0x01));
+ bytes[index] = b;
+ assertThat(SwarUtils.indexOf(bytes, 0, LENGTH, b)).isEqualTo(index);
+ // an unaligned start still finds the byte, unless it's before the
start
+ assertThat(SwarUtils.indexOf(bytes, 1, LENGTH - 1, b)).isEqualTo(index
> 0 ? index : -1);
+ assertThat(SwarUtils.indexOf(bytes, index + 1, LENGTH - index - 1,
b)).isEqualTo(-1);
Review Comment:
The new tests cover shifted starts, but every nonempty search still ends at
the backing array's end. They would therefore miss an implementation that
ignores `len` and finds a delimiter outside the requested range—important here
because input buffers can contain bytes beyond the current record/read limit.
Please add upper-bound cases in `SwarUtilsTest`, for example searching `[0,
index)` with the only match at `index`, covering both word-sized ranges and
scalar tails.
--
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]