move fill to TermStatsQueue (which was pkg-private, so the static method wasnt useful anyway)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1329013 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-04-23 00:50:34 +00:00
parent 46b66c5b71
commit c8b4f6d473
1 changed files with 13 additions and 14 deletions

View File

@ -123,7 +123,7 @@ public class HighFreqTerms {
if (terms != null) {
TermsEnum termsEnum = terms.iterator(null);
tiq = new TermStatsQueue(numTerms);
fillQueue(termsEnum, tiq, field);
tiq.fill(field, termsEnum);
}
} else {
Fields fields = MultiFields.getFields(reader);
@ -137,7 +137,7 @@ public class HighFreqTerms {
if (field != null) {
Terms terms = fieldsEnum.terms();
if (terms != null) {
fillQueue(terms.iterator(null), tiq, field);
tiq.fill(field, terms.iterator(null));
}
} else {
break;
@ -211,18 +211,6 @@ public class HighFreqTerms {
return totalTF[0];
}
public static void fillQueue(TermsEnum termsEnum, TermStatsQueue tiq, String field) throws Exception {
while (true) {
BytesRef term = termsEnum.next();
if (term != null) {
tiq.insertWithOverflow(new TermStats(field, term, termsEnum.docFreq()));
} else {
break;
}
}
}
}
/**
@ -257,4 +245,15 @@ final class TermStatsQueue extends PriorityQueue<TermStats> {
protected boolean lessThan(TermStats termInfoA, TermStats termInfoB) {
return termInfoA.docFreq < termInfoB.docFreq;
}
protected void fill(String field, TermsEnum termsEnum) throws IOException {
while (true) {
BytesRef term = termsEnum.next();
if (term != null) {
insertWithOverflow(new TermStats(field, term, termsEnum.docFreq()));
} else {
break;
}
}
}
}