Example usage for org.apache.mahout.cf.taste.hadoop.item VectorOrPrefWritable set

List of usage examples for org.apache.mahout.cf.taste.hadoop.item VectorOrPrefWritable set

Introduction

In this page you can find the example usage for org.apache.mahout.cf.taste.hadoop.item VectorOrPrefWritable set.

Prototype

public void set(long userID, float value) 

Source Link

Usage

From source file:nl.gridline.zieook.inx.movielens.UserVectorSplitterMapper.java

License:Apache License

@Override
protected void map(VarLongWritable key, VectorWritable value, Context context)
        throws IOException, InterruptedException {
    long userID = key.get();
    if (usersToRecommendFor != null && !usersToRecommendFor.contains(userID)) {
        return;/* w w w . j av  a2s .c  o  m*/
    }
    Vector userVector = maybePruneUserVector(value.get());
    Iterator<Vector.Element> it = userVector.iterateNonZero();
    VarIntWritable itemIndexWritable = new VarIntWritable();
    VectorOrPrefWritable vectorOrPref = new VectorOrPrefWritable();
    while (it.hasNext()) {
        Vector.Element e = it.next();
        itemIndexWritable.set(e.index());
        vectorOrPref.set(userID, (float) e.get());
        context.write(itemIndexWritable, vectorOrPref);
    }
}