You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found this method after discovering (from an OOME in tests) that within the ART module ints are modified by unpacking to a byte[], performing the modification, and then packing back to an int again.
IntegerUtils.shiftLeftFromSpecifiedPosition looks a little odd to me:
/** * shift the byte left from the specified position * @param v a integer value * @param pos the position from which to shift byte values left * @param count the shifting numbers * @return a fresh integer value */publicstaticintshiftLeftFromSpecifiedPosition(intv, intpos, intcount) {
byte[] initialVal = toBDBytes(v);
System.arraycopy(initialVal, pos + 1, initialVal, pos, count);
returnfromBDBytes(initialVal);
}
The following test case, which covers the combinations of position and count for which the method doesn't throw, passes:
The method is only used in node removal, which is unlikely to be widely used. The pattern above looks a little suspicious to me, so the behaviour in node removal is either quite subtle or perhaps wrong:
shiftLeftFromSpecifiedPosition() is to move the bytes after the removed position to a previouse position one by one. For example: the four bytes of the key is : 8,11, 13, 16 , now we remove the position 2 key(13), then move the afterward key value (16) to key value(13) poistion ,that is the final keys would be : 8, 11, 16,16;
@richardstartin if you still wanna this, would be appreciate you could give a concise description to document this behavior in your native language or pr it.
I found this method after discovering (from an OOME in tests) that within the ART module
int
s are modified by unpacking to abyte[]
, performing the modification, and then packing back to anint
again.IntegerUtils.shiftLeftFromSpecifiedPosition
looks a little odd to me:The following test case, which covers the combinations of
position
andcount
for which the method doesn't throw, passes:The method is only used in node removal, which is unlikely to be widely used. The pattern above looks a little suspicious to me, so the behaviour in node removal is either quite subtle or perhaps wrong:
If the method's implementation is correct, I think explaining the logic for modifying the key when removing nodes would be helpful.
The text was updated successfully, but these errors were encountered: