ZanderXu commented on PR #6710: URL: https://github.com/apache/hadoop/pull/6710#issuecomment-2044493479
> I am a little confused with it why here return -2 which is binary search for collections contains only one element, IIUC, it will return -1 for this case. Please correct me if i missed something. The binary search will return -1 if the offset is less than the smallest offset in the list. And it will return -2 if the offset is greater than the maximum offset in the list. We can reproduce by the following steps: 1. Assume one file contains 20 completed blocks and 1 UC block. 2. The current `locatedBlocks` only cache the 10 ~ 20 blocks. 3. The binary search will return -1 if the offset is less than the offset of the first cached block, such as offset in the first ten blocks. 4. The binary search will return -2 if the offset is greater than the offset of the last cached block, such as offset in the last UC block. And another bug is that the `currentBlock` should be relocated after `locatedBlocks` is refreshed. -- 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]
