Closed leventov closed 6 years ago
Because Java does some really strange and inconsistent things under the covers. For example, a slice offset is saved differently for a direct BB vs a heap BB. If the BB is Read-only, I have to acquire the values of hb and offset via reflection.
I understand difference between heap and direct, but I don't understand why in case of writable you don't access hb
and offset
.
Because I have normal access to byteBuf.array() = hb, and byteBuf.arrayOffset()= offset.
I didn't complete review, so want to keep it open as a reminder
@leventov
Please review.
I am closing this due to lack of response.
Ok, I finally understood why you are doing this: because ByteBuffer.array()
and arrayOffset()
throw an exception when attempted to be called on a read-only BB. The other path works in both cases though so I decided to simplify the code in #73.
Yes and I agree with your simplified code.
https://github.com/DataSketches/memory/blob/5356a8b1db8aaf985acb22766e803f8737de115e/src/main/java/com/yahoo/memory/AccessByteBuffer.java#L32-L80
Why read-only and writable branches are so different?