public static void writeUnsignedVL(long data,DataOutput out) throws IOException {
  while (true) {
    if ((data & ~0x7FL) == 0) {
      out.writeByte((int)data);
      return;
    }
 else {
      out.writeByte(((int)data & 0x7F) | 0x80);
      data>>>=7;
    }
  }
}

public static void writeUnsignedVL ( long data , DataOutput out ) throws IOException { while ( true ) { if ( ( data & ~ 0x7FL ) == 0 ) { out . writeByte ( ( int ) data ) ; return ; } else { out . writeByte ( ( ( int ) data & 0x7F ) | 0x80 ) ; data >>>= 7 ; } } }
encode a long as a variable length array . this method is appropriate for unsigned integers . for signed integers , negative values will always consume 10 bytes , so it is recommended to use writesignedvl instead . this is taken from the varint encoding in protobufs ( bsd licensed ) . see https : / / developers . google . com / protocol - buffers / docs / encoding
