本文整理了Java中org.lenskit.data.dao.Query.valueSet
方法的一些代码示例,展示了Query.valueSet
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.valueSet
方法的具体详情如下:
包路径:org.lenskit.data.dao.Query
类名称:Query
方法名:valueSet
[英]Get the set of values from an attribute in the entities in this query. Use this to do things like get the set of items referenced in a user's ratings: dao.query(Rating.class) .withAttribute(CommonAttributes.USER_ID, user) .valueSet(CommonAttributes.ITEM_ID);
[中]
代码示例来源:origin: lenskit/lenskit
/**
* Get the default exclude set for a user. The base implementation gets
* all the items they have interacted with.
*
* @param user The user ID.
* @return The set of items to exclude.
*/
protected LongSet getDefaultExcludes(long user) {
// FIXME Support things other than ratings
return dao.query(CommonTypes.RATING)
.withAttribute(CommonAttributes.USER_ID, user)
.valueSet(CommonAttributes.ITEM_ID);
}
代码示例来源:origin: lenskit/lenskit
@Override
protected LongList recommend(long user, int n, @Nullable LongSet candidates, @Nullable LongSet exclude) {
if (exclude == null) {
exclude = data.query(statistics.getEntityType())
.withAttribute(CommonAttributes.USER_ID, user)
.valueSet(CommonAttributes.ITEM_ID);
}
return recommendWithSets(n, candidates, exclude);
}
代码示例来源:origin: lenskit/lenskit
.valueSet(CommonAttributes.ITEM_ID));
代码示例来源:origin: lenskit/lenskit
/**
* Get the IDs of the candidate neighbors for a user.
* @param user The user.
* @param userItems The user's rated items.
* @param targetItems The set of target items.
* @return The set of IDs of candidate neighbors.
*/
private LongSet findCandidateNeighbors(long user, LongSet userItems, LongCollection targetItems) {
LongSet users = new LongOpenHashSet(100);
LongIterator items;
if (userItems.size() < targetItems.size()) {
items = userItems.iterator();
} else {
items = targetItems.iterator();
}
while (items.hasNext()) {
LongSet iusers = dao.query(CommonTypes.RATING)
.withAttribute(CommonAttributes.ITEM_ID, items.nextLong())
.valueSet(CommonAttributes.USER_ID);
if (iusers != null) {
users.addAll(iusers);
}
}
users.remove(user);
return users;
}
代码示例来源:origin: org.lenskit/lenskit-core
/**
* Get the default exclude set for a user. The base implementation gets
* all the items they have interacted with.
*
* @param user The user ID.
* @return The set of items to exclude.
*/
protected LongSet getDefaultExcludes(long user) {
// FIXME Support things other than ratings
return dao.query(CommonTypes.RATING)
.withAttribute(CommonAttributes.USER_ID, user)
.valueSet(CommonAttributes.ITEM_ID);
}
代码示例来源:origin: org.lenskit/lenskit-core
@Override
protected LongList recommend(long user, int n, @Nullable LongSet candidates, @Nullable LongSet exclude) {
if (exclude == null) {
exclude = data.query(statistics.getEntityType())
.withAttribute(CommonAttributes.USER_ID, user)
.valueSet(CommonAttributes.ITEM_ID);
}
return recommendWithSets(n, candidates, exclude);
}
代码示例来源:origin: org.lenskit/lenskit-knn
/**
* Get the IDs of the candidate neighbors for a user.
* @param user The user.
* @param userItems The user's rated items.
* @param targetItems The set of target items.
* @return The set of IDs of candidate neighbors.
*/
private LongSet findCandidateNeighbors(long user, LongSet userItems, LongCollection targetItems) {
LongSet users = new LongOpenHashSet(100);
LongIterator items;
if (userItems.size() < targetItems.size()) {
items = userItems.iterator();
} else {
items = targetItems.iterator();
}
while (items.hasNext()) {
LongSet iusers = dao.query(CommonTypes.RATING)
.withAttribute(CommonAttributes.ITEM_ID, items.nextLong())
.valueSet(CommonAttributes.USER_ID);
if (iusers != null) {
users.addAll(iusers);
}
}
users.remove(user);
return users;
}
内容来源于网络,如有侵权,请联系作者删除!