[ https://issues.apache.org/jira/browse/CASSANDRA-20190?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17930810#comment-17930810 ]
Dmitry Konstantinov commented on CASSANDRA-20190: ------------------------------------------------- [https://github.com/apache/cassandra/pull/3936] I have implemented a draft version of changes related to {{{}MemoryUtil{}}}: I have introduced {{NativeEndianMemoryUtil}} and moved adjusted methods from {{MemoryUtil}} related to a particular endian (like get/setInt). The methods from MemoryUtil class are used only in offheap memtable entities (NativeCell/NativeClustering/NativeDecoratedKey) which are not going to disk/network without decoding to Java primitives, so I switched the logic to native endian to avoid unnecessary conversions. Values stored in the entities are still exposed as BigEndian byte buffers. Also I dropped unused {{getHollowByteBuffer()}} method and related constants. I have not touched {{Memory}} class yet. > MemoryUtil.setInt/getInt and similar use the wrong endianness > ------------------------------------------------------------- > > Key: CASSANDRA-20190 > URL: https://issues.apache.org/jira/browse/CASSANDRA-20190 > Project: Apache Cassandra > Issue Type: Bug > Components: Local/Other > Reporter: Branimir Lambov > Assignee: Dmitry Konstantinov > Priority: Normal > Time Spent: 10m > Remaining Estimate: 0h > > `NativeCell`, `NativeClustering` and `NativeDecoratedKey` use the above > methods from `MemoryUtil` to write and read data from native memory. As far > as I can see they are meant to write data in big endian. They do not (they > always correct to little endian). > Moreover, they disagree with their `ByByte` versions on big-endian machines > (which is only likely an issue on aligned-access architectures (x86 and arm > should be fine)). > The same is true for the methods in `Memory`, used by compression metadata as > well as index summaries. > We need to verify that this does not cause any problems, and to change the > methods to behave as expected and document the behaviour by explicitly using > `ByteOrder.LITTLE_ENDIAN` for any data that may have been persisted on disk > with the wrong endianness. > The current MemoryUtil behaviour: > ||Native > order||MemoryUtil.setX||MemoryUtil.setXByByte||MemoryUtil.getX||MemoryUtil.getXByByte|| > |BE|LE|BE|LE|BE| > |LE|LE|LE|LE|LE| -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org