org.apache.mahout.cf.taste.hadoop.item
Class ToUserVectorReducer
java.lang.Object
org.apache.hadoop.mapred.MapReduceBase
org.apache.mahout.cf.taste.hadoop.item.ToUserVectorReducer
- All Implemented Interfaces:
- java.io.Closeable, org.apache.hadoop.mapred.JobConfigurable, org.apache.hadoop.mapred.Reducer<org.apache.hadoop.io.LongWritable,ItemPrefWritable,org.apache.hadoop.io.LongWritable,VectorWritable>
public final class ToUserVectorReducer
- extends org.apache.hadoop.mapred.MapReduceBase
- implements org.apache.hadoop.mapred.Reducer<org.apache.hadoop.io.LongWritable,ItemPrefWritable,org.apache.hadoop.io.LongWritable,VectorWritable>
Input
Takes user IDs as LongWritable
mapped to all associated item IDs and preference values, as
ItemPrefWritable
s.
Output
The same user ID mapped to a RandomAccessSparseVector
representation of the same item IDs and
preference values. Item IDs are used as vector indexes; they are hashed into ints to work as indexes with
ItemIDIndexMapper.idToIndex(long)
. The mapping is remembered for later with a combination of
ItemIDIndexMapper
and ItemIDIndexReducer
.
The number of non-default elements actually retained in the user vector is capped at
MAX_PREFS_CONSIDERED
.
Method Summary |
void |
reduce(org.apache.hadoop.io.LongWritable userID,
java.util.Iterator<ItemPrefWritable> itemPrefs,
org.apache.hadoop.mapred.OutputCollector<org.apache.hadoop.io.LongWritable,VectorWritable> output,
org.apache.hadoop.mapred.Reporter reporter)
|
Methods inherited from class org.apache.hadoop.mapred.MapReduceBase |
close, configure |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.hadoop.mapred.JobConfigurable |
configure |
Methods inherited from interface java.io.Closeable |
close |
MAX_PREFS_CONSIDERED
public static final int MAX_PREFS_CONSIDERED
- See Also:
- Constant Field Values
ToUserVectorReducer
public ToUserVectorReducer()
reduce
public void reduce(org.apache.hadoop.io.LongWritable userID,
java.util.Iterator<ItemPrefWritable> itemPrefs,
org.apache.hadoop.mapred.OutputCollector<org.apache.hadoop.io.LongWritable,VectorWritable> output,
org.apache.hadoop.mapred.Reporter reporter)
throws java.io.IOException
- Specified by:
reduce
in interface org.apache.hadoop.mapred.Reducer<org.apache.hadoop.io.LongWritable,ItemPrefWritable,org.apache.hadoop.io.LongWritable,VectorWritable>
- Throws:
java.io.IOException
Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.