question: 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 ) ) ; }
target:  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