Hi there! Thanks for the series!
While reading the sstable part, I have found that there is an unreachable check in the implementation of binary search.
Here is the exact line:
Explanation
The if expression checks if the mid index equals to usize::MAX which never happens. Note that in the last point of usage of the variable of m, we read the offset from the offsets vector by using m as index. If m were equal to the above bound, the program would have panicked (out of bounds) since Vec type is bounded by isize::MAX which is far lower than usize::MAX. Thus, if the code made to pass till this check, m is definitely lower than usize::MAX. Hence, the check is dead.
Hi there! Thanks for the series!
While reading the sstable part, I have found that there is an unreachable check in the implementation of binary search.
Here is the exact line:
database-engine/src/sstable.rs
Line 232 in 6425604
Explanation
The
ifexpression checks if the mid index equals tousize::MAXwhich never happens. Note that in the last point of usage of the variable ofm, we read the offset from theoffsetsvector by usingmas index. If m were equal to the above bound, the program would have panicked (out of bounds) sinceVectype is bounded byisize::MAXwhich is far lower thanusize::MAX. Thus, if the code made to pass till this check,mis definitely lower thanusize::MAX. Hence, the check is dead.