protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, IDataModel dataModel) { var preferredItemIDsIterator = ((IEnumerable <long>)preferredItemIDs).GetEnumerator(); if (preferredItemIDs.Length > maxItems) { double samplingRate = (double)maxItems / preferredItemIDs.Length; log.Info("preferredItemIDs.Length {0}, samplingRate {1}", preferredItemIDs.Length, samplingRate); preferredItemIDsIterator = new SamplinglongPrimitiveIterator(preferredItemIDsIterator, samplingRate); } FastIDSet possibleItemsIDs = new FastIDSet(); while (preferredItemIDsIterator.MoveNext()) { long itemID = preferredItemIDsIterator.Current; IPreferenceArray prefs = dataModel.GetPreferencesForItem(itemID); int prefsLength = prefs.Length(); if (prefsLength > maxUsersPerItem) { var sampledPrefs = new FixedSizeSamplingIterator <IPreference>(maxUsersPerItem, prefs.GetEnumerator()); while (sampledPrefs.MoveNext()) { addSomeOf(possibleItemsIDs, dataModel.GetItemIDsFromUser(sampledPrefs.Current.GetUserID())); } } else { for (int i = 0; i < prefsLength; i++) { addSomeOf(possibleItemsIDs, dataModel.GetItemIDsFromUser(prefs.GetUserID(i))); } } } possibleItemsIDs.RemoveAll(preferredItemIDs); return(possibleItemsIDs); }
protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, DataModel dataModel) { IEnumerator <long> enumerator = ((IEnumerable <long>)preferredItemIDs).GetEnumerator(); if (preferredItemIDs.Length > this.maxItems) { double samplingRate = ((double)this.maxItems) / ((double)preferredItemIDs.Length); log.info("preferredItemIDs.Length {0}, samplingRate {1}", new object[] { preferredItemIDs.Length, samplingRate }); enumerator = new SamplingLongPrimitiveIterator(enumerator, samplingRate); } FastIDSet possibleItemIDs = new FastIDSet(); while (enumerator.MoveNext()) { long current = enumerator.Current; PreferenceArray array = dataModel.getPreferencesForItem(current); int num3 = array.length(); if (num3 > this.maxUsersPerItem) { FixedSizeSamplingIterator <Preference> iterator = new FixedSizeSamplingIterator <Preference>(this.maxUsersPerItem, array.GetEnumerator()); while (iterator.MoveNext()) { this.addSomeOf(possibleItemIDs, dataModel.getItemIDsFromUser(iterator.Current.getUserID())); } } else { for (int i = 0; i < num3; i++) { this.addSomeOf(possibleItemIDs, dataModel.getItemIDsFromUser(array.getUserID(i))); } } } possibleItemIDs.removeAll(preferredItemIDs); return(possibleItemIDs); }
protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, IDataModel dataModel) { var preferredItemIDsIterator = ((IEnumerable<long>)preferredItemIDs).GetEnumerator(); if (preferredItemIDs.Length > maxItems) { double samplingRate = (double) maxItems / preferredItemIDs.Length; log.Info("preferredItemIDs.Length {0}, samplingRate {1}", preferredItemIDs.Length, samplingRate); preferredItemIDsIterator = new SamplinglongPrimitiveIterator(preferredItemIDsIterator, samplingRate); } FastIDSet possibleItemsIDs = new FastIDSet(); while (preferredItemIDsIterator.MoveNext()) { long itemID = preferredItemIDsIterator.Current; IPreferenceArray prefs = dataModel.GetPreferencesForItem(itemID); int prefsLength = prefs.Length(); if (prefsLength > maxUsersPerItem) { var sampledPrefs = new FixedSizeSamplingIterator<IPreference>(maxUsersPerItem, prefs.GetEnumerator()); while (sampledPrefs.MoveNext()) { addSomeOf(possibleItemsIDs, dataModel.GetItemIDsFromUser(sampledPrefs.Current.GetUserID())); } } else { for (int i = 0; i < prefsLength; i++) { addSomeOf(possibleItemsIDs, dataModel.GetItemIDsFromUser(prefs.GetUserID(i))); } } } possibleItemsIDs.RemoveAll(preferredItemIDs); return possibleItemsIDs; }