/**
   * Get the rank (index) for all set bits up to just before the given rankPosition in the block.
   * The caller is responsible for deriving the count of bits up to the docID target from the rankPosition.
   * The caller is also responsible for keeping track of set bits up to the current block.
   * Important: This only accepts rankPositions that aligns to {@link #RANK_BLOCK} boundaries.
   * Note 1: Use {@link #denseRankPosition(int)} to obtain a calid rankPosition for a wanted docID.
   * Note 2: The caller should seek to the rankPosition in the underlying slice to keep everything in sync.
   * @param rankPosition a docID target that aligns to {@link #RANK_BLOCK}.
   * @return the rank (index / set bits count) up to just before the given rankPosition.
   *         If rank is disabled, -1 is returned.
   */
// TODO: This method requires a lot of knowledge of the intrinsics of the cache. Usage should be simplified
int getRankInBlock(int rankPosition) {
    if (rank == null) {
      return -1;
    }
    assert rankPosition == denseRankPosition(rankPosition);
    int rankIndex = rankPosition >> RANK_BLOCK_BITS;
    return rankIndex >= rank.size() ? -1 : (int) rank.get(rankIndex);
  }
int getRankInBlock(int rankPosition) {
if (rank == null) {
return -1;
}
assert rankPosition == denseRankPosition(rankPosition);
int rankIndex = rankPosition >> RANK_BLOCK_BITS;
return rankIndex >= rank.size() ? -1 : (int) rank.get(rankIndex);
}
int getRankInBlock(int rankPosition) {
if (rank == null) {
return -1;
}
assert rankPosition == denseRankPosition(rankPosition);
int rankIndex = rankPosition >> RANK_BLOCK_BITS;
return rankIndex >= rank.size() ? -1 : (int) rank.get(rankIndex);
}
int getRankInBlock(int rankPosition) {
if (rank == null) {
return -1;
}
assert rankPosition == denseRankPosition(rankPosition);
int rankIndex = rankPosition >> RANK_BLOCK_BITS;
return rankIndex >= rank.size() ? -1 : (int) rank.get(rankIndex);
}