List of usage examples for org.apache.lucene.search DoubleValues withDefault
public static DoubleValues withDefault(DoubleValues in, double missingValue)
From source file:org.apache.solr.legacy.DistanceValueSource.java
License:Apache License
/** * Returns the FunctionValues used by the function query. *//*from w w w . j ava 2 s . c o m*/ @Override public DoubleValues getValues(LeafReaderContext readerContext, DoubleValues scores) throws IOException { final DoubleValues ptX = DoubleValuesSource.fromDoubleField(strategy.getFieldNameX()) .getValues(readerContext, null); final DoubleValues ptY = DoubleValuesSource.fromDoubleField(strategy.getFieldNameY()) .getValues(readerContext, null); final DistanceCalculator calculator = strategy.getSpatialContext().getDistCalc(); return DoubleValues.withDefault(new DoubleValues() { @Override public double doubleValue() throws IOException { return calculator.distance(from, ptX.doubleValue(), ptY.doubleValue()) * multiplier; } @Override public boolean advanceExact(int doc) throws IOException { return ptX.advanceExact(doc) && ptY.advanceExact(doc); } }, nullValue); }