blambov commented on code in PR #3764:
URL: https://github.com/apache/cassandra/pull/3764#discussion_r1905439306
##########
src/java/org/apache/cassandra/utils/FastByteOperations.java:
##########
@@ -70,6 +70,21 @@ public static int compareUnsigned(ByteBuffer b1, ByteBuffer
b2)
return BestHolder.BEST.compare(b1, b2);
}
+ public static int compareUnsigned(ByteBuffer b1, long address2, int
length2)
Review Comment:
Nit: these should have "Memory" somewhere in the name, to make it obvious
that they expect an address.
##########
src/java/org/apache/cassandra/utils/memory/MemoryUtil.java:
##########
@@ -104,54 +104,87 @@ public static void setByte(long address, int count, byte
b)
unsafe.setMemory(address, count, b);
}
+ public static void setShort(long address, short s, boolean isBigEndian)
+ {
+ unsafe.putShort(address, isBigEndian ? Short.reverseBytes(s) : s);
Review Comment:
This looks wrong. We need to check if the architecture matches the requested
endianness, and reverse the bytes when it does not.
Incidentally, all the existing non-specified-endianness versions are writing
the data in little-endian, and disagree with `putXByByte` on big-endian
machines... I will open a separate ticket to discuss these and check for
potential problems.
##########
src/java/org/apache/cassandra/utils/memory/MemoryUtil.java:
##########
@@ -104,54 +104,87 @@ public static void setByte(long address, int count, byte
b)
unsafe.setMemory(address, count, b);
}
+ public static void setShort(long address, short s, boolean isBigEndian)
Review Comment:
Using a boolean for the byte order is error-prone. I would change it to
accept a `ByteOrder` as the last argument.
--
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]