1 | /******************************************************************************
|
---|
2 | *
|
---|
3 | * A component of the Greenstone digital library software from the New Zealand
|
---|
4 | * Digital Library Project at the # University of Waikato, New Zealand.
|
---|
5 | * Copyright (C) 2006 New Zealand Digital Library Project
|
---|
6 | *
|
---|
7 | * This program is free software; you can redistribute it and/or modify it
|
---|
8 | * under the terms of the GNU General Public License as published by the Free
|
---|
9 | * Software Foundation; either version 2 of the License, or (at your option)
|
---|
10 | * any later version.
|
---|
11 | *
|
---|
12 | * This program is distributed in the hope that it will be useful, but
|
---|
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
---|
14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
---|
15 | * for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License along
|
---|
18 | * with this program; if not, write to the Free Software Foundation, Inc.,
|
---|
19 | * 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
20 | *****************************************************************************/
|
---|
21 | /** @author jmt12, GSDL **/
|
---|
22 |
|
---|
23 | package org.nzdl.gsdl;
|
---|
24 |
|
---|
25 | /** Imports */
|
---|
26 | import org.apache.hadoop.io.Text;
|
---|
27 | import org.apache.hadoop.io.WritableComparable;
|
---|
28 | import org.apache.hadoop.io.WritableComparator;
|
---|
29 |
|
---|
30 | /** @class GSGroupingComparator
|
---|
31 | */
|
---|
32 | public class GSGroupingComparator
|
---|
33 | extends WritableComparator
|
---|
34 | {
|
---|
35 |
|
---|
36 | /** @function constructor
|
---|
37 | */
|
---|
38 | public GSGroupingComparator()
|
---|
39 | {
|
---|
40 | super(Text.class, true);
|
---|
41 | }
|
---|
42 | /** constructor **/
|
---|
43 |
|
---|
44 |
|
---|
45 | /** @function compare(WritableComparable, WritableComparable)
|
---|
46 | */
|
---|
47 | @Override
|
---|
48 | public int compare(WritableComparable w1, WritableComparable w2)
|
---|
49 | {
|
---|
50 | String s1 = w1.toString();
|
---|
51 | String[] s1_parts = s1.split(" ");
|
---|
52 | Text t1 = new Text(s1_parts[0]);
|
---|
53 | String s2 = w2.toString();
|
---|
54 | String[] s2_parts = s2.split(" ");
|
---|
55 | Text t2 = new Text(s2_parts[0]);
|
---|
56 | return t1.compareTo(t2);
|
---|
57 | }
|
---|
58 | /** compare(WritableComparable, WritableComparable) **/
|
---|
59 |
|
---|
60 | }
|
---|
61 | /** class GSGroupingComparator **/ |
---|