/** * Gets a collection of items which should be recommended for a user * * @param userId ID of a user we are interested in * @return if a userItemFile option is specified, and that file contains at least one item ID for the user, * then this method returns a {@link FastIDSet} object populated with item IDs. Otherwise, this * method returns an empty set. */ public FastIDSet getItemsToRecommendForUser(Long userId) { if (isUserItemFilterSpecified() && userItemFilter.containsKey(userId)) { return userItemFilter.get(userId); } else { return emptySet; } }
/** * Gets a collection of items which should be recommended for a user * * @param userId ID of a user we are interested in * @return if a userItemFile option is specified, and that file contains at least one item ID for the user, * then this method returns a {@link FastIDSet} object populated with item IDs. Otherwise, this * method returns an empty set. */ public FastIDSet getItemsToRecommendForUser(Long userId) { if (isUserItemFilterSpecified() && userItemFilter.containsKey(userId)) { return userItemFilter.get(userId); } else { return emptySet; } }
private void readUserItemFilterIfNeeded() throws IOException { if (!isUserItemFilterSpecified() && isUserItemFileSpecified()) { userItemFilter = readUserItemFilter(userItemFile); } }
private void readUserItemFilterIfNeeded() throws IOException { if (!isUserItemFilterSpecified() && isUserItemFileSpecified()) { userItemFilter = readUserItemFilter(userItemFile); } }
/** * Reads user ids and item ids from files specified in a job configuration * * @throws IOException if an error occurs during file read operation * * @throws IllegalStateException if userItemFile option is specified together with usersFile or itemsFile */ public void readIDs() throws IOException, IllegalStateException { if (isUserItemFileSpecified()) { readUserItemFilterIfNeeded(); } if (isUsersFileSpecified() || isUserItemFilterSpecified()) { readUserIds(); } if (isItemsFileSpecified() || isUserItemFilterSpecified()) { readItemIds(); } }
/** * Reads user ids and item ids from files specified in a job configuration * * @throws IOException if an error occurs during file read operation * * @throws IllegalStateException if userItemFile option is specified together with usersFile or itemsFile */ public void readIDs() throws IOException, IllegalStateException { if (isUserItemFileSpecified()) { readUserItemFilterIfNeeded(); } if (isUsersFileSpecified() || isUserItemFilterSpecified()) { readUserIds(); } if (isItemsFileSpecified() || isUserItemFilterSpecified()) { readItemIds(); } }
FastIDSet itemsForUser = null; if (idReader != null && idReader.isUserItemFilterSpecified()) { itemsForUser = idReader.getItemsToRecommendForUser(userID.get());
FastIDSet itemsForUser = null; if (idReader != null && idReader.isUserItemFilterSpecified()) { itemsForUser = idReader.getItemsToRecommendForUser(userID.get());