-
Notifications
You must be signed in to change notification settings - Fork 0
/
RatingFilter.java
36 lines (31 loc) · 980 Bytes
/
RatingFilter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package src.mrsim;
import java.util.ArrayList;
import java.util.List;
/**
* Example of a RatingFilter that does nothing at the moment.
* Your task is to finish the constructor, so that the user id can be configured,
* and to implement the filter method so that all ratings of the given user are filtered.
* The filter method shall return a Record that contains a key and a rating value
* for further processing by our MR-simulator.
*/
public class RatingFilter extends Filter<String, String, Integer>{
String userid="";
public RatingFilter(String search_key) {
// to be done
this.userid = search_key;
}
public Record<String, Integer> filter ( String line ) {
// to be done
String[] uid=line.split("\t");
if(userid.equals(uid[0]))
{
int i =Integer.parseInt(uid[2]);
Record<String,Integer> rec = new Record(userid,i);
return rec;
}
else
{
return null;
}
}
}