final double globalMean;
logger.debug("computing item mean ratings");
Cursor<Rating> ratings = dao.streamEvents(Rating.class);
try {
IdMeanAccumulator accum = new IdMeanAccumulator();
for (Rating r: ratings) {
Preference p = r.getPreference();
if (p != null) {
accum.put(p.getItemId(), p.getValue());
}
}
globalMean = accum.globalMean();
itemMeans = accum.idMeanOffsets(damping);
} finally {
ratings.close();
}
logger.debug("computed means for {} items", itemMeans.size());
logger.debug("global mean rating is {}", globalMean);