SparseVector predictions = user.getPredictions();
if (predictions == null) {
predictions = MutableSparseVector.create();
}
LongSortedSet items = ratings.keySet();
if (!items.containsAll(predictions.keySet())) {
items = LongUtils.setUnion(items, predictions.keySet());
}
logger.debug("outputting {} predictions for user {}", predictions.size(), user.getUserId());
for (LongIterator iter = items.iterator(); iter.hasNext(); /* no increment */) {
long item = iter.nextLong();
Double rating = ratings.containsKey(item) ? ratings.get(item) : null;
Double pred = predictions.containsKey(item) ? predictions.get(item) : null;
try {
List<Object> row = Lists.<Object>newArrayList(user.getUserId(), item, rating, pred);