Package org.apache.lucene.util.fst
Class Util.TopNSearcher<T>
- java.lang.Object
-
- org.apache.lucene.util.fst.Util.TopNSearcher<T>
-
- Enclosing class:
- Util
public static class Util.TopNSearcher<T> extends java.lang.ObjectUtility class to find top N shortest paths from start point(s).
-
-
Field Summary
Fields Modifier and Type Field Description private FST.BytesReaderbytesReaderprivate java.util.Comparator<T>comparatorprivate FST<T>fstprivate intmaxQueueDepthprivate java.util.Comparator<Util.FSTPath<T>>pathComparator(package private) java.util.TreeSet<Util.FSTPath<T>>queueprivate FST.Arc<T>scratchArcprivate inttopN
-
Constructor Summary
Constructors Constructor Description TopNSearcher(FST<T> fst, int topN, int maxQueueDepth, java.util.Comparator<T> comparator)Creates an unbounded TopNSearcherTopNSearcher(FST<T> fst, int topN, int maxQueueDepth, java.util.Comparator<T> comparator, java.util.Comparator<Util.FSTPath<T>> pathComparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanacceptPartialPath(Util.FSTPath<T> path)Override this to prevent considering a path before it's completeprotected booleanacceptResult(Util.FSTPath<T> path)protected booleanacceptResult(IntsRef input, T output)protected voidaddIfCompetitive(Util.FSTPath<T> path)voidaddStartPaths(FST.Arc<T> node, T startOutput, boolean allowEmptyString, IntsRefBuilder input)voidaddStartPaths(FST.Arc<T> node, T startOutput, boolean allowEmptyString, IntsRefBuilder input, float boost, java.lang.CharSequence context, int payload)Adds all leaving arcs, including 'finished' arc, if the node is final, from this node into the queue.Util.TopResults<T>search()
-
-
-
Field Detail
-
bytesReader
private final FST.BytesReader bytesReader
-
topN
private final int topN
-
maxQueueDepth
private final int maxQueueDepth
-
comparator
private final java.util.Comparator<T> comparator
-
pathComparator
private final java.util.Comparator<Util.FSTPath<T>> pathComparator
-
queue
java.util.TreeSet<Util.FSTPath<T>> queue
-
-
Constructor Detail
-
TopNSearcher
public TopNSearcher(FST<T> fst, int topN, int maxQueueDepth, java.util.Comparator<T> comparator)
Creates an unbounded TopNSearcher- Parameters:
fst- theFSTto search ontopN- the number of top scoring entries to retrievemaxQueueDepth- the maximum size of the queue of possible top entriescomparator- the comparator to select the top N
-
TopNSearcher
public TopNSearcher(FST<T> fst, int topN, int maxQueueDepth, java.util.Comparator<T> comparator, java.util.Comparator<Util.FSTPath<T>> pathComparator)
-
-
Method Detail
-
addIfCompetitive
protected void addIfCompetitive(Util.FSTPath<T> path)
-
addStartPaths
public void addStartPaths(FST.Arc<T> node, T startOutput, boolean allowEmptyString, IntsRefBuilder input) throws java.io.IOException
- Throws:
java.io.IOException
-
addStartPaths
public void addStartPaths(FST.Arc<T> node, T startOutput, boolean allowEmptyString, IntsRefBuilder input, float boost, java.lang.CharSequence context, int payload) throws java.io.IOException
Adds all leaving arcs, including 'finished' arc, if the node is final, from this node into the queue.- Throws:
java.io.IOException
-
search
public Util.TopResults<T> search() throws java.io.IOException
- Throws:
java.io.IOException
-
acceptResult
protected boolean acceptResult(Util.FSTPath<T> path)
-
acceptPartialPath
protected boolean acceptPartialPath(Util.FSTPath<T> path)
Override this to prevent considering a path before it's complete
-
-