Index: trunk/lucene-search-3/src/main/java/org/wikimedia/lsearch/search/CachedSearchable.java |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | import org.apache.lucene.document.Document; |
9 | 9 | import org.apache.lucene.document.FieldSelector; |
10 | 10 | import org.apache.lucene.index.Term; |
| 11 | +import org.apache.lucene.search.Collector; |
11 | 12 | import org.apache.lucene.search.Explanation; |
12 | 13 | import org.apache.lucene.search.Filter; |
13 | 14 | import org.apache.lucene.search.HitCollector; |
— | — | @@ -43,7 +44,7 @@ |
44 | 45 | this.searchable = searchable; |
45 | 46 | log.debug("New cached searchable for "+searchable); |
46 | 47 | } |
47 | | - |
| 48 | + @Override |
48 | 49 | public void close() throws IOException { |
49 | 50 | log.debug("called close()"); |
50 | 51 | try{ |
— | — | @@ -54,7 +55,7 @@ |
55 | 56 | throw new IOException(e.getMessage()); |
56 | 57 | } |
57 | 58 | } |
58 | | - |
| 59 | + @Override |
59 | 60 | public Document doc(int i) throws IOException { |
60 | 61 | log.debug("called doc("+i+")"); |
61 | 62 | try{ |
— | — | @@ -76,7 +77,7 @@ |
77 | 78 | throw new IOException(e.getMessage()); |
78 | 79 | } |
79 | 80 | } |
80 | | - |
| 81 | + @Override |
81 | 82 | public Document[] docs(int[] i) throws IOException { |
82 | 83 | log.debug("called docs("+Arrays.toString(i)+")"); |
83 | 84 | try{ |
— | — | @@ -98,7 +99,7 @@ |
99 | 100 | throw new IOException(e.getMessage()); |
100 | 101 | } |
101 | 102 | } |
102 | | - |
| 103 | + @Override |
103 | 104 | public int docFreq(Term term) throws IOException { |
104 | 105 | log.debug("called docFreq("+term+")"); |
105 | 106 | log.warn("Should never call docFreq(Term), but docFreqs(Term[])"); |
— | — | @@ -111,7 +112,7 @@ |
112 | 113 | throw new IOException(e.getMessage()); |
113 | 114 | } |
114 | 115 | } |
115 | | - |
| 116 | + @Override |
116 | 117 | public int[] docFreqs(Term[] terms) throws IOException { |
117 | 118 | log.debug("called docFreqs("+Arrays.toString(terms)+")"); |
118 | 119 | try{ |
— | — | @@ -122,7 +123,7 @@ |
123 | 124 | throw new IOException(e.getMessage()); |
124 | 125 | } |
125 | 126 | } |
126 | | - |
| 127 | + @Override |
127 | 128 | public Explanation explain(Weight weight, int doc) throws IOException { |
128 | 129 | log.debug("called explaint("+weight+","+doc+")"); |
129 | 130 | try{ |
— | — | @@ -133,7 +134,7 @@ |
134 | 135 | throw new IOException(e.getMessage()); |
135 | 136 | } |
136 | 137 | } |
137 | | - |
| 138 | + @Override |
138 | 139 | public int maxDoc() throws IOException { |
139 | 140 | try{ |
140 | 141 | if(maxDocCached == -1){ |
— | — | @@ -148,7 +149,7 @@ |
149 | 150 | throw new IOException(e.getMessage()); |
150 | 151 | } |
151 | 152 | } |
152 | | - |
| 153 | + @Override |
153 | 154 | public Query rewrite(Query query) throws IOException { |
154 | 155 | log.debug("called rewrite("+query+")"); |
155 | 156 | try{ |
— | — | @@ -159,7 +160,8 @@ |
160 | 161 | throw new IOException(e.getMessage()); |
161 | 162 | } |
162 | 163 | } |
163 | | - |
| 164 | + |
| 165 | + @Override |
164 | 166 | public void search(Weight weight, Filter filter, HitCollector results) throws IOException { |
165 | 167 | log.debug("called search("+weight+","+filter+","+results+")"); |
166 | 168 | try{ |
— | — | @@ -170,7 +172,23 @@ |
171 | 173 | throw new IOException(e.getMessage()); |
172 | 174 | } |
173 | 175 | } |
| 176 | + |
| 177 | + @Override |
| 178 | + public void search(Weight weight, Filter filter, Collector collector) |
| 179 | + throws IOException { |
| 180 | + log.debug("called search("+weight+","+filter+","+collector+")"); |
| 181 | + try{ |
| 182 | + searchable.search(weight,filter,collector); |
| 183 | + } catch(Exception e){ |
| 184 | + log.error(e.getMessage(), e); |
| 185 | + SearcherCache.getInstance().reInitializeRemote(iid,host); |
| 186 | + throw new IOException(e.getMessage()); |
| 187 | + } |
| 188 | + |
| 189 | + } |
174 | 190 | |
| 191 | + |
| 192 | + @Override |
175 | 193 | public TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort) throws IOException { |
176 | 194 | log.debug("called search("+weight+","+filter+","+n+","+sort+")"); |
177 | 195 | try{ |
— | — | @@ -181,7 +199,7 @@ |
182 | 200 | throw new IOException(e.getMessage()); |
183 | 201 | } |
184 | 202 | } |
185 | | - |
| 203 | + @Override |
186 | 204 | public TopDocs search(Weight weight, Filter filter, int n) throws IOException { |
187 | 205 | log.debug("called search("+weight+","+filter+","+n+")"); |
188 | 206 | try{ |
— | — | @@ -197,6 +215,4 @@ |
198 | 216 | public String toString() { |
199 | 217 | return searchable.toString(); |
200 | 218 | } |
201 | | - |
202 | | - |
203 | 219 | } |