code: @Override
      public void writeCompactInt(int value) throws IOException {
          // MSB: 0  -> 1 byte with the remaining 7 bits
          // MSB: 10 -> 2 bytes with the remaining 6+8 bits
          // MSB: 11 -> 4 bytes with the remaining 6+8+8+8 bits
          if (value < COMPACT_INT_MIN || value >= COMPACT_INT_MAX) {
              throw new IllegalArgumentException("writeCompactInt can only serialize non-negative longs up to 2^30.");
          } else if (value > 0x3FFF) {
              // All 4 bytes
              writeInt(value | 0xC000_0000);
          } else if (value > 0x7F) {
              // 2 Bytes.
              writeShort((short) (value | 0x8000));
          } else {
              // 1 byte.
              writeByte((byte) value);
          }
      }
docs: {@inheritDoc}
  Encodes the given value as a compact integer, using the following scheme (MSB=Most Significant Bits):
  * MSB = 0 for values in [0, 0x7F], with a 1-byte encoding.
  * MSB = 10 for values in (0x7F, 0x3FFF], with a 2-byte encoding (2 MSB are reserved, leaving 14 bits usable).
  * MSB = 11 for values in (0x3FFF, 0x3FFF_FFFF], with a 4-byte encoding (2 MSB are reserved, leaving 30 bits usable).
  
  @param value The value to encode.