-
Notifications
You must be signed in to change notification settings - Fork 0
/
KMeansReducerFinal.java
39 lines (34 loc) · 1.08 KB
/
KMeansReducerFinal.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
37
38
39
/*=============================================================================
| Assignment: Final Project - Multiple Document Summarization
| Author: Group7 - (Sampath, Ajay, Visesh)
| Grader: Walid Shalaby
|
| Course: ITCS 6190
| Instructor: Srinivas Akella
|
| Language: Java
| Version : 1.8.0_101
|
| Deficiencies: No logical errors.
*===========================================================================*/
import java.io.IOException;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.io.Text;
/*
* Writes corresponding cluster and respective filenames in each cluster.
* */
public class KMeansReducerFinal extends Reducer<Text, Text, Text, Text> {
@Override
protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
boolean first = true;
String fileName = "";
for (Text value : values) {
if (!first) {
fileName += ",";
}
fileName += value.toString();
first = false;
}
context.write(new Text("Cluster"), new Text(fileName));
}
}