r110918 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110917‎ | r110918 | r110919 >
Date:07:25, 8 February 2012
Author:oren
Status:deferred
Tags:
Comment:
added unimplemented methods required to conform to Lucene 2.9.4 API
Modified paths:
  • /trunk/lucene-search-3/src/main/java/org/apache/lucene/search/MultiSearcherBase.java (modified) (history)
  • /trunk/lucene-search-3/src/main/java/org/apache/lucene/search/PositionalQuery.java (modified) (history)
  • /trunk/lucene-search-3/src/main/java/org/apache/lucene/search/RemoteSearchableMul.java (modified) (history)

Diff [purge]

Index: trunk/lucene-search-3/src/main/java/org/apache/lucene/search/MultiSearcherBase.java
@@ -17,17 +17,18 @@
1818 * limitations under the License.
1919 */
2020
21 -import org.apache.lucene.document.Document;
22 -import org.apache.lucene.document.FieldSelector;
23 -import org.apache.lucene.index.CorruptIndexException;
24 -import org.apache.lucene.index.Term;
25 -
2621 import java.io.IOException;
2722 import java.util.HashMap;
2823 import java.util.HashSet;
2924 import java.util.Map;
3025 import java.util.Set;
3126
 27+import org.apache.lucene.document.Document;
 28+import org.apache.lucene.document.FieldSelector;
 29+import org.apache.lucene.index.CorruptIndexException;
 30+import org.apache.lucene.index.IndexReader;
 31+import org.apache.lucene.index.Term;
 32+
3233 /** Implements search over a set of <code>Searchables</code>.
3334 *
3435 * <p>Applications usually need only call the inherited {@link #search(Query)}
@@ -103,10 +104,20 @@
104105 public TopDocs search(Weight weight,Filter filter,int n) {
105106 throw new UnsupportedOperationException();
106107 }
 108+
 109+ @Override
 110+ public void search(Weight weight, Filter filter, Collector results)
 111+ throws IOException {
 112+ throw new UnsupportedOperationException();
 113+
 114+ }
 115+
107116
108117 public TopFieldDocs search(Weight weight,Filter filter,int n,Sort sort) {
109118 throw new UnsupportedOperationException();
110119 }
 120+
 121+
111122 }
112123
113124
@@ -207,11 +218,11 @@
208219 public int maxDoc() throws IOException {
209220 return maxDoc;
210221 }
211 -
 222+
212223 public TopDocs search(Weight weight, Filter filter, int nDocs)
213224 throws IOException {
214225
215 - HitQueue hq = new HitQueue(nDocs);
 226+ HitQueue hq = new HitQueue(nDocs, false);
216227 int totalHits = 0;
217228
218229 for (int i = 0; i < searchables.length; i++) { // search each searcher
@@ -256,6 +267,8 @@
257268 break; // no more scores > minScore
258269 }
259270 }
 271+
 272+
260273
261274 ScoreDoc[] scoreDocs = new ScoreDoc[hq.size()];
262275 for (int i = hq.size() - 1; i >= 0; i--) // put docs in array
@@ -264,7 +277,61 @@
265278 return new TopFieldDocs (totalHits, scoreDocs, hq.getFields(), maxScore);
266279 }
267280
 281+ @Override
 282+ public void search(Weight weight, Filter filter, final Collector results)
 283+ throws IOException {
268284
 285+ for (int i = 0; i < searchables.length; i++) { // search each searcher
 286+
 287+ final int start=starts[i];
 288+
 289+ searchables[i].search(weight, filter, new Collector(){
 290+
 291+ private Scorer scorer;
 292+ @Override
 293+ public void setScorer(Scorer scorer) throws IOException {
 294+ this.scorer=scorer;
 295+
 296+ }
 297+
 298+ @Override
 299+ public void collect(int doc) throws IOException {
 300+ try{
 301+ results.collect(doc+start);
 302+ }catch(IOException e){
 303+ e.printStackTrace();
 304+ }
 305+
 306+ }
 307+
 308+ @Override
 309+ public void setNextReader(IndexReader reader, int docBase)
 310+ throws IOException {
 311+ // TODO Auto-generated method stub
 312+
 313+ }
 314+
 315+ @Override
 316+ public boolean acceptsDocsOutOfOrder() {
 317+ // TODO Auto-generated method stub
 318+ return false;
 319+ }
 320+
 321+ });
 322+ /*
 323+ TopDocs docs = searchables[i].search(weight, filter, nDocs);
 324+ totalHits += docs.totalHits; // update totalHits
 325+ ScoreDoc[] scoreDocs = docs.scoreDocs;
 326+ for (int j = 0; j < scoreDocs.length; j++) { // merge scoreDocs into hq
 327+ ScoreDoc scoreDoc = scoreDocs[j];
 328+ scoreDoc.doc += starts[i]; // convert doc
 329+ if(!hq.insert(scoreDoc))
 330+ break; // no more scores > minScore
 331+ */
 332+ }
 333+
 334+ }
 335+
269336 // inherit javadoc
270337 public void search(Weight weight, Filter filter, final HitCollector results)
271338 throws IOException {
@@ -361,4 +428,5 @@
362429 return rewrittenQuery.weight(cacheSim);
363430 }
364431
 432+
365433 }
Index: trunk/lucene-search-3/src/main/java/org/apache/lucene/search/PositionalQuery.java
@@ -151,7 +151,7 @@
152152 * @author rainman
153153 *
154154 */
155 - protected class PositionalWeight implements Weight//PhraseWeight
 155+ protected class PositionalWeight extends Weight//PhraseWeight
156156 {
157157
158158 private Similarity similarity;
@@ -177,6 +177,13 @@
178178 queryWeight *= queryNorm; // normalize query weight
179179 value = queryWeight * idf; // idf for document
180180 }
 181+
 182+ @Override
 183+ public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder,
 184+ boolean topScorer) throws IOException {
 185+
 186+ return scorer(reader) ;
 187+ }
181188
182189 public Scorer scorer(IndexReader reader) throws IOException {
183190 if (terms.size() == 0) // optimize zero-term case
@@ -293,6 +300,8 @@
294301 queryWeight = idf * getBoost(); // compute query weight
295302 return queryWeight * queryWeight; // square it
296303 }
 304+
 305+
297306 }
298307
299308 @Override
Index: trunk/lucene-search-3/src/main/java/org/apache/lucene/search/RemoteSearchableMul.java
@@ -47,6 +47,14 @@
4848 return local.maxDoc();
4949 }
5050
 51+
 52+ @Override
 53+ public void search(Weight weight, Filter filter, Collector results)
 54+ throws IOException {
 55+ local.search(weight, filter, results);
 56+
 57+ }
 58+
5159 public TopDocs search(Weight weight, Filter filter, int n) throws IOException {
5260 return local.search(weight, filter, n);
5361 }
@@ -88,4 +96,7 @@
8997 return local.doc(n,fieldSelector);
9098 }
9199
 100+
 101+
 102+
92103 }

Status & tagging log