LUCENE-2837: small code cleanup

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1055595 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-01-05 19:27:51 +00:00
parent c29b449d42
commit acd9519e59
1 changed files with 11 additions and 15 deletions

View File

@ -371,7 +371,7 @@ public class IndexSearcher {
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;
@ -440,7 +440,7 @@ public class IndexSearcher {
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, hq, sort, i, docStarts));
new MultiSearcherCallableWithSort(lock, subSearchers[i], weight, filter, nDocs, hq, sort, docStarts[i]));
}
int totalHits = 0;
float maxScore = Float.NEGATIVE_INFINITY;
@ -626,20 +626,18 @@ public class IndexSearcher {
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 {
@ -647,7 +645,7 @@ public class IndexSearcher {
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 {
@ -672,21 +670,19 @@ public class IndexSearcher {
private final Weight weight;
private final Filter filter;
private final int nDocs;
private final int i;
private final FieldDocSortedHitQueue 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, FieldDocSortedHitQueue hq, Sort sort, int i, int[] starts) {
Filter filter, int nDocs, FieldDocSortedHitQueue 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;
}
@ -700,7 +696,7 @@ public class IndexSearcher {
// 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;
}
@ -716,7 +712,7 @@ public class IndexSearcher {
final ScoreDoc[] scoreDocs = docs.scoreDocs;
for (int j = 0; j < scoreDocs.length; j++) { // merge scoreDocs into hq
final FieldDoc fieldDoc = (FieldDoc) scoreDocs[j];
fieldDoc.doc += starts[i]; // convert doc
fieldDoc.doc += docBase; // convert doc
//it would be so nice if we had a thread-safe insert
lock.lock();
try {