public void clear(int startIndex, int endIndex) {
    if (endIndex <= startIndex) {
      return;
    }

    int startWord = (startIndex >> 6);
    if (startWord >= wlen) {
      return;
    }

    // since endIndex is one past the end, this is index of the last
    // word to be changed.
    int endWord = ((endIndex - 1) >> 6);

    long startmask = -1L << startIndex;
    long endmask = -1L >>> -endIndex;  // 64-(endIndex&0x3f) is the same as -endIndex due to wrap

    // invert masks since we are clearing
    startmask = ~startmask;
    endmask = ~endmask;

    if (startWord == endWord) {
      bits[startWord / PAGE_SIZE][startWord % PAGE_SIZE] &= (startmask | endmask);
      return;
    }

    bits[startWord / PAGE_SIZE][startWord % PAGE_SIZE] &= startmask;

    int middle = Math.min(wlen, endWord);
    if (startWord / PAGE_SIZE == middle / PAGE_SIZE) {
      Arrays.fill(bits[startWord / PAGE_SIZE], (startWord + 1) % PAGE_SIZE, middle % PAGE_SIZE, 0L);
    } else {
      while (++startWord < middle) {
        bits[startWord / PAGE_SIZE][startWord % PAGE_SIZE] = 0L;
      }
    }
    if (endWord < wlen) {
      bits[endWord / PAGE_SIZE][endWord % PAGE_SIZE] &= endmask;
    }
  }
Clears a range of bits.  Clearing past the end does not change the size of the set.

@param startIndex lower index
@param endIndex one-past the last bit to clear
ambry-utils/src/main/java/com/github/ambry/utils/OpenBitSet.java