public void putInt2_4_8Bytes(long number) {
        if (number < 0L) {
            throw new IllegalArgumentException("Cannot encode negative number.");
        } else if (number > 0x3FFFFFFFFFFFFFFFL) {
            throw new IllegalArgumentException("Cannot encode number larger than 2^62.");
        }

        if (number < 0x8000L) {
            //length 2 bytes
            putShort((short) number);
        } else if (number < 0x40000000L) {
            //length 4 bytes
            putInt(((int) number) | 0x80000000);
        } else {
            //length 8 bytes
            putLong(number | 0xC000000000000000L);
        }
    }
Writes a 62-bit positive integer to the buffer, using 2, 4, or 8 bytes.

@param number the integer to write
vespajlib/src/main/java/com/yahoo/io/GrowableByteBuffer.java