Class LongValuesSource
- java.lang.Object
-
- org.apache.lucene.search.LongValuesSource
-
- All Implemented Interfaces:
SegmentCacheable
- Direct Known Subclasses:
LongValuesSource.ConstantLongValuesSource
public abstract class LongValuesSource extends Object implements SegmentCacheable
Base class for producingLongValuesTo obtain a
LongValuesobject for a leaf reader, clients should callrewrite(IndexSearcher)against the top-level searcher, and thengetValues(LeafReaderContext, DoubleValues).LongValuesSource objects for long and int-valued NumericDocValues fields can be obtained by calling
fromLongField(String)andfromIntField(String).To obtain a LongValuesSource from a float or double-valued NumericDocValues field, use
DoubleValuesSource.fromFloatField(String)orDoubleValuesSource.fromDoubleField(String)and then callDoubleValuesSource.toLongValuesSource().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLongValuesSource.ConstantLongValuesSourceA ConstantLongValuesSource that always returns a constant value
-
Constructor Summary
Constructors Constructor Description LongValuesSource()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static LongValuesSourceconstant(long value)Creates a LongValuesSource that always returns a constant valueabstract booleanequals(Object obj)static LongValuesSourcefromIntField(String field)Creates a LongValuesSource that wraps an int-valued fieldstatic LongValuesSourcefromLongField(String field)Creates a LongValuesSource that wraps a long-valued fieldSortFieldgetSortField(boolean reverse)Create a sort field based on the value of this producerabstract LongValuesgetValues(LeafReaderContext ctx, DoubleValues scores)Returns aLongValuesinstance for the passed-in LeafReaderContext and scoresabstract inthashCode()abstract booleanneedsScores()Return true if document scores are needed to calculate valuesabstract LongValuesSourcerewrite(IndexSearcher searcher)Return a LongValuesSource specialised for the given IndexSearcherDoubleValuesSourcetoDoubleValuesSource()Convert to a DoubleValuesSource by casting long values to doublesabstract StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.lucene.search.SegmentCacheable
isCacheable
-
-
-
-
Method Detail
-
getValues
public abstract LongValues getValues(LeafReaderContext ctx, DoubleValues scores) throws IOException
Returns aLongValuesinstance for the passed-in LeafReaderContext and scoresIf scores are not needed to calculate the values (ie
returns false, callers may safely passnullfor thescoresparameter.- Throws:
IOException
-
needsScores
public abstract boolean needsScores()
Return true if document scores are needed to calculate values
-
rewrite
public abstract LongValuesSource rewrite(IndexSearcher searcher) throws IOException
Return a LongValuesSource specialised for the given IndexSearcherImplementations should assume that this will only be called once. IndexSearcher-independent implementations can just return
this- Throws:
IOException
-
getSortField
public SortField getSortField(boolean reverse)
Create a sort field based on the value of this producer- Parameters:
reverse- true if the sort should be decreasing
-
toDoubleValuesSource
public DoubleValuesSource toDoubleValuesSource()
Convert to a DoubleValuesSource by casting long values to doubles
-
fromLongField
public static LongValuesSource fromLongField(String field)
Creates a LongValuesSource that wraps a long-valued field
-
fromIntField
public static LongValuesSource fromIntField(String field)
Creates a LongValuesSource that wraps an int-valued field
-
constant
public static LongValuesSource constant(long value)
Creates a LongValuesSource that always returns a constant value
-
-