Package org.grouplens.lenskit.data.event

Examples of org.grouplens.lenskit.data.event.RatingBuilder


     * Test method for {@link org.grouplens.lenskit.data.event.Ratings#itemRatingVector(java.util.Collection)}.
     */
    @Test
    public void testItemRatingVector() {
        Collection<Rating> ratings = new ArrayList<Rating>();
        RatingBuilder rb = new RatingBuilder();
        ratings.add(Ratings.make(7, 5, 3.5));
        ratings.add(Ratings.make(3, 5, 1.5));
        ratings.add(Ratings.make(8, 5, 2));
        SparseVector v = Ratings.itemRatingVector(ratings);
        assertEquals(3, v.size());
View Full Code Here


     * Read a rating from a buffer.
     * @param buf The buffer to read.
     * @return The rating.
     */
    public Rating readRating(ByteBuffer buf) {
        RatingBuilder rb = new RatingBuilder();
        rb.setUserId(readUserId(buf));
        rb.setItemId(readItemId(buf));
        double rating = buf.getDouble();
        if (!Double.isNaN(rating)) {
            rb.setRating(rating);
        }
        if (hasTimestamps()) {
            rb.setTimestamp(buf.getLong());
        }
        return rb.build();
    }
View Full Code Here

TOP

Related Classes of org.grouplens.lenskit.data.event.RatingBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.