class RedisStreamReader implements Closeable {

  public int readInt() throws IOException {
    int length = 0;
    final byte[] allIntBytes = new byte[13]; // maximum integer length + minus symbol + CR + LF = 13
    while ((allIntBytes[length++] = readByte()) != RedisBytes.CARRIAGE_RETURN_BYTE) {
      ;
    }
    //Read Line feed byte
    readByte();
    int number = 0;
    final boolean negative = allIntBytes.length > 0 && allIntBytes[0] == RedisBytes.DASH_BYTE;
    //We don't read last value if it's negative
    for (int i = length - 2, j = 0; i > (negative ? 0 : -1); i--, j++) {
      number += (int) (Math.pow(10, j) * (allIntBytes[i] - RedisBytes.ZERO_BYTE));
    }
    number = number * (negative ? -1 : 1);
    return number;
  }

  public  RedisStreamReader(InputStream inputStream);

}