public static int readCompressedInt(InputStream input) throws IOException {
        int result = 0;
        int i = 0;
        byte b;
        do {
            b = (byte) input.read();
            result += (b & VALUE_MASK) << (NEXT_BIT_SHIFT * i);
            i++;
            if (i > Bytes.SIZEOF_INT + 1) {
                throw new IllegalStateException(
                        "Corrupted compressed int (too long: " + (i + 1) + " bytes)");
            }
        } while (0 != (b & NEXT_BIT_MASK));
        return result;
    }
Read integer from stream coded in 7 bits and increment position.

@return the integer that has been read
@throws IOException on stream error
stroom-bytebuffer/src/main/java/stroom/bytebuffer/hbase/ByteBufferUtils.java