code: static public int packLong(byte[] ba, long value)
        throws IOException {
  
      if (value < 0) {
        throw new IllegalArgumentException("negative value: v=" + value);
      }
  
      int i = 1;
      while ((value & ~0x7FL) != 0) {
        ba[i - 1] = (byte) (((int) value & 0x7F) | 0x80);
        value >>>= 7;
        i++;
      }
      ba[i - 1] = (byte) value;
      return i;
    }
docs: Pack non-negative long into byte array. It will occupy 1-10 bytes
  depending on value (lower values occupy smaller space)
  
  @param ba the byte array
  @param value the long value
  @return the number of bytes written
  @throws IOException if an error occurs with the stream