-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchwithspecificReqMapper.java
157 lines (123 loc) · 2.81 KB
/
searchwithspecificReqMapper.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import java.io.IOException;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
public class searchwithspecificReqMapper extends MapReduceBase implements Mapper<LongWritable, Text, Text, Text>{
private static String date;
private static String fileformat;
private static String username;
private static String size;
private static String timestmp;
public void configure(JobConf job) {
date = (job.get("date"));
fileformat = (job.get("fileformat"));
username = (job.get("username"));
size = (job.get("size"));
timestmp = (job.get("timestmp"));
}
@Override
public void map(LongWritable key, Text value, OutputCollector<Text, Text> output, Reporter reporter)
throws IOException {
// TODO Auto-generated method stub
String line = value.toString();
String[] linee = line.split("\t");
String[] records =linee[1].split("###");
String path =records[0];
String format =linee[0];
String datee_timestamp =records[1];
String size1 =records[2];
String user =records[3];
String[] details_path =path.split("/");
String todatday=details_path[3];
boolean pathf =false;
boolean formatf =false;
boolean datee_timestampf =false;
boolean sizef =false;
boolean userf=false;
boolean todatdayf=false;
if(timestmp.equals("NA"))
{
datee_timestampf =false;
}
else
{
if(timestmp.startsWith(datee_timestamp))
{
datee_timestampf =false;
}
else
{
datee_timestampf =true;
}
}
if(date.equals("NA"))
{
todatdayf =false;
}
else
{
if(date.equals(todatday))
{
todatdayf =false;
}
else
{
todatdayf =true;
}
}
if(fileformat.equals("NA"))
{
formatf =false;
}
else
{
if(fileformat.equalsIgnoreCase(format.trim()))
{
formatf =false;
}
else
{
formatf =true;
}
}
if(username.equals("NA"))
{
userf =false;
}
else
{
if(username.equalsIgnoreCase(user))
{
userf =false;
}
else
{
userf =true;
}
}
if(size.equals("NA"))
{
sizef =false;
}
else
{
if(size.equals(size1))
{
sizef =false;
}
else
{
sizef =true;
}
}
if((sizef==false) && (userf==false) && (formatf==false) && (datee_timestampf==false))
{
output.collect(new Text(path), new Text(""));
}
System.out.println("************************************************************");
}
}