## org.apache.mahout.cf.taste.hadoop.item
Class ToUserVectorsReducer

    java.lang.Object
      org.apache.hadoop.mapreduce.Reducer<VarLongWritable,VarLongWritable,VarLongWritable,VectorWritable>
          org.apache.mahout.cf.taste.hadoop.item.ToUserVectorsReducer

    public final class ToUserVectorsReducer

extends org.apache.hadoop.mapreduce.Reducer<VarLongWritable,VarLongWritable,VarLongWritable,VectorWritable>

# Input

Takes user IDs as `VarLongWritable` mapped to all associated item IDs and preference values, as `EntityPrefWritable`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 `TasteHadoopUtils.idToIndex(long)`. The mapping is remembered for later with a combination of `ItemIDIndexMapper` and `ItemIDIndexReducer`.

Nested Class Summary
`static class` `ToUserVectorsReducer.Counters`

Nested classes/interfaces inherited from class org.apache.hadoop.mapreduce.Reducer
`org.apache.hadoop.mapreduce.Reducer.Context`

Field Summary
`static String` `MIN_PREFERENCES_PER_USER`

Constructor Summary
`ToUserVectorsReducer()`

Method Summary
`protected void` `reduce(VarLongWritable userID, Iterable<VarLongWritable> itemPrefs, org.apache.hadoop.mapreduce.Reducer.Context context)`
`protected void` `setup(org.apache.hadoop.mapreduce.Reducer.Context ctx)`

Methods inherited from class org.apache.hadoop.mapreduce.Reducer
`cleanup, run`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MIN_PREFERENCES_PER_USER

    public static final String MIN_PREFERENCES_PER_USER

Constructor Detail

### ToUserVectorsReducer

    public ToUserVectorsReducer()

Method Detail

### setup

    protected void setup(org.apache.hadoop.mapreduce.Reducer.Context ctx)
                  throws IOException,
                         InterruptedException

  Overrides:
    `setup` in class `org.apache.hadoop.mapreduce.Reducer<VarLongWritable,VarLongWritable,VarLongWritable,VectorWritable>`
  Throws:
    `IOException`
    `InterruptedException`

### reduce

    protected void reduce(VarLongWritable userID,
                          Iterable<VarLongWritable> itemPrefs,
                          org.apache.hadoop.mapreduce.Reducer.Context context)
                   throws IOException,
                          InterruptedException

  Overrides:
    `reduce` in class `org.apache.hadoop.mapreduce.Reducer<VarLongWritable,VarLongWritable,VarLongWritable,VectorWritable>`
  Throws:
    `IOException`
    `InterruptedException`

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.