pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / grouping / src / java / org / apache / lucene / search / grouping / AbstractAllGroupsCollector.java
1 package org.apache.lucene.search.grouping;
2
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one or more
5  * contributor license agreements.  See the NOTICE file distributed with
6  * this work for additional information regarding copyright ownership.
7  * The ASF licenses this file to You under the Apache License, Version 2.0
8  * (the "License"); you may not use this file except in compliance with
9  * the License.  You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 import org.apache.lucene.search.Collector;
21 import org.apache.lucene.search.Scorer;
22 import org.apache.lucene.util.BytesRef;
23
24 import java.io.IOException;
25 import java.util.Collection;
26
27 /**
28  * A collector that collects all groups that match the
29  * query. Only the group value is collected, and the order
30  * is undefined.  This collector does not determine
31  * the most relevant document of a group.
32  *
33  * <p/>
34  * This is an abstract version. Concrete implementations define
35  * what a group actually is and how it is internally collected.
36  *
37  * @lucene.experimental
38  */
39 public abstract class AbstractAllGroupsCollector<GROUP_VALUE_TYPE> extends Collector {
40
41   /**
42    * Returns the total number of groups for the executed search.
43    * This is a convenience method. The following code snippet has the same effect: <pre>getGroups().size()</pre>
44    *
45    * @return The total number of groups for the executed search
46    */
47   public int getGroupCount() {
48     return getGroups().size();
49   }
50
51   /**
52    * Returns the group values
53    * <p/>
54    * This is an unordered collections of group values. For each group that matched the query there is a {@link BytesRef}
55    * representing a group value.
56    *
57    * @return the group values
58    */
59   public abstract Collection<GROUP_VALUE_TYPE> getGroups();
60
61   // Empty not necessary
62   public void setScorer(Scorer scorer) throws IOException {}
63
64   public boolean acceptsDocsOutOfOrder() {
65     return true;
66   }
67 }