richardstartin commented on a change in pull request #7708:
URL: https://github.com/apache/pinot/pull/7708#discussion_r743986902
##########
File path:
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/FixedByteValueReaderWriter.java
##########
@@ -56,14 +57,28 @@ public String getUnpaddedString(int index, int
numBytesPerValue, byte paddingByt
assert buffer.length >= numBytesPerValue;
long startOffset = (long) index * numBytesPerValue;
- for (int i = 0; i < numBytesPerValue; i++) {
- byte currentByte = _dataBuffer.getByte(startOffset + i);
- if (currentByte == paddingByte) {
- return new String(buffer, 0, i, UTF_8);
+ int written = 0;
+ long pattern = (paddingByte & 0xFFL) * 0x101010101010101L;
+ ByteBuffer wrapper = ByteBuffer.wrap(buffer);
+ for (int i = 0; i < ((numBytesPerValue >>> 3) << 3); i += 8) {
+ long word = _dataBuffer.getLong(startOffset + i);
+ wrapper.putLong(i, word);
+ long zeroed = word ^ pattern;
+ long tmp = (zeroed & 0x7F7F7F7F7F7F7F7FL) + 0x7F7F7F7F7F7F7F7FL;
+ tmp = ~(tmp | zeroed | 0x7F7F7F7F7F7F7F7FL);
+ int end = Long.numberOfLeadingZeros(tmp) >>> 3;
Review comment:
`Long.numberOfLeadingZeros` has an intrinsic implementation which
compiles to an instruction with 1 cycle latency and reciprocal throughput of
1/2, it's really not worth guarding with a branch.
--
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]