code: private static int readPreamble(ByteBuf in) {
          int length = 0;
          int byteIndex = 0;
          while (in.isReadable()) {
              int current = in.readUnsignedByte();
              length |= (current & 0x7f) << byteIndex++ * 7;
              if ((current & 0x80) == 0) {
                  return length;
              }
  
              if (byteIndex >= 4) {
                  throw new DecompressionException("Preamble is greater than 4 bytes");
              }
          }
  
          return 0;
      }
docs: Reads the length varint (a series of bytes, where the lower 7 bits
  are data and the upper bit is a flag to indicate more bytes to be
  read).
  
  @param in The input buffer to read the preamble from
  @return The calculated length based on the input buffer, or 0 if
  no preamble is able to be calculated