Forum Stats

  • 3,853,698 Users
  • 2,264,256 Discussions


Chapter 13: products won't get reviewed


I'm doing the Java 11 25th Aniversary Learningpath. And doing the labs, of chapter 13, I encounter that after changing the code to load all the data from files, I see that the product reviews are loaded, but the products aren't actually Rated. While in the video I see that apparently the code from the presenter has ratings for the product.

Now, going through my code, I reviewed several times that my source matches that from the video. And I think it's logical that my products won't get rated. As I understand it, the .Collectors.toMap(product -> product, product -> loadReviews(product) part in the loadAllData() method does combine the product with the reviews list. But the reviews aren't averaging the rewiew ratings into the product.rating.

Do I miss something?

Kind regards,



  • User_I2MBO
    User_I2MBO Member Posts: 0 Green Ribbon

    that cause on the previous chapter the default product review was not rated but in this chapter if you looks on the video when the instructor opened one of the product's files you would see it has default review

    and he do not save the product after apply review prduct file does not change

    i also trapped on that one till i double check the part when he opened the product file

    hope that help and have a nice day :)

  • Vasily Strelnikov-Oracle
    Vasily Strelnikov-Oracle Member Posts: 15 Employee

    Practice 13.2 


    • Existing algorithms of the parseReview and parseProduct methods automatically add Review and Product objects to the products Map collection.

    • Such an approach is not suitable for a bulk data load scenario, because every time you invoke the writeReview method it recalculates the average rating value for all reviews of this product and recreates products by applying the new rating value.

    • You also need to be able to use Java Stream API Collectors to improve bulk load performance and possibly allow parallel processing of information.

    • You need to load data for your products and reviews from files as is, without constantly recalculating values.

    This is achieved by loading product information and all reviews for a product first, modifying the parseReview and parseProduct methods so they don't immediately add products and review to the map. The assumption is that product stored in the csv file is consistent with all of its reviews stored in another csv. This is not unlike loading data from the database where you don't expect to perform all calculations, but rather treat selected table data as consistent by default. Remember that since as early as practice 5.2 product can be created with a specified rating immediately, without actually having to calculate it from all reviews. Once product and all of its reviews are loaded, they can be added to a map stored in the ProductManager.

    The rest of the logic remains the same - a review can be applied to the product, causing its recreation and reinsertion into the map. No further calculations are required at printing stage not in this nor any earlier practice.

  • User_I2MBO
    User_I2MBO Member Posts: 0 Green Ribbon

    sorry for my miss understanding and thanks for correcting me and clearing that and thanks alot for you for many f the indepth thing and how thing wokring from behind scene that you teached us on that course and thanks for orcale to offer this course for free :)

    thanks again and have a nice day :)