Example usage for org.apache.mahout.math VarIntWritable set

List of usage examples for org.apache.mahout.math VarIntWritable set

Introduction

In this page you can find the example usage for org.apache.mahout.math VarIntWritable set.

Prototype

public void set(int 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;//from   w w w.  jav a 2s. co  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);
    }
}