You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/06/24 02:06:01 UTC

[GitHub] [rocketmq] BurningCN commented on issue #4505: Questions about the legal judgment of indexCount

BurningCN commented on issue #4505:
URL: https://github.com/apache/rocketmq/issues/4505#issuecomment-1165106301

   多谢,从你的描述我想了下从1计数的原因是这样的。
   当`putKey`方法触发,某个`slot`被第一次命中的时候,该`slot`本身的值就是`0`。如果`indexCount`从`0`计数的话,当`this.mappedByteBuffer.getInt(absSlotPos)`返回`0`的时候,无法确认返回的`0`是表示【从来没有过`key`落在该`slot`上】,还是表示【之前已经有一个`indexCount=0`的`indexEntry`落到了该`slot`上】。
   
   Thanks a lot. From your description, I think the reason for counting from 1 is like this.
   When the putKey method is triggered and a slot is hit for the first time, the value of the slot itself is 0. If indexCount counts from 0, when this `this.mappedByteBuffer.getInt(absSlotPos)` returns 0, it is not possible to confirm whether the returned 0 means that [no key has ever landed on the slot] or that [an indexEntry with indexCount=0 has previously landed on the slot].


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org