public static int writeLongAsVarIntBytes(long v, byte[] bytes, int offest) {
        int pos = offest;

        while (true) {
            if ((v & ~0x7FL) == 0) {
                bytes[pos++] = ((byte)v);
                return pos;
            } else {
                bytes[pos++] = (byte)((v & 0x7F) | 0x80);
                v >>>= 7;
            }
        }    
    }
public static int writeLongAsVarIntBytes ( long v , byte [ ] bytes , int offest ) { int pos = offest ; while ( true ) { if ( ( v & ~ 0x7FL ) == 0 ) { bytes [ pos ++ ] = ( ( byte ) v ) ; return pos ; } else { bytes [ pos ++ ] = ( byte ) ( ( v & 0x7F ) | 0x80 ) ; v >>>= 7 ; } } }
Writes a long to the byte array in the Varint format.
@param v - long value to write to the bytes buffer in the Varint format
@param bytes - byte buffer to write to - must contain enough space for maximum
length which is 10 bytes.
@param offset - the offset within the bytes buffer to start writing
@return - returns the number of bytes used from the bytes buffer