Koado opened a new issue, #7961: URL: https://github.com/apache/rocketmq/issues/7961
### Before Creating the Enhancement Request - [X] I have confirmed that this should be classified as an enhancement rather than a bug/feature. ### Summary use BoundaryType in binarySearchInCQByTime, when the target timestsamp does not match an exact offset, return either left offset or right offset depending on the value of BoundaryType. ### Motivation In the original implementation, if the target timestamp does not match an exact offset, the system compares the absolute value of the difference between the leftOffset's storeTime and the incoming timestamp with the absolute value of the difference between the rightOffset's storeTime and the timestamp. The method will return the offset with the smaller absolute difference as the result. <img width="917" alt="image" src="https://github.com/apache/rocketmq/assets/34032341/8406dfb9-8821-468c-bea8-7ec1e83f90dd"> When we want to retrieve messages within a certain time range, this implementation may result in obtaining messages that fall outside of the specified time range. ### Describe the Solution You'd Like use BoundaryType to replace absolute value comparison: 1. When the input time is the start time, pass in BoundaryType.UPPER; when the input time is the end time, pass in BoundaryType.LOWER. 2. If the value of BoundaryType is UPPER, return the right offset. If the value of BoundaryType is LOWER, return the left offset. ### Describe Alternatives You've Considered No ### Additional Context _No response_ -- 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: commits-unsubscr...@rocketmq.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org