List of usage examples for org.apache.mahout.math VarIntWritable VarIntWritable
public VarIntWritable()
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 a va 2 s . com } 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); } }