You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2011/05/05 00:20:11 UTC
svn commit: r1099625 - in /lucene/dev/branches/branch_3x: ./ lucene/
lucene/backwards/
lucene/src/java/org/apache/lucene/search/IndexSearcher.java solr/
Author: mikemccand
Date: Wed May 4 22:20:11 2011
New Revision: 1099625
URL: http://svn.apache.org/viewvc?rev=1099625&view=rev
Log:
LUCENE-2837: small code cleanup, merged back from trunk
Modified:
lucene/dev/branches/branch_3x/ (props changed)
lucene/dev/branches/branch_3x/lucene/ (props changed)
lucene/dev/branches/branch_3x/lucene/backwards/ (props changed)
lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
lucene/dev/branches/branch_3x/solr/ (props changed)
Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/search/IndexSearcher.java?rev=1099625&r1=1099624&r2=1099625&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/search/IndexSearcher.java Wed May 4 22:20:11 2011
@@ -400,7 +400,7 @@ public class IndexSearcher extends Searc
for (int i = 0; i < subReaders.length; i++) { // search each sub
runner.submit(
- new MultiSearcherCallableNoSort(lock, subSearchers[i], weight, filter, nDocs, hq, i, docStarts));
+ new MultiSearcherCallableNoSort(lock, subSearchers[i], weight, filter, nDocs, hq, docStarts[i]));
}
int totalHits = 0;
@@ -476,7 +476,7 @@ public class IndexSearcher extends Searc
final ExecutionHelper<TopFieldDocs> runner = new ExecutionHelper<TopFieldDocs>(executor);
for (int i = 0; i < subReaders.length; i++) { // search each sub
runner.submit(
- new MultiSearcherCallableWithSort(lock, subSearchers[i], weight, filter, nDocs, topCollector, sort, i, docStarts));
+ new MultiSearcherCallableWithSort(lock, subSearchers[i], weight, filter, nDocs, topCollector, sort, docStarts[i]));
}
int totalHits = 0;
float maxScore = Float.NEGATIVE_INFINITY;
@@ -673,20 +673,18 @@ public class IndexSearcher extends Searc
private final Weight weight;
private final Filter filter;
private final int nDocs;
- private final int i;
private final HitQueue hq;
- private final int[] starts;
+ private final int docBase;
public MultiSearcherCallableNoSort(Lock lock, IndexSearcher searchable, Weight weight,
- Filter filter, int nDocs, HitQueue hq, int i, int[] starts) {
+ Filter filter, int nDocs, HitQueue hq, int docBase) {
this.lock = lock;
this.searchable = searchable;
this.weight = weight;
this.filter = filter;
this.nDocs = nDocs;
this.hq = hq;
- this.i = i;
- this.starts = starts;
+ this.docBase = docBase;
}
public TopDocs call() throws IOException {
@@ -694,7 +692,7 @@ public class IndexSearcher extends Searc
final ScoreDoc[] scoreDocs = docs.scoreDocs;
for (int j = 0; j < scoreDocs.length; j++) { // merge scoreDocs into hq
final ScoreDoc scoreDoc = scoreDocs[j];
- scoreDoc.doc += starts[i]; // convert doc
+ scoreDoc.doc += docBase; // convert doc
//it would be so nice if we had a thread-safe insert
lock.lock();
try {
@@ -719,21 +717,19 @@ public class IndexSearcher extends Searc
private final Weight weight;
private final Filter filter;
private final int nDocs;
- private final int i;
private final TopFieldCollector hq;
- private final int[] starts;
+ private final int docBase;
private final Sort sort;
public MultiSearcherCallableWithSort(Lock lock, IndexSearcher searchable, Weight weight,
- Filter filter, int nDocs, TopFieldCollector hq, Sort sort, int i, int[] starts) {
+ Filter filter, int nDocs, TopFieldCollector hq, Sort sort, int docBase) {
this.lock = lock;
this.searchable = searchable;
this.weight = weight;
this.filter = filter;
this.nDocs = nDocs;
this.hq = hq;
- this.i = i;
- this.starts = starts;
+ this.docBase = docBase;
this.sort = sort;
}
@@ -783,7 +779,7 @@ public class IndexSearcher extends Searc
// iterate over the score docs and change their fields value
for (int j2 = 0; j2 < docs.scoreDocs.length; j2++) {
FieldDoc fd = (FieldDoc) docs.scoreDocs[j2];
- fd.fields[j] = Integer.valueOf(((Integer) fd.fields[j]).intValue() + starts[i]);
+ fd.fields[j] = Integer.valueOf(((Integer) fd.fields[j]).intValue() + docBase);
}
break;
}
@@ -791,7 +787,7 @@ public class IndexSearcher extends Searc
lock.lock();
try {
- hq.setNextReader(searchable.getIndexReader(), starts[i]);
+ hq.setNextReader(searchable.getIndexReader(), docBase);
hq.setScorer(fakeScorer);
for(ScoreDoc scoreDoc : docs.scoreDocs) {
fakeScorer.doc = scoreDoc.doc;
@@ -801,6 +797,7 @@ public class IndexSearcher extends Searc
} finally {
lock.unlock();
}
+
return docs;
}
}