Jackie-Jiang commented on PR #10151:
URL: https://github.com/apache/pinot/pull/10151#issuecomment-1397833332
With the current code, `length == bytes.length && length != 0 &&
bytes[length - 1] == 0` case is not handled (the new added
`ValueReaderComparisonTest` is flaky right now). To keep the behavior exactly
the same as before, we need to do the following check:
```
if (padded) {
if (length < bytes.length) {
return -1;
}
if (length == bytes.length) {
if (length == 0) {
return 0;
} else {
return dataBuffer.getByte(startOffset + length - 1) == 0 ? -1 :
0;
}
}
// length > bytes.length
// need to figure out whether the unpadded string is longer than the
parameter or not
if (bytes.length == 0) {
// just need nonzero first byte
return dataBuffer.getByte(startOffset) == 0 ? 0 : 1;
} else if (bytes[bytes.length - 1] == 0) {
return -1;
} else {
// check if the stored string continues beyond the length of the
parameter
return dataBuffer.getByte(startOffset + bytes.length) == 0 ? 0 : 1;
}
```
IMO it is too much and quite easy to make mistakes without adding much value
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]