List of usage examples for org.apache.mahout.cf.taste.hadoop.item VectorOrPrefWritable getValue
public float getValue()
From source file:com.skp.experiment.common.mapreduce.ToVectorAndPrefReducer.java
License:Apache License
@Override protected void reduce(IntWritable key, Iterable<VectorOrPrefWritable> values, Context context) throws IOException, InterruptedException { List<Long> userIDs = Lists.newArrayList(); List<Float> prefValues = Lists.newArrayList(); Vector similarityMatrixColumn = null; for (VectorOrPrefWritable value : values) { if (value.getVector() == null) { // Then this is going into list userIDs.add(value.getUserID()); prefValues.add(value.getValue()); } else {/*w w w .j a va2 s .c o m*/ // Then this is going into vector if (similarityMatrixColumn != null) { throw new IllegalStateException(" " + key.get()); } similarityMatrixColumn = value.getVector(); } } if (similarityMatrixColumn == null) { return; } VectorAndPrefsWritable vectorAndPrefs = new VectorAndPrefsWritable(similarityMatrixColumn, userIDs, prefValues); context.write(key, vectorAndPrefs); }