/** * Get the user's test ratings. * Summarizes the user's ratings from the history. * * @return The user's ratings for the test items. */ public Long2DoubleMap getTestRatings() { if (testRatings == null) { Predicate<Entity> predicate = Entities.typePredicate(CommonTypes.RATING); Function<Entity, Rating> targetViewClass = Entities.projection(Rating.class); ImmutableList<Rating> list = FluentIterable.from(testHistory).filter(predicate).transform(targetViewClass).toList(); testRatings = Ratings.userRatingVector(list); } return testRatings; } }
@Override public IdBox<List<E>> readObject() { while (iter.hasNext()) { Map.Entry<Long, List<Entity>> entry = iter.next(); Stream<Entity> data = entry.getValue() .stream() .filter(query); Ordering<Entity> ord = query.getOrdering(); if (ord != null) { data = data.sorted(ord); } List<E> list = data.map(Entities.projection(query.getViewType())) .collect(Collectors.toList()); if (!list.isEmpty()) { return IdBox.create(entry.getKey(), list); } } // we're done return null; } };
: ObjectStreams.transform(baseStream, Entities.projection(query.getViewType())); List<SortKey> sort = query.getSortKeys(); List<SortKey> dataKeys = data.getSortKeys();
@Override public IdBox<List<E>> readObject() { while (iter.hasNext()) { Map.Entry<Long, List<Entity>> entry = iter.next(); Stream<Entity> data = entry.getValue() .stream() .filter(query); Ordering<Entity> ord = query.getOrdering(); if (ord != null) { data = data.sorted(ord); } List<E> list = data.map(Entities.projection(query.getViewType())) .collect(Collectors.toList()); if (!list.isEmpty()) { return IdBox.create(entry.getKey(), list); } } // we're done return null; } };
: ObjectStreams.transform(baseStream, Entities.projection(query.getViewType())); List<SortKey> sort = query.getSortKeys(); List<SortKey> dataKeys = data.getSortKeys();