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

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

Introduction

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

Prototype

public VectorOrPrefWritable() 

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;/*from   w w w  .ja  va2  s. 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);
    }
}