4 * May 5, 2007 -- Trevor Strohman
6 * BSD License (http://www.galagosearch.org/license)
12 import galago
.tupleflow
.Reducer
;
13 import galago
.types
.DocumentLengthWordCount
;
14 import java
.io
.IOException
;
15 import java
.util
.ArrayList
;
16 import java
.util
.Collections
;
17 import java
.util
.List
;
23 public class PostingsReducer
implements Reducer
<DocumentLengthWordCount
> {
24 public ArrayList
<DocumentLengthWordCount
> reduce(List
<DocumentLengthWordCount
> input
) throws IOException
{
25 Collections
.sort(input
, new DocumentLengthWordCount().getOrder( "+document", "+word" ).lessThan() );
26 List
<DocumentLengthWordCount
> sorted
= input
;
28 DocumentLengthWordCount o
= null;
29 ArrayList
<DocumentLengthWordCount
> newList
= new ArrayList
<DocumentLengthWordCount
>();
31 for( DocumentLengthWordCount wc
: input
) {
32 if( o
!= null && wc
.word
.equals(o
.word
) && wc
.document
.equals(o
.document
) ) {