public static void setAll(MemoryBuffer bitmapBuffer, int baseOffset, int valueCount) {
    final int sizeInBytes = (valueCount + 7) / 8;
    // If value count is not a multiple of 8, then calculate number of used bits in the last byte
    final int remainder = valueCount % 8;

    final int sizeInBytesMinus1 = sizeInBytes - 1;
    int bytesMinus1EndOffset = baseOffset + sizeInBytesMinus1;
    for (int i = baseOffset; i < bytesMinus1EndOffset; i++) {
      bitmapBuffer.putByte(i, (byte) 0xff);
    }

    // handling with the last byte
    // since unsafe putLong use native byte order, maybe not big endian,
    // see java.nio.DirectByteBuffer.putLong(long, long), we can't use unsafe.putLong
    // for bit operations, native byte order may be subject to change between machine
    if (remainder != 0) {
      // Every byte is set form right to left
      byte byteValue = (byte) (0xff >>> (8 - remainder));
      bitmapBuffer.putByte(baseOffset + sizeInBytesMinus1, byteValue);
    }
  }
@Test
  public void testSetAll() {
    int valueCount = 10;
    MemoryBuffer buffer = MemoryUtils.buffer(8);
    BitUtils.setAll(buffer, 0, valueCount);
    assertEquals(BitUtils.getNullCount(buffer, 0, valueCount), 0);
    assertEquals("ff03000000000000", StringUtils.encodeHexString(buffer.getRemainingBytes()));
  }