public int getNextSetBitOffset(int bitOffset) {
    int byteOffset = bitOffset / Byte.SIZE;
    int bitOffsetInFirstByte = bitOffset % Byte.SIZE;
    int firstByte = (_dataBuffer.getByte(byteOffset) << bitOffsetInFirstByte) & BYTE_MASK;
    if (firstByte != 0) {
      return bitOffset + FIRST_BIT_SET[firstByte];
    }
    while (true) {
      byteOffset++;
      int currentByte = _dataBuffer.getByte(byteOffset) & BYTE_MASK;
      if (currentByte != 0) {
        return (byteOffset * Byte.SIZE) | FIRST_BIT_SET[currentByte];
      }
    }
  }
@Test
  public void testGetNextSetBitOffset()
      throws IOException {
    int[] setBitOffsets = new int[NUM_ITERATIONS];
    int bitOffset = RANDOM.nextInt(10);
    for (int i = 0; i < NUM_ITERATIONS; i++) {
      setBitOffsets[i] = bitOffset;
      bitOffset += RANDOM.nextInt(10) + 1;
    }
    int dataBufferSize = setBitOffsets[NUM_ITERATIONS - 1] / Byte.SIZE + 1;
    try (PinotDataBuffer dataBuffer = getEmptyDataBuffer(dataBufferSize);
        PinotDataBitSet dataBitSet = new PinotDataBitSet(dataBuffer)) {
      for (int i = 0; i < NUM_ITERATIONS; i++) {
        dataBitSet.setBit(setBitOffsets[i]);
      }

      // Test next set bit offset
      for (int i = 0; i < NUM_ITERATIONS - 1; i++) {
        assertEquals(dataBitSet
                .getNextSetBitOffset(setBitOffsets[i] + RANDOM.nextInt(setBitOffsets[i + 1] - setBitOffsets[i]) + 1),
            setBitOffsets[i + 1]);
      }

      // Test next nth set bit offset
      for (int i = 0; i < NUM_ITERATIONS - 100; i++) {
        int n = RANDOM.nextInt(100) + 1;
        assertEquals(
            dataBitSet.getNextNthSetBitOffset(
                setBitOffsets[i] + RANDOM.nextInt(setBitOffsets[i + 1] - setBitOffsets[i]) + 1, n),
            setBitOffsets[i + n]);
      }
    }
  }