LUCENE-3902: fix javadocs

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1304219 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Willnauer 2012-03-23 08:05:02 +00:00
parent adfac074ec
commit 6c73b26c93
2 changed files with 13 additions and 5 deletions

View File

@ -17,7 +17,6 @@ package org.apache.lucene.search.suggest;
* limitations under the License. * limitations under the License.
*/ */
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -57,6 +56,9 @@ public abstract class Lookup {
} }
} }
/**
* A simple char-by-char comparator for {@link CharSequence}
*/
public static final Comparator<CharSequence> CHARSEQUENCE_COMPARATOR = new CharSequenceComparator(); public static final Comparator<CharSequence> CHARSEQUENCE_COMPARATOR = new CharSequenceComparator();
private static class CharSequenceComparator implements Comparator<CharSequence> { private static class CharSequenceComparator implements Comparator<CharSequence> {
@ -79,8 +81,11 @@ public abstract class Lookup {
} }
/**
* A {@link PriorityQueue} collecting a fixed size of high priority {@link LookupResult}
*/
public static final class LookupPriorityQueue extends PriorityQueue<LookupResult> { public static final class LookupPriorityQueue extends PriorityQueue<LookupResult> {
// TODO: should we move this out of the interface into a utility class?
public LookupPriorityQueue(int size) { public LookupPriorityQueue(int size) {
super(size); super(size);
} }
@ -90,6 +95,10 @@ public abstract class Lookup {
return a.value < b.value; return a.value < b.value;
} }
/**
* Returns the top N results in descending order.
* @return the top N results in descending order.
*/
public LookupResult[] getResults() { public LookupResult[] getResults() {
int size = size(); int size = size();
LookupResult[] res = new LookupResult[size]; LookupResult[] res = new LookupResult[size];

View File

@ -19,9 +19,6 @@ package org.apache.lucene.search.suggest.tst;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -104,6 +101,7 @@ public class TSTLookup extends Lookup {
int maxCnt = Math.min(num, list.size()); int maxCnt = Math.min(num, list.size());
if (onlyMorePopular) { if (onlyMorePopular) {
LookupPriorityQueue queue = new LookupPriorityQueue(num); LookupPriorityQueue queue = new LookupPriorityQueue(num);
for (TernaryTreeNode ttn : list) { for (TernaryTreeNode ttn : list) {
queue.insertWithOverflow(new LookupResult(ttn.token, ((Number)ttn.val).longValue())); queue.insertWithOverflow(new LookupResult(ttn.token, ((Number)ttn.val).longValue()));
} }
@ -198,4 +196,5 @@ public class TSTLookup extends Lookup {
} }
return true; return true;
} }
} }