Example usage for org.apache.mahout.cf.taste.hadoop RecommendedItemsWritable getRecommendedItems

List of usage examples for org.apache.mahout.cf.taste.hadoop RecommendedItemsWritable getRecommendedItems

Introduction

In this page you can find the example usage for org.apache.mahout.cf.taste.hadoop RecommendedItemsWritable getRecommendedItems.

Prototype

public List<RecommendedItem> getRecommendedItems() 

Source Link

Usage

From source file:nl.gridline.zieook.inx.movielens.hbase.UserRecommendationsStoreMap.java

License:Apache License

protected void map(VarLongWritable key, RecommendedItemsWritable value, Context context)
        throws IOException, InterruptedException {
    // <UserId, [item,value]>
    // the in the recommendations are already sorted! - this makes writing them easy

    List<RecommendedItem> recommendations = value.getRecommendedItems();
    int rank = 1;
    Put put = new Put(RowKeys.getRecommendationKey(collection, recommender, key.get()));
    for (RecommendedItem el : recommendations) {
        byte[] data = nl.gridline.zieook.model.Recommend.getRecommendation(el.getItemID(), rank, el.getValue());
        put.add(RECOMMENDATION_COLUMN, Bytes.toBytes(rank), data);
        rank++;/*  w  w  w .j  ava  2s  . c  om*/
    }
    context.write(new LongWritable(key.get()), put);

}