@Override
 public Long2ObjectMap<UserHistory<Event>> get() {
   Long2ObjectMap<List<Event>> table = new Long2ObjectOpenHashMap<List<Event>>();
   Cursor<Event> events = eventDAO.streamEvents();
   try {
     for (Event evt : events) {
       final long iid = evt.getUserId();
       List<Event> list = table.get(iid);
       if (list == null) {
         list = Lists.newArrayList();
         table.put(iid, list);
       }
       list.add(evt);
     }
   } finally {
     events.close();
   }
   Long2ObjectMap<UserHistory<Event>> result =
       new Long2ObjectOpenHashMap<UserHistory<Event>>(table.size());
   for (Long2ObjectMap.Entry<List<Event>> evt : table.long2ObjectEntrySet()) {
     long user = evt.getLongKey();
     result.put(user, History.forUser(user, evt.getValue()));
     evt.setValue(null);
   }
   return result;
 }
  /**
   * Get a user's ratings.
   *
   * @param user The user ID.
   * @return The ratings to retrieve.
   */
  private SparseVector getUserRatingVector(long user) {
    UserHistory<Rating> history = userEvents.getEventsForUser(user, Rating.class);
    if (history == null) {
      history = History.forUser(user);
    }

    return RatingVectorUserHistorySummarizer.makeRatingVector(history);
  }
 @Nullable
 @Override
 public ItemEventCollection<Event> apply(@Nullable Map.Entry<Long, List<Event>> input) {
   if (input == null) {
     return null;
   } else {
     return History.forItem(input.getKey(), input.getValue());
   }
 }