public long decodeVariantLong(byte[] read){
  int shift=0;
  long result=0;
  ByteArrayInputStream in=new ByteArrayInputStream(read);
  while (shift < 64) {
    final byte b=(byte)in.read();
    result|=(long)(b & 0x7F) << shift;
    if ((b & 0x80) == 0) {
      break;
    }
    shift+=7;
  }
  return ((result >>> 1) ^ -(result & 1));
}

public long decodeVariantLong ( byte [ ] read ) { int shift = 0 ; long result = 0 ; ByteArrayInputStream in = new ByteArrayInputStream ( read ) ; while ( shift < 64 ) { final byte b = ( byte ) in . read ( ) ; result |= ( long ) ( b & 0x7F ) << shift ; if ( ( b & 0x80 ) == 0 ) { break ; } shift += 7 ; } return ( ( result > > > 1 ) ^ - ( result & 1 ) ) ; }
decode a long number from variable length encoded byte array 1 . decode 7 bits from each bit , starting with lsb 2 . undo the sign - unsigned conversion we did , to restore the sign bit
