@Nullable @Override public IdBox<Long2DoubleMap> apply(@Nullable IdBox<List<Entity>> input) { if (input == null) { return null; } return IdBox.create(input.getId(), makeVector(input.getValue())); } });
@Nonnull @Override public Long2DoubleMap userRatingVector(long user) { IdBox<Long2DoubleMap> cached = cachedValue; if (cached != null && cached.getId() == user) { return cached.getValue(); } Long2DoubleMap map; List<Entity> entities = dao.query(getEntityType()) .withAttribute(CommonAttributes.USER_ID, user) .get(); map = makeVector(entities); cachedValue = IdBox.create(user, map); return map; }
@Nullable @Override public IdBox<Long2DoubleMap> apply(@Nullable IdBox<List<Entity>> input) { if (input == null) { return null; } return IdBox.create(input.getId(), makeVector(input.getValue())); } });
@Nonnull @Override public Long2DoubleMap userRatingVector(long user) { IdBox<Long2DoubleMap> cached = cachedValue; if (cached != null && cached.getId() == user) { return cached.getValue(); } Long2DoubleMap map; List<Entity> entities = dao.query(getEntityType()) .withAttribute(CommonAttributes.USER_ID, user) .get(); map = makeVector(entities); cachedValue = IdBox.create(user, map); return map; }