Last change
on this file since 166 was
166,
checked in by (none), 14 years ago
|
HadoopA51: imported git repository from github
|
File size:
1.0 KB
|
Line | |
---|
1 | package ro.pub.cs.pp.a51hadoop.algorithm.testing; |
---|
2 | |
---|
3 | import ro.pub.cs.pp.a51hadoop.algorithm.HashReducer; |
---|
4 | import ro.pub.cs.pp.a51hadoop.algorithm.ReducerGenerator; |
---|
5 | |
---|
6 | |
---|
7 | /* |
---|
8 | * A generator for DigitReducer functors. |
---|
9 | * |
---|
10 | */ |
---|
11 | public class DigitReducerGenerator implements ReducerGenerator |
---|
12 | { |
---|
13 | |
---|
14 | /* |
---|
15 | * All logic implemented in the generate() method. |
---|
16 | * |
---|
17 | * This generator can be reused to generate many sets of |
---|
18 | * objects as it does not hold any state information. |
---|
19 | */ |
---|
20 | public DigitReducerGenerator() { } |
---|
21 | |
---|
22 | /* |
---|
23 | * Generate @length distinct Reducer functors |
---|
24 | * @length - the number of Reducers to generate |
---|
25 | * @param - a parameter to be sent to the reducers |
---|
26 | * |
---|
27 | * @return an array of all Reducer objects created |
---|
28 | */ |
---|
29 | public HashReducer[] generate(int length, int param) |
---|
30 | { |
---|
31 | try |
---|
32 | { |
---|
33 | HashReducer[] r; |
---|
34 | |
---|
35 | r = new HashReducer[length]; |
---|
36 | for (int i = 0; i < length; i++) |
---|
37 | r[i] = new DigitReducer(i, param); |
---|
38 | |
---|
39 | return r; |
---|
40 | } |
---|
41 | catch(Exception e) |
---|
42 | { |
---|
43 | /* |
---|
44 | * Fallback to an empty list of reducers. |
---|
45 | */ |
---|
46 | return new HashReducer[0]; |
---|
47 | } |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
Note: See
TracBrowser
for help on using the repository browser.