@Override public KeyIndex userIndex() { requireValid(); return data.getUserIndex(); }
@Override public KeyIndex itemIndex() { requireValid(); return data.getItemIndex(); }
/** * Create a preference domain builder with a specified minimum and maximum. * @param min The minimum preference. * @param max The maximum preference. */ public PreferenceDomainBuilder(double min, double max) { setMinimum(min); setMaximum(max); }
/** * Create a new preference domain builder. * @return A new preference domain builder. */ public static PreferenceDomainBuilder newBuilder() { return new PreferenceDomainBuilder(); }
/** * Build the packed rating data. This first moves records from the end to fill * any released but not reused slots. * * @return The packed rating data structure. */ @Override public PackedRatingData build() { repack(); trim(); return internalBuild(); } }
public double apply(long user, long item, double value) { return domain.clampValue(value); } }
/** * Create a new rating builder. * @return A new rating builder. */ public static RatingBuilder newBuilder() { return new RatingBuilder(); }
/** * Get the estimate for a getEntry. * @param pref The getEntry. * @return The estimate. */ public double get(RatingMatrixEntry pref) { return estimates[pref.getIndex()]; }
/** * Construct a new interaction statistics object. * @param dao The DAO. * @param type The entity type to count. * @return The statistics. */ public static InteractionStatistics create(DataAccessObject dao, EntityType type) { return new ISProvider(type, dao).get(); }
/** * Create a rating summary from a DAO. * @param dao The events. * @return The rating summary. */ public static RatingSummary create(DataAccessObject dao) { return new RatingSummaryProvider(dao).get(); }
/** * Create a new preference domain quantizer. * * @see PreferenceDomain#PreferenceDomain(double, double, double) */ @SuppressWarnings("unused") public PreferenceDomainQuantizer(double min, double max, double prec) { this(new PreferenceDomain(min, max, prec)); }
/** * Construct a new rating builder that is a copy of a particular rating. * @param r The rating to copy. * @return A rating builder that will initially build a copy of the specified rating. */ public static RatingBuilder copy(Rating r) { return r.copyBuilder(); }
/** * Construct a new interaction statistics object that counts ratings. * @param dao The DAO. * @return The rating statistics. */ public static InteractionStatistics create(DataAccessObject dao) { return create(dao, CommonTypes.RATING); }
/** * Query whether this getEntry is valid. Valid preferences point to * * @return {@code true} if this index is valid. */ public boolean isValid() { return index >= 0 && index < size(); }
/** * Get an indirect preference pointed at the specified index. * * @param index An index in the data pack. * @return A preference pointing at the index. This does no checking to make sure that * the preference is valid. */ public IndirectEntry getEntry(int index) { return new IndirectEntry(index); }
@Override public List<RatingMatrixEntry> getRatings() { return new PackedRatingCollection(data); }
public Rating rating(long uid, long iid, double rating, long timestamp) { return Rating.newBuilder() .setId(++entityId) .setUserId(uid) .setItemId(iid) .setRating(rating) .setTimestamp(timestamp) .build(); }