public class BoostSet
extends Object
Modifier and Type | Class and Description |
---|---|
private class |
BoostSet.DocIter
Iterates all the document keys in an index
|
private class |
BoostSet.LineIter
Iterates all the lines in a boost file
|
Modifier and Type | Field and Description |
---|---|
private float[] |
boostByDoc
Set of boost values, one per document ID
|
private static WeakHashMap |
cache
Cached data.
|
private static float |
DEFAULT_MARKER
Marker for the default value
|
private String |
field
Field to find document keys in
|
private int |
nWarnings
Number of warnings emitted so far.
|
Modifier | Constructor and Description |
---|---|
private |
BoostSet(IndexReader indexReader,
File inFile,
String field)
Do not construct directly; use
getCachedSet(IndexReader, File, String)
instead. |
Modifier and Type | Method and Description |
---|---|
float |
getBoost(int docId,
float defaultBoost)
Get the boost factor associated with the given document, or the default
boost value if not found.
|
static BoostSet |
getCachedSet(IndexReader indexReader,
File inFile,
String field)
Retrieves BoostSet for a given File from a given reader.
|
private void |
warn(String msg)
If less than 10 warnings have been emitted, we print this one out.
|
private static WeakHashMap cache
private String field
private int nWarnings
private float[] boostByDoc
private static float DEFAULT_MARKER
private BoostSet(IndexReader indexReader, File inFile, String field) throws IOException
getCachedSet(IndexReader, File, String)
instead. Constructs a BoostSet by reading a file containing document
key -> boost factor mappings, and correlating it with the keys in the
given index reader.IOException
public static BoostSet getCachedSet(IndexReader indexReader, File inFile, String field) throws IOException
indexReader
- Index to correlate the data toinFile
- Which file to readfield
- Field used to key boost valuesIOException
public final float getBoost(int docId, float defaultBoost)
docId
- Document ID to look updefaultBoost
- What to return if not foundprivate void warn(String msg)
msg
- The message to emit