I have part of the code but don't know how to perform on the Eclipse answer!
1. The public class AggregateAndRecommendReducer extends Reducer
.
Public viod reduce (VarLongWritable key Iterable
The Vector recommendationVector=null;
For (VectorWritable VectorWritable: values) {
RecommendationVector=recommendationVector==null?
VectorWritable. The get ();
RecommendationVector. Plus (bectorWritable. The get ());
}
Queue
Iterator
While (recommendationVectorIterator. HasNext ()) {
The vector. The Element Element=recommendationVectorIterator. Next ();
Int index=element. The index ();
A float value=https://bbs.csdn.net/topics/(float) element. The get ();
If (topItems. The size () & lt; RecommendationsPerUser) {
TopItems. Add (new GenericRecommendedItem (indexItemIDMap. Get (index), value));
}
Else if (value> TopItems. Peek (). The getValue ()) {
TopItems. Add (new GenericRecommendedItem (indexItemIDMap. Get (index), value));
TopItems. Poll ();
}
}
List
Recommendations. AddAll (topItems);
Collections. Sort (recommendations, ByValueRecommendedItemComparator getInstance ());
Context. Write (key,
The new
RecommendedItemsWritable (recommendations));
}
}
2. The public class AggregateCombiner extends Reducer
The Vector partial=null;
For (VectorWritable VectorWritable: values) {
Partial=partial==null?
VectorWritable. The get () : partial. Plus (vectorWritable. The get ());
}
Context. Write (key, new VectorWritable (partial));
}
}
3. The public class CooccurrenceColumnWrapperMapper extends Mapper
Public void map (IntWritable key, VectorWritable value, Context Context) throws IOException, IniterruptedException {
Context. Write (key, new VectorOrPrefWritable (value. The get ()));
}
}
4. The public class PartialMultiplyMapper extends Mapper
Public void map (IntWritable key, VectorAndPrefsWritable VectorAndPrefsWritable, Context Context) throws IOException, InterruptedException {
The Vector cooccurrenceColumn=vectorAndPrefsWritable. GetVector ();
List
List
for (int i=0; I<=userIDs. The size (); I++) {
Long userID=userIDs. Get (I);
Float prefValue=https://bbs.csdn.net/topics/prefValues.get (I);
The Vector partialProduct=cooccurrenceColumn. Times (prefValue);
Context. Write (new VarLongWritable (userID), new VectorWritable (partialProduct));
}
}
}
5. The public class UserVectorSplitterMapper extends Mapper
Public void map (VarLongWritable key, VectorWritable key, the Context Context) throws IOException, InterruptedException {
Long userID=key. The get ();
The Vector userVector=value. The get ();
Iterator
IntWritable itemIndexWritable=new IntWritable ();
While (it. HasNext ()) {
Vector Element e=it, next ();
Int itemIndex=e.i ndex ();
Float preferenceValue=https://bbs.csdn.net/topics/(float) um participant et ();
ItemIndexWritable. Set (itemIndex);
Context. Write (itemIndexWritable, new VectorOrPrefWritable (userID, preferenceValue));
}
}
}
6. Public UserVectorToCooccurrenceMapper extends Mapper
Public void map (VarLongWritable userID, VectorWritable userVector, Context Context) throws IOException, InterruptedException {Iterator
While (it. HasNext ()) {
Int index1=it. Next (). The index ();
Iterator
While (it2. HasNext ()) {
Int index2=it2. Next (0. The index ();
The context. Write (new IntWritable (index1), new IntWritable (index2));
}
}
}
7.
Public UserVectorToCooccurrenceReducer extends Reducer
Public void the reduce (Intwritable itemIndex1 Iterable
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull