What should be the value of non-rated field when finding cosine similarity
Implementation-side, there is a good reason to make 0 correspond to not rated.  Since most users haven't rated most books, 0 will be the most common value and the cosine similarity function can use sparse matrices internally to speed up the computation.  The sparse matrix shortcut is the main reason why people use cosine similarity in the first place.

On the other hand, it will throw off your recommendations if the algorithm interprets a 0 to be closer to a 1 than a 2. You do need to intentionally ignore those, but you can easily do so inside your cosine similarity implementation rather than filtering the data before applying it.