}
@Override
protected FastIDSet doGetCandidateItems(long[] preferredItemIDs, DataModel dataModel, boolean includeKnownItems)
throws TasteException {
LongPrimitiveIterator preferredItemIDsIterator = new LongPrimitiveArrayIterator(preferredItemIDs);
if (preferredItemIDs.length > maxItems) {
double samplingRate = (double) maxItems / preferredItemIDs.length;
// log.info("preferredItemIDs.length {}, samplingRate {}", preferredItemIDs.length, samplingRate);
preferredItemIDsIterator =
new SamplingLongPrimitiveIterator(preferredItemIDsIterator, samplingRate);
}
FastIDSet possibleItemsIDs = new FastIDSet();
while (preferredItemIDsIterator.hasNext()) {
long itemID = preferredItemIDsIterator.nextLong();
PreferenceArray prefs = dataModel.getPreferencesForItem(itemID);
int prefsLength = prefs.length();
if (prefsLength > maxUsersPerItem) {
Iterator<Preference> sampledPrefs =
new FixedSizeSamplingIterator<Preference>(maxUsersPerItem, prefs.iterator());