mirror of https://github.com/apache/lucene.git
LUCENE-3622: function DocValues -> FunctionValues
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3622@1213426 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
64facac463
commit
701000cf27
|
@ -18,7 +18,7 @@ package org.apache.lucene.search.grouping.function;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.search.FieldComparator;
|
||||
import org.apache.lucene.search.Scorer;
|
||||
|
@ -45,7 +45,7 @@ public class FunctionAllGroupHeadsCollector extends AbstractAllGroupHeadsCollect
|
|||
private final Map<MutableValue, GroupHead> groups;
|
||||
private final Sort sortWithinGroup;
|
||||
|
||||
private DocValues.ValueFiller filler;
|
||||
private FunctionValues.ValueFiller filler;
|
||||
private MutableValue mval;
|
||||
private IndexReader.AtomicReaderContext readerContext;
|
||||
private Scorer scorer;
|
||||
|
@ -105,7 +105,7 @@ public class FunctionAllGroupHeadsCollector extends AbstractAllGroupHeadsCollect
|
|||
|
||||
public void setNextReader(IndexReader.AtomicReaderContext context) throws IOException {
|
||||
this.readerContext = context;
|
||||
DocValues docValues = groupBy.getValues(vsContext, context);
|
||||
FunctionValues docValues = groupBy.getValues(vsContext, context);
|
||||
filler = docValues.getValueFiller();
|
||||
mval = filler.getValue();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.lucene.search.grouping.function;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.search.grouping.AbstractAllGroupsCollector;
|
||||
import org.apache.lucene.util.mutable.MutableValue;
|
||||
|
@ -36,7 +36,7 @@ import java.util.TreeSet;
|
|||
* the most relevant document of a group.
|
||||
*
|
||||
* <p/>
|
||||
* Implementation detail: Uses {@link ValueSource} and {@link DocValues} to retrieve the
|
||||
* Implementation detail: Uses {@link ValueSource} and {@link FunctionValues} to retrieve the
|
||||
* field values to group by.
|
||||
*
|
||||
* @lucene.experimental
|
||||
|
@ -47,7 +47,7 @@ public class FunctionAllGroupsCollector extends AbstractAllGroupsCollector<Mutab
|
|||
private final ValueSource groupBy;
|
||||
private final SortedSet<MutableValue> groups = new TreeSet<MutableValue>();
|
||||
|
||||
private DocValues.ValueFiller filler;
|
||||
private FunctionValues.ValueFiller filler;
|
||||
private MutableValue mval;
|
||||
|
||||
/**
|
||||
|
@ -79,7 +79,7 @@ public class FunctionAllGroupsCollector extends AbstractAllGroupsCollector<Mutab
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
public void setNextReader(IndexReader.AtomicReaderContext context) throws IOException {
|
||||
DocValues docValues = groupBy.getValues(vsContext, context);
|
||||
FunctionValues docValues = groupBy.getValues(vsContext, context);
|
||||
filler = docValues.getValueFiller();
|
||||
mval = filler.getValue();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.lucene.search.grouping.function;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.search.grouping.AbstractFirstPassGroupingCollector;
|
||||
|
@ -38,8 +38,8 @@ public class FunctionFirstPassGroupingCollector extends AbstractFirstPassGroupin
|
|||
private final ValueSource groupByVS;
|
||||
private final Map vsContext;
|
||||
|
||||
private DocValues docValues;
|
||||
private DocValues.ValueFiller filler;
|
||||
private FunctionValues docValues;
|
||||
private FunctionValues.ValueFiller filler;
|
||||
private MutableValue mval;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.lucene.search.grouping.function;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.search.Sort;
|
||||
import org.apache.lucene.search.grouping.AbstractSecondPassGroupingCollector;
|
||||
|
@ -41,7 +41,7 @@ public class FunctionSecondPassGroupingCollector extends AbstractSecondPassGroup
|
|||
private final ValueSource groupByVS;
|
||||
private final Map vsContext;
|
||||
|
||||
private DocValues.ValueFiller filler;
|
||||
private FunctionValues.ValueFiller filler;
|
||||
private MutableValue mval;
|
||||
|
||||
/**
|
||||
|
@ -77,7 +77,7 @@ public class FunctionSecondPassGroupingCollector extends AbstractSecondPassGroup
|
|||
*/
|
||||
public void setNextReader(IndexReader.AtomicReaderContext readerContext) throws IOException {
|
||||
super.setNextReader(readerContext);
|
||||
DocValues docValues = groupByVS.getValues(vsContext, readerContext);
|
||||
FunctionValues docValues = groupByVS.getValues(vsContext, readerContext);
|
||||
filler = docValues.getValueFiller();
|
||||
mval = filler.getValue();
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class BoostedQuery extends Query {
|
|||
if (!subQueryExpl.isMatch()) {
|
||||
return subQueryExpl;
|
||||
}
|
||||
DocValues vals = boostVal.getValues(fcontext, readerContext);
|
||||
FunctionValues vals = boostVal.getValues(fcontext, readerContext);
|
||||
float sc = subQueryExpl.getValue() * vals.floatVal(doc);
|
||||
Explanation res = new ComplexExplanation(
|
||||
true, sc, BoostedQuery.this.toString() + ", product of:");
|
||||
|
@ -123,7 +123,7 @@ public class BoostedQuery extends Query {
|
|||
private final BoostedQuery.BoostedWeight weight;
|
||||
private final float qWeight;
|
||||
private final Scorer scorer;
|
||||
private final DocValues vals;
|
||||
private final FunctionValues vals;
|
||||
private final AtomicReaderContext readerContext;
|
||||
|
||||
private CustomScorer(AtomicReaderContext readerContext, BoostedQuery.BoostedWeight w, float qWeight,
|
||||
|
|
|
@ -106,7 +106,7 @@ public class FunctionQuery extends Query {
|
|||
final int maxDoc;
|
||||
final float qWeight;
|
||||
int doc=-1;
|
||||
final DocValues vals;
|
||||
final FunctionValues vals;
|
||||
final Bits liveDocs;
|
||||
|
||||
public AllScorer(AtomicReaderContext context, Bits acceptDocs, FunctionWeight w, float qWeight) throws IOException {
|
||||
|
|
|
@ -30,13 +30,13 @@ import org.apache.lucene.util.mutable.MutableValueFloat;
|
|||
*
|
||||
*/
|
||||
|
||||
// DocValues is distinct from ValueSource because
|
||||
// FunctionValues is distinct from ValueSource because
|
||||
// there needs to be an object created at query evaluation time that
|
||||
// is not referenced by the query itself because:
|
||||
// - Query objects should be MT safe
|
||||
// - For caching, Query objects are often used as keys... you don't
|
||||
// want the Query carrying around big objects
|
||||
public abstract class DocValues {
|
||||
public abstract class FunctionValues {
|
||||
|
||||
public byte byteVal(int doc) { throw new UnsupportedOperationException(); }
|
||||
public short shortVal(int doc) { throw new UnsupportedOperationException(); }
|
||||
|
@ -65,7 +65,7 @@ public abstract class DocValues {
|
|||
|
||||
/** Native Java Object representation of the value */
|
||||
public Object objectVal(int doc) {
|
||||
// most DocValues are functions, so by default return a Float()
|
||||
// most FunctionValues are functions, so by default return a Float()
|
||||
return floatVal(doc);
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ import java.util.IdentityHashMap;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Instantiates {@link DocValues} for a particular reader.
|
||||
* Instantiates {@link FunctionValues} for a particular reader.
|
||||
* <br>
|
||||
* Often used when creating a {@link FunctionQuery}.
|
||||
*
|
||||
|
@ -45,7 +45,7 @@ public abstract class ValueSource implements Serializable {
|
|||
* Gets the values for this reader and the context that was previously
|
||||
* passed to createWeight()
|
||||
*/
|
||||
public abstract DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException;
|
||||
public abstract FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException;
|
||||
|
||||
@Override
|
||||
public abstract boolean equals(Object o);
|
||||
|
@ -129,12 +129,12 @@ public abstract class ValueSource implements Serializable {
|
|||
|
||||
/**
|
||||
* Implement a {@link org.apache.lucene.search.FieldComparator} that works
|
||||
* off of the {@link DocValues} for a ValueSource
|
||||
* off of the {@link FunctionValues} for a ValueSource
|
||||
* instead of the normal Lucene FieldComparator that works off of a FieldCache.
|
||||
*/
|
||||
class ValueSourceComparator extends FieldComparator<Double> {
|
||||
private final double[] values;
|
||||
private DocValues docVals;
|
||||
private FunctionValues docVals;
|
||||
private double bottom;
|
||||
private Map fcontext;
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ public class ValueSourceScorer extends Scorer {
|
|||
protected IndexReader reader;
|
||||
private int doc = -1;
|
||||
protected final int maxDoc;
|
||||
protected final DocValues values;
|
||||
protected final FunctionValues values;
|
||||
protected boolean checkDeletes;
|
||||
private final Bits liveDocs;
|
||||
|
||||
protected ValueSourceScorer(IndexReader reader, DocValues values) {
|
||||
protected ValueSourceScorer(IndexReader reader, FunctionValues values) {
|
||||
super(null);
|
||||
this.reader = reader;
|
||||
this.maxDoc = reader.maxDoc();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package org.apache.lucene.queries.function.docvalues;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.util.mutable.MutableValue;
|
||||
import org.apache.lucene.util.mutable.MutableValueBool;
|
||||
|
||||
|
||||
public abstract class BoolDocValues extends DocValues {
|
||||
public abstract class BoolDocValues extends FunctionValues {
|
||||
protected final ValueSource vs;
|
||||
|
||||
public BoolDocValues(ValueSource vs) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package org.apache.lucene.queries.function.docvalues;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.util.mutable.MutableValue;
|
||||
import org.apache.lucene.util.mutable.MutableValueDouble;
|
||||
|
||||
public abstract class DoubleDocValues extends DocValues {
|
||||
public abstract class DoubleDocValues extends FunctionValues {
|
||||
protected final ValueSource vs;
|
||||
|
||||
public DoubleDocValues(ValueSource vs) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package org.apache.lucene.queries.function.docvalues;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.util.mutable.MutableValue;
|
||||
import org.apache.lucene.util.mutable.MutableValueFloat;
|
||||
|
||||
public abstract class FloatDocValues extends DocValues {
|
||||
public abstract class FloatDocValues extends FunctionValues {
|
||||
protected final ValueSource vs;
|
||||
|
||||
public FloatDocValues(ValueSource vs) {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package org.apache.lucene.queries.function.docvalues;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.util.mutable.MutableValue;
|
||||
import org.apache.lucene.util.mutable.MutableValueInt;
|
||||
|
||||
|
||||
public abstract class IntDocValues extends DocValues {
|
||||
public abstract class IntDocValues extends FunctionValues {
|
||||
protected final ValueSource vs;
|
||||
|
||||
public IntDocValues(ValueSource vs) {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package org.apache.lucene.queries.function.docvalues;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.util.mutable.MutableValue;
|
||||
import org.apache.lucene.util.mutable.MutableValueLong;
|
||||
|
||||
|
||||
public abstract class LongDocValues extends DocValues {
|
||||
public abstract class LongDocValues extends FunctionValues {
|
||||
protected final ValueSource vs;
|
||||
|
||||
public LongDocValues(ValueSource vs) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package org.apache.lucene.queries.function.docvalues;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.util.mutable.MutableValue;
|
||||
import org.apache.lucene.util.mutable.MutableValueStr;
|
||||
|
||||
public abstract class StrDocValues extends DocValues {
|
||||
public abstract class StrDocValues extends FunctionValues {
|
||||
protected final ValueSource vs;
|
||||
|
||||
public StrDocValues(ValueSource vs) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.lucene.queries.function.docvalues;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.ValueSourceScorer;
|
||||
import org.apache.lucene.search.FieldCache;
|
||||
|
@ -32,9 +32,9 @@ import org.apache.lucene.util.mutable.MutableValueStr;
|
|||
import java.io.IOException;
|
||||
|
||||
/** Internal class, subject to change.
|
||||
* Serves as base class for DocValues based on StringIndex
|
||||
* Serves as base class for FunctionValues based on StringIndex
|
||||
**/
|
||||
public abstract class StringIndexDocValues extends DocValues {
|
||||
public abstract class StringIndexDocValues extends FunctionValues {
|
||||
protected final FieldCache.DocTermsIndex termsIndex;
|
||||
protected final ValueSource vs;
|
||||
protected final MutableValueStr val = new MutableValueStr();
|
||||
|
@ -158,7 +158,7 @@ public abstract class StringIndexDocValues extends DocValues {
|
|||
public StringIndexException(final String fieldName,
|
||||
final RuntimeException cause) {
|
||||
super("Can't initialize StringIndex to generate (function) " +
|
||||
"DocValues for field: " + fieldName, cause);
|
||||
"FunctionValues for field: " + fieldName, cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.io.IOException;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.search.FieldCache;
|
||||
|
||||
/**
|
||||
|
@ -50,10 +50,10 @@ public class ByteFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final byte[] arr = cache.getBytes(readerContext.reader, field, parser, false);
|
||||
|
||||
return new DocValues() {
|
||||
return new FunctionValues() {
|
||||
@Override
|
||||
public byte byteVal(int doc) {
|
||||
return arr[doc];
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.docvalues.StringIndexDocValues;
|
||||
import org.apache.lucene.queries.function.ValueSource; //javadoc
|
||||
|
||||
|
@ -26,7 +26,7 @@ import java.io.IOException;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An implementation for retrieving {@link DocValues} instances for string based fields.
|
||||
* An implementation for retrieving {@link FunctionValues} instances for string based fields.
|
||||
*/
|
||||
public class BytesRefFieldSource extends FieldCacheSource {
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class BytesRefFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
|
||||
return new StringIndexDocValues(this, readerContext, field) {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -42,7 +42,7 @@ public class ConstValueSource extends ConstNumberSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
return new FloatDocValues(this) {
|
||||
@Override
|
||||
public float floatVal(int doc) {
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -39,15 +39,15 @@ public class DefFunction extends MultiFunction {
|
|||
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map fcontext, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map fcontext, AtomicReaderContext readerContext) throws IOException {
|
||||
|
||||
|
||||
return new Values(valsArr(sources, fcontext, readerContext)) {
|
||||
final int upto = valsArr.length - 1;
|
||||
|
||||
private DocValues get(int doc) {
|
||||
private FunctionValues get(int doc) {
|
||||
for (int i=0; i<upto; i++) {
|
||||
DocValues vals = valsArr[i];
|
||||
FunctionValues vals = valsArr[i];
|
||||
if (vals.exists(doc)) {
|
||||
return vals;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class DefFunction extends MultiFunction {
|
|||
@Override
|
||||
public boolean exists(int doc) {
|
||||
// return true if any source is exists?
|
||||
for (DocValues vals : valsArr) {
|
||||
for (FunctionValues vals : valsArr) {
|
||||
if (vals.exists(doc)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
|
||||
/** Function to divide "a" by "b"
|
||||
|
@ -37,7 +37,7 @@ public class DivFloatFunction extends DualFloatFunction {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues aVals, DocValues bVals) {
|
||||
protected float func(int doc, FunctionValues aVals, FunctionValues bVals) {
|
||||
return aVals.floatVal(doc) / bVals.floatVal(doc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
|
||||
import org.apache.lucene.queries.function.docvalues.IntDocValues;
|
||||
|
@ -146,7 +146,7 @@ public class DocFreqValueSource extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
IndexSearcher searcher = (IndexSearcher)context.get("searcher");
|
||||
int docfreq = searcher.getIndexReader().docFreq(new Term(indexedField, indexedBytes));
|
||||
return new ConstIntDocValues(docfreq, this);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -41,7 +41,7 @@ public class DoubleConstValueSource extends ConstNumberSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
return new DoubleDocValues(this) {
|
||||
@Override
|
||||
public float floatVal(int doc) {
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSourceScorer;
|
||||
import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
|
||||
import org.apache.lucene.search.FieldCache;
|
||||
|
@ -56,7 +56,7 @@ public class DoubleFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final double[] arr = cache.getDoubles(readerContext.reader, field, parser, true);
|
||||
final Bits valid = cache.getDocsWithField(readerContext.reader, field);
|
||||
return new DoubleDocValues(this) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -40,7 +40,7 @@ public abstract class DualFloatFunction extends ValueSource {
|
|||
}
|
||||
|
||||
protected abstract String name();
|
||||
protected abstract float func(int doc, DocValues aVals, DocValues bVals);
|
||||
protected abstract float func(int doc, FunctionValues aVals, FunctionValues bVals);
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
|
@ -48,9 +48,9 @@ public abstract class DualFloatFunction extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues aVals = a.getValues(context, readerContext);
|
||||
final DocValues bVals = b.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues aVals = a.getValues(context, readerContext);
|
||||
final FunctionValues bVals = b.getValues(context, readerContext);
|
||||
return new FloatDocValues(this) {
|
||||
@Override
|
||||
public float floatVal(int doc) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.io.IOException;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.search.FieldCache;
|
||||
import org.apache.lucene.util.Bits;
|
||||
|
@ -54,7 +54,7 @@ public class FloatFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final float[] arr = cache.getFloats(readerContext.reader, field, parser, true);
|
||||
final Bits valid = cache.getDocsWithField(readerContext.reader, field);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
|
||||
import org.apache.lucene.index.*;
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.similarities.Similarity;
|
||||
import org.apache.lucene.search.similarities.TFIDFSimilarity;
|
||||
|
@ -40,7 +40,7 @@ public class IDFValueSource extends DocFreqValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
IndexSearcher searcher = (IndexSearcher)context.get("searcher");
|
||||
Similarity sim = searcher.getSimilarityProvider().get(field);
|
||||
if (!(sim instanceof TFIDFSimilarity)) {
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.search.Explanation;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -43,12 +43,12 @@ public class IfFunction extends BoolFunction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues ifVals = ifSource.getValues(context, readerContext);
|
||||
final DocValues trueVals = trueSource.getValues(context, readerContext);
|
||||
final DocValues falseVals = falseSource.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues ifVals = ifSource.getValues(context, readerContext);
|
||||
final FunctionValues trueVals = trueSource.getValues(context, readerContext);
|
||||
final FunctionValues falseVals = falseSource.getValues(context, readerContext);
|
||||
|
||||
return new DocValues() {
|
||||
return new FunctionValues() {
|
||||
@Override
|
||||
public byte byteVal(int doc) {
|
||||
return ifVals.boolVal(doc) ? trueVals.byteVal(doc) : falseVals.byteVal(doc);
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSourceScorer;
|
||||
import org.apache.lucene.queries.function.docvalues.IntDocValues;
|
||||
import org.apache.lucene.search.FieldCache;
|
||||
|
@ -56,7 +56,7 @@ public class IntFieldSource extends FieldCacheSource {
|
|||
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final int[] arr = cache.getInts(readerContext.reader, field, parser, true);
|
||||
final Bits valid = cache.getDocsWithField(readerContext.reader, field);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.docvalues.IntDocValues;
|
||||
import org.apache.lucene.search.FieldCache.DocTerms;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -50,7 +50,7 @@ public class JoinDocFreqValueSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException
|
||||
{
|
||||
final DocTerms terms = cache.getTerms(readerContext.reader, field, true );
|
||||
final IndexReader top = ReaderUtil.getTopLevelContext(readerContext).reader;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -51,8 +51,8 @@ public class LinearFloatFunction extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues vals = source.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues vals = source.getValues(context, readerContext);
|
||||
return new FloatDocValues(this) {
|
||||
@Override
|
||||
public float floatVal(int doc) {
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.StrDocValues;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -45,7 +45,7 @@ public class LiteralValueSource extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
|
||||
return new StrDocValues(this) {
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSourceScorer;
|
||||
import org.apache.lucene.queries.function.docvalues.LongDocValues;
|
||||
import org.apache.lucene.search.FieldCache;
|
||||
|
@ -65,7 +65,7 @@ public class LongFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final long[] arr = cache.getLongs(readerContext.reader, field, parser, true);
|
||||
final Bits valid = cache.getDocsWithField(readerContext.reader, field);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class MaxDocValueSource extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
IndexSearcher searcher = (IndexSearcher)context.get("searcher");
|
||||
return new ConstIntDocValues(searcher.getIndexReader().maxDoc(), this);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
|
||||
/**
|
||||
|
@ -34,10 +34,10 @@ public class MaxFloatFunction extends MultiFloatFunction {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues[] valsArr) {
|
||||
protected float func(int doc, FunctionValues[] valsArr) {
|
||||
boolean first = true;
|
||||
float val = 0.0f;
|
||||
for (DocValues vals : valsArr) {
|
||||
for (FunctionValues vals : valsArr) {
|
||||
if (first) {
|
||||
first = false;
|
||||
val = vals.floatVal(doc);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
|
||||
/**
|
||||
|
@ -34,10 +34,10 @@ public class MinFloatFunction extends MultiFloatFunction {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues[] valsArr) {
|
||||
protected float func(int doc, FunctionValues[] valsArr) {
|
||||
boolean first = true;
|
||||
float val = 0.0f;
|
||||
for (DocValues vals : valsArr) {
|
||||
for (FunctionValues vals : valsArr) {
|
||||
if (first) {
|
||||
first = false;
|
||||
val = vals.floatVal(doc);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.BoolDocValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -37,11 +37,11 @@ public abstract class MultiBoolFunction extends BoolFunction {
|
|||
|
||||
protected abstract String name();
|
||||
|
||||
protected abstract boolean func(int doc, DocValues[] vals);
|
||||
protected abstract boolean func(int doc, FunctionValues[] vals);
|
||||
|
||||
@Override
|
||||
public BoolDocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues[] vals = new DocValues[sources.size()];
|
||||
final FunctionValues[] vals = new FunctionValues[sources.size()];
|
||||
int i=0;
|
||||
for (ValueSource source : sources) {
|
||||
vals[i++] = source.getValues(context, readerContext);
|
||||
|
@ -58,7 +58,7 @@ public abstract class MultiBoolFunction extends BoolFunction {
|
|||
StringBuilder sb = new StringBuilder(name());
|
||||
sb.append('(');
|
||||
boolean first = true;
|
||||
for (DocValues dv : vals) {
|
||||
for (FunctionValues dv : vals) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -39,7 +39,7 @@ public abstract class MultiFloatFunction extends ValueSource {
|
|||
}
|
||||
|
||||
abstract protected String name();
|
||||
abstract protected float func(int doc, DocValues[] valsArr);
|
||||
abstract protected float func(int doc, FunctionValues[] valsArr);
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
|
@ -59,8 +59,8 @@ public abstract class MultiFloatFunction extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues[] valsArr = new DocValues[sources.length];
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues[] valsArr = new FunctionValues[sources.length];
|
||||
for (int i=0; i<sources.length; i++) {
|
||||
valsArr[i] = sources[i].getValues(context, readerContext);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public abstract class MultiFloatFunction extends ValueSource {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(name()).append('(');
|
||||
boolean firstTime=true;
|
||||
for (DocValues vals : valsArr) {
|
||||
for (FunctionValues vals : valsArr) {
|
||||
if (firstTime) {
|
||||
firstTime=false;
|
||||
} else {
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -58,8 +58,8 @@ public abstract class MultiFunction extends ValueSource {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public static DocValues[] valsArr(List<ValueSource> sources, Map fcontext, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues[] valsArr = new DocValues[sources.size()];
|
||||
public static FunctionValues[] valsArr(List<ValueSource> sources, Map fcontext, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues[] valsArr = new FunctionValues[sources.size()];
|
||||
int i=0;
|
||||
for (ValueSource source : sources) {
|
||||
valsArr[i++] = source.getValues(fcontext, readerContext);
|
||||
|
@ -67,10 +67,10 @@ public abstract class MultiFunction extends ValueSource {
|
|||
return valsArr;
|
||||
}
|
||||
|
||||
public class Values extends DocValues {
|
||||
final DocValues[] valsArr;
|
||||
public class Values extends FunctionValues {
|
||||
final FunctionValues[] valsArr;
|
||||
|
||||
public Values(DocValues[] valsArr) {
|
||||
public Values(FunctionValues[] valsArr) {
|
||||
this.valsArr = valsArr;
|
||||
}
|
||||
|
||||
|
@ -87,11 +87,11 @@ public abstract class MultiFunction extends ValueSource {
|
|||
}
|
||||
|
||||
|
||||
public static String toString(String name, DocValues[] valsArr, int doc) {
|
||||
public static String toString(String name, FunctionValues[] valsArr, int doc) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(name).append('(');
|
||||
boolean firstTime=true;
|
||||
for (DocValues vals : valsArr) {
|
||||
for (FunctionValues vals : valsArr) {
|
||||
if (firstTime) {
|
||||
firstTime=false;
|
||||
} else {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -49,7 +49,7 @@ public class NormValueSource extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
IndexSearcher searcher = (IndexSearcher)context.get("searcher");
|
||||
Similarity sim = searcher.getSimilarityProvider().get(field);
|
||||
if (!(sim instanceof TFIDFSimilarity)) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.util.ReaderUtil;
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class NumDocsValueSource extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
// Searcher has no numdocs so we must use the reader instead
|
||||
return new ConstIntDocValues(ReaderUtil.getTopLevelContext(readerContext).reader.numDocs(), this);
|
||||
}
|
||||
|
|
|
@ -22,13 +22,13 @@ import java.util.Map;
|
|||
import org.apache.lucene.index.DocValues.Source;
|
||||
import org.apache.lucene.index.DocValues.Type;
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
|
||||
/**
|
||||
* Expert: obtains numeric field values from a {@link DocValues} field.
|
||||
* Expert: obtains numeric field values from a {@link FunctionValues} field.
|
||||
* This {@link ValueSource} is compatible with all numerical
|
||||
* {@link DocValues}
|
||||
* {@link FunctionValues}
|
||||
*
|
||||
* @lucene.experimental
|
||||
*
|
||||
|
@ -42,7 +42,7 @@ public class NumericIndexDocValueSource extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final Source source = readerContext.reader.docValues(field)
|
||||
.getSource();
|
||||
Type type = source.type();
|
||||
|
@ -50,7 +50,7 @@ public class NumericIndexDocValueSource extends ValueSource {
|
|||
case FLOAT_32:
|
||||
case FLOAT_64:
|
||||
// TODO (chrism) Change to use FloatDocValues and IntDocValues
|
||||
return new DocValues() {
|
||||
return new FunctionValues() {
|
||||
|
||||
@Override
|
||||
public String toString(int doc) {
|
||||
|
@ -64,7 +64,7 @@ public class NumericIndexDocValueSource extends ValueSource {
|
|||
};
|
||||
|
||||
case VAR_INTS:
|
||||
return new DocValues() {
|
||||
return new FunctionValues() {
|
||||
@Override
|
||||
public String toString(int doc) {
|
||||
return "float: [" + floatVal(doc) + "]";
|
||||
|
@ -113,6 +113,6 @@ public class NumericIndexDocValueSource extends ValueSource {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DocValues float(" + field + ')';
|
||||
return "FunctionValues float(" + field + ')';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.IntDocValues;
|
||||
import org.apache.lucene.search.FieldCache;
|
||||
|
@ -62,7 +62,7 @@ public class OrdFieldSource extends ValueSource {
|
|||
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final int off = readerContext.docBase;
|
||||
final IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader;
|
||||
final FieldCache.DocTermsIndex sindex = FieldCache.DEFAULT.getTermsIndex(topReader, field);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
|
||||
/** Function to raise the base "a" to the power "b"
|
||||
|
@ -37,7 +37,7 @@ public class PowFloatFunction extends DualFloatFunction {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues aVals, DocValues bVals) {
|
||||
protected float func(int doc, FunctionValues aVals, FunctionValues bVals) {
|
||||
return (float)Math.pow(aVals.floatVal(doc), bVals.floatVal(doc));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
|
||||
/**
|
||||
|
@ -34,9 +34,9 @@ public class ProductFloatFunction extends MultiFloatFunction {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues[] valsArr) {
|
||||
protected float func(int doc, FunctionValues[] valsArr) {
|
||||
float val = 1.0f;
|
||||
for (DocValues vals : valsArr) {
|
||||
for (FunctionValues vals : valsArr) {
|
||||
val *= vals.floatVal(doc);
|
||||
}
|
||||
return val;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.search.*;
|
||||
|
@ -51,7 +51,7 @@ public class QueryValueSource extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map fcontext, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map fcontext, AtomicReaderContext readerContext) throws IOException {
|
||||
return new QueryDocValues(this, readerContext, fcontext);
|
||||
}
|
||||
|
||||
|
@ -193,8 +193,8 @@ class QueryDocValues extends FloatDocValues {
|
|||
public ValueFiller getValueFiller() {
|
||||
//
|
||||
// TODO: if we want to support more than one value-filler or a value-filler in conjunction with
|
||||
// the DocValues, then members like "scorer" should be per ValueFiller instance.
|
||||
// Or we can say that the user should just instantiate multiple DocValues.
|
||||
// the FunctionValues, then members like "scorer" should be per ValueFiller instance.
|
||||
// Or we can say that the user should just instantiate multiple FunctionValues.
|
||||
//
|
||||
return new ValueFiller() {
|
||||
private final MutableValueFloat mval = new MutableValueFloat();
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -55,8 +55,8 @@ public class RangeMapFloatFunction extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues vals = source.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues vals = source.getValues(context, readerContext);
|
||||
return new FloatDocValues(this) {
|
||||
@Override
|
||||
public float floatVal(int doc) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -61,8 +61,8 @@ public class ReciprocalFloatFunction extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues vals = source.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues vals = source.getValues(context, readerContext);
|
||||
return new FloatDocValues(this) {
|
||||
@Override
|
||||
public float floatVal(int doc) {
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.IntDocValues;
|
||||
import org.apache.lucene.search.FieldCache;
|
||||
|
@ -62,7 +62,7 @@ public class ReverseOrdFieldSource extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader;
|
||||
final int off = readerContext.docBase;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -67,7 +67,7 @@ public class ScaleFloatFunction extends ValueSource {
|
|||
|
||||
for (AtomicReaderContext leaf : leaves) {
|
||||
int maxDoc = leaf.reader.maxDoc();
|
||||
DocValues vals = source.getValues(context, leaf);
|
||||
FunctionValues vals = source.getValues(context, leaf);
|
||||
for (int i=0; i<maxDoc; i++) {
|
||||
|
||||
float val = vals.floatVal(i);
|
||||
|
@ -98,7 +98,7 @@ public class ScaleFloatFunction extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
|
||||
ScaleInfo scaleInfo = (ScaleInfo)context.get(source);
|
||||
if (scaleInfo == null) {
|
||||
|
@ -109,7 +109,7 @@ public class ScaleFloatFunction extends ValueSource {
|
|||
final float minSource = scaleInfo.minVal;
|
||||
final float maxSource = scaleInfo.maxVal;
|
||||
|
||||
final DocValues vals = source.getValues(context, readerContext);
|
||||
final FunctionValues vals = source.getValues(context, readerContext);
|
||||
|
||||
return new FloatDocValues(this) {
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.io.IOException;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.search.FieldCache;
|
||||
|
||||
|
||||
|
@ -47,10 +47,10 @@ public class ShortFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final short[] arr = cache.getShorts(readerContext.reader, field, parser, false);
|
||||
|
||||
return new DocValues() {
|
||||
return new FunctionValues() {
|
||||
@Override
|
||||
public byte byteVal(int doc) {
|
||||
return (byte) arr[doc];
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.BoolDocValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -36,11 +36,11 @@ public abstract class SimpleBoolFunction extends BoolFunction {
|
|||
|
||||
protected abstract String name();
|
||||
|
||||
protected abstract boolean func(int doc, DocValues vals);
|
||||
protected abstract boolean func(int doc, FunctionValues vals);
|
||||
|
||||
@Override
|
||||
public BoolDocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues vals = source.getValues(context, readerContext);
|
||||
final FunctionValues vals = source.getValues(context, readerContext);
|
||||
return new BoolDocValues(this) {
|
||||
@Override
|
||||
public boolean boolVal(int doc) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
|
||||
|
@ -32,11 +32,11 @@ import java.util.Map;
|
|||
super(source);
|
||||
}
|
||||
|
||||
protected abstract float func(int doc, DocValues vals);
|
||||
protected abstract float func(int doc, FunctionValues vals);
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues vals = source.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues vals = source.getValues(context, readerContext);
|
||||
return new FloatDocValues(this) {
|
||||
@Override
|
||||
public float floatVal(int doc) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
|
||||
/**
|
||||
|
@ -34,9 +34,9 @@ public class SumFloatFunction extends MultiFloatFunction {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues[] valsArr) {
|
||||
protected float func(int doc, FunctionValues[] valsArr) {
|
||||
float val = 0.0f;
|
||||
for (DocValues vals : valsArr) {
|
||||
for (FunctionValues vals : valsArr) {
|
||||
val += vals.floatVal(doc);
|
||||
}
|
||||
return val;
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
import org.apache.lucene.index.Fields;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.Terms;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.LongDocValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -50,8 +50,8 @@ public class SumTotalTermFreqValueSource extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
|
||||
return (DocValues)context.get(this);
|
||||
public FunctionValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
|
||||
return (FunctionValues)context.get(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
|
||||
import org.apache.lucene.index.*;
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -41,7 +41,7 @@ public class TFValueSource extends TermFreqValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
Fields fields = readerContext.reader.fields();
|
||||
final Terms terms = fields.terms(field);
|
||||
final Similarity sim = ((IndexSearcher)context.get("searcher")).getSimilarityProvider().get(field);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
|
||||
import org.apache.lucene.index.*;
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.docvalues.IntDocValues;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -38,7 +38,7 @@ public class TermFreqValueSource extends DocFreqValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
Fields fields = readerContext.reader.fields();
|
||||
final Terms terms = fields.terms(field);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.LongDocValues;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -54,8 +54,8 @@ public class TotalTermFreqValueSource extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
|
||||
return (DocValues)context.get(this);
|
||||
public FunctionValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
|
||||
return (FunctionValues)context.get(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.queries.function.valuesource;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
||||
|
@ -27,8 +27,8 @@ import java.util.Map;
|
|||
|
||||
|
||||
/**
|
||||
* Converts individual ValueSource instances to leverage the DocValues *Val functions that work with multiple values,
|
||||
* i.e. {@link org.apache.lucene.queries.function.DocValues#doubleVal(int, double[])}
|
||||
* Converts individual ValueSource instances to leverage the FunctionValues *Val functions that work with multiple values,
|
||||
* i.e. {@link org.apache.lucene.queries.function.FunctionValues#doubleVal(int, double[])}
|
||||
*/
|
||||
//Not crazy about the name, but...
|
||||
public class VectorValueSource extends MultiValueSource {
|
||||
|
@ -53,14 +53,14 @@ public class VectorValueSource extends MultiValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
int size = sources.size();
|
||||
|
||||
// special-case x,y and lat,lon since it's so common
|
||||
if (size==2) {
|
||||
final DocValues x = sources.get(0).getValues(context, readerContext);
|
||||
final DocValues y = sources.get(1).getValues(context, readerContext);
|
||||
return new DocValues() {
|
||||
final FunctionValues x = sources.get(0).getValues(context, readerContext);
|
||||
final FunctionValues y = sources.get(1).getValues(context, readerContext);
|
||||
return new FunctionValues() {
|
||||
@Override
|
||||
public void byteVal(int doc, byte[] vals) {
|
||||
vals[0] = x.byteVal(doc);
|
||||
|
@ -105,12 +105,12 @@ public class VectorValueSource extends MultiValueSource {
|
|||
}
|
||||
|
||||
|
||||
final DocValues[] valsArr = new DocValues[size];
|
||||
final FunctionValues[] valsArr = new FunctionValues[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
valsArr[i] = sources.get(i).getValues(context, readerContext);
|
||||
}
|
||||
|
||||
return new DocValues() {
|
||||
return new FunctionValues() {
|
||||
@Override
|
||||
public void byteVal(int doc, byte[] vals) {
|
||||
for (int i = 0; i < valsArr.length; i++) {
|
||||
|
@ -165,7 +165,7 @@ public class VectorValueSource extends MultiValueSource {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(name()).append('(');
|
||||
boolean firstTime = true;
|
||||
for (DocValues vals : valsArr) {
|
||||
for (FunctionValues vals : valsArr) {
|
||||
if (firstTime) {
|
||||
firstTime = false;
|
||||
} else {
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.io.IOException;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.util.ReaderUtil;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
|
@ -63,7 +63,7 @@ public class ValueSourceAugmenter extends DocTransformer
|
|||
try {
|
||||
IndexReader reader = qparser.getReq().getSearcher().getIndexReader();
|
||||
readerContexts = reader.getTopReaderContext().leaves();
|
||||
docValuesArr = new DocValues[readerContexts.length];
|
||||
docValuesArr = new FunctionValues[readerContexts.length];
|
||||
|
||||
searcher = qparser.getReq().getSearcher();
|
||||
fcontext = ValueSource.newContext(searcher);
|
||||
|
@ -77,7 +77,7 @@ public class ValueSourceAugmenter extends DocTransformer
|
|||
Map fcontext;
|
||||
SolrIndexSearcher searcher;
|
||||
IndexReader.AtomicReaderContext[] readerContexts;
|
||||
DocValues docValuesArr[];
|
||||
FunctionValues docValuesArr[];
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -89,7 +89,7 @@ public class ValueSourceAugmenter extends DocTransformer
|
|||
// TODO: calculate this stuff just once across diff functions
|
||||
int idx = ReaderUtil.subIndex(docid, readerContexts);
|
||||
IndexReader.AtomicReaderContext rcontext = readerContexts[idx];
|
||||
DocValues values = docValuesArr[idx];
|
||||
FunctionValues values = docValuesArr[idx];
|
||||
if (values == null) {
|
||||
docValuesArr[idx] = values = valueSource.getValues(fcontext, rcontext);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.lucene.index.IndexableField;
|
|||
import org.apache.lucene.search.FieldCache;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.BoolDocValues;
|
||||
import org.apache.lucene.queries.function.valuesource.OrdFieldSource;
|
||||
|
@ -170,7 +170,7 @@ class BoolFieldSource extends ValueSource {
|
|||
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
|
||||
final FieldCache.DocTermsIndex sindex = FieldCache.DEFAULT.getTermsIndex(readerContext.reader, field);
|
||||
|
||||
// figure out what ord maps to true
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.lucene.index.IndexableField;
|
|||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.TermRangeQuery;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.StringIndexDocValues;
|
||||
import org.apache.lucene.queries.function.valuesource.FieldCacheSource;
|
||||
|
@ -462,7 +462,7 @@ class DateFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
return new StringIndexDocValues(this, readerContext, field) {
|
||||
@Override
|
||||
protected String toTerm(String readableValue) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.apache.lucene.document.FieldType;
|
|||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.valuesource.VectorValueSource;
|
||||
import org.apache.lucene.search.*;
|
||||
|
@ -383,8 +383,8 @@ class SpatialDistanceQuery extends Query {
|
|||
final int maxDoc;
|
||||
final float qWeight;
|
||||
int doc=-1;
|
||||
final DocValues latVals;
|
||||
final DocValues lonVals;
|
||||
final FunctionValues latVals;
|
||||
final FunctionValues lonVals;
|
||||
final Bits liveDocs;
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
|||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.IntDocValues;
|
||||
import org.apache.lucene.search.*;
|
||||
|
@ -157,7 +157,7 @@ public class RandomSortField extends FieldType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, final AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, final AtomicReaderContext readerContext) throws IOException {
|
||||
return new IntDocValues(this) {
|
||||
private final int seed = getSeed(field, readerContext);
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.solr.schema;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.StringIndexDocValues;
|
||||
import org.apache.lucene.queries.function.valuesource.FieldCacheSource;
|
||||
|
@ -122,7 +122,7 @@ class SortableDoubleFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final double def = defVal;
|
||||
|
||||
return new StringIndexDocValues(this, readerContext, field) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.solr.schema;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.StringIndexDocValues;
|
||||
import org.apache.lucene.queries.function.valuesource.FieldCacheSource;
|
||||
|
@ -125,7 +125,7 @@ class SortableFloatFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final float def = defVal;
|
||||
|
||||
return new StringIndexDocValues(this, readerContext, field) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.solr.schema;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.StringIndexDocValues;
|
||||
import org.apache.lucene.queries.function.valuesource.FieldCacheSource;
|
||||
|
@ -127,7 +127,7 @@ class SortableIntFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final int def = defVal;
|
||||
|
||||
return new StringIndexDocValues(this, readerContext, field) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.solr.schema;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.StringIndexDocValues;
|
||||
import org.apache.lucene.queries.function.valuesource.FieldCacheSource;
|
||||
|
@ -125,7 +125,7 @@ class SortableLongFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final long def = defVal;
|
||||
|
||||
return new StringIndexDocValues(this, readerContext, field) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.solr.schema;
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.docvalues.StringIndexDocValues;
|
||||
import org.apache.lucene.queries.function.valuesource.FieldCacheSource;
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class StrFieldSource extends FieldCacheSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
return new StringIndexDocValues(this, readerContext, field) {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.solr.search;
|
||||
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.FunctionQuery;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.ValueSourceScorer;
|
||||
|
@ -114,7 +114,7 @@ class FunctionRangeQuery extends SolrConstantScoreQuery implements PostFilter {
|
|||
@Override
|
||||
public void setNextReader(IndexReader.AtomicReaderContext context) throws IOException {
|
||||
maxdoc = context.reader.maxDoc();
|
||||
DocValues dv = rangeFilt.getValueSource().getValues(fcontext, context);
|
||||
FunctionValues dv = rangeFilt.getValueSource().getValues(fcontext, context);
|
||||
scorer = dv.getRangeScorer(context.reader, rangeFilt.getLowerVal(), rangeFilt.getUpperVal(), rangeFilt.isIncludeLower(), rangeFilt.isIncludeUpper());
|
||||
super.setNextReader(context);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.solr.search;
|
|||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queries.function.BoostedQuery;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.BoolDocValues;
|
||||
import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
|
||||
|
@ -173,7 +173,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues vals) {
|
||||
protected float func(int doc, FunctionValues vals) {
|
||||
return Math.abs(vals.floatVal(doc));
|
||||
}
|
||||
};
|
||||
|
@ -209,7 +209,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues aVals, DocValues bVals) {
|
||||
protected float func(int doc, FunctionValues aVals, FunctionValues bVals) {
|
||||
return aVals.floatVal(doc) - bVals.floatVal(doc);
|
||||
}
|
||||
};
|
||||
|
@ -353,133 +353,133 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
|
|||
|
||||
addParser(new DoubleParser("rad") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return vals.doubleVal(doc) * DistanceUtils.DEGREES_TO_RADIANS;
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("deg") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return vals.doubleVal(doc) * DistanceUtils.RADIANS_TO_DEGREES;
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("sqrt") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.sqrt(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("cbrt") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.cbrt(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("log") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.log10(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("ln") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.log(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("exp") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.exp(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("sin") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.sin(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("cos") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.cos(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("tan") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.tan(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("asin") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.asin(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("acos") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.acos(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("atan") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.atan(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("sinh") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.sinh(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("cosh") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.cosh(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("tanh") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.tanh(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("ceil") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.ceil(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("floor") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.floor(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new DoubleParser("rint") {
|
||||
@Override
|
||||
public double func(int doc, DocValues vals) {
|
||||
public double func(int doc, FunctionValues vals) {
|
||||
return Math.rint(vals.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new Double2Parser("pow") {
|
||||
@Override
|
||||
public double func(int doc, DocValues a, DocValues b) {
|
||||
public double func(int doc, FunctionValues a, FunctionValues b) {
|
||||
return Math.pow(a.doubleVal(doc), b.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new Double2Parser("hypot") {
|
||||
@Override
|
||||
public double func(int doc, DocValues a, DocValues b) {
|
||||
public double func(int doc, FunctionValues a, FunctionValues b) {
|
||||
return Math.hypot(a.doubleVal(doc), b.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
addParser(new Double2Parser("atan2") {
|
||||
@Override
|
||||
public double func(int doc, DocValues a, DocValues b) {
|
||||
public double func(int doc, FunctionValues a, FunctionValues b) {
|
||||
return Math.atan2(a.doubleVal(doc), b.doubleVal(doc));
|
||||
}
|
||||
});
|
||||
|
@ -629,7 +629,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
|
|||
return "exists";
|
||||
}
|
||||
@Override
|
||||
protected boolean func(int doc, DocValues vals) {
|
||||
protected boolean func(int doc, FunctionValues vals) {
|
||||
return vals.exists(doc);
|
||||
}
|
||||
};
|
||||
|
@ -642,7 +642,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
|
|||
ValueSource vs = fp.parseValueSource();
|
||||
return new SimpleBoolFunction(vs) {
|
||||
@Override
|
||||
protected boolean func(int doc, DocValues vals) {
|
||||
protected boolean func(int doc, FunctionValues vals) {
|
||||
return !vals.boolVal(doc);
|
||||
}
|
||||
@Override
|
||||
|
@ -664,8 +664,8 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
|
|||
return "and";
|
||||
}
|
||||
@Override
|
||||
protected boolean func(int doc, DocValues[] vals) {
|
||||
for (DocValues dv : vals)
|
||||
protected boolean func(int doc, FunctionValues[] vals) {
|
||||
for (FunctionValues dv : vals)
|
||||
if (!dv.boolVal(doc)) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -683,8 +683,8 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
|
|||
return "or";
|
||||
}
|
||||
@Override
|
||||
protected boolean func(int doc, DocValues[] vals) {
|
||||
for (DocValues dv : vals)
|
||||
protected boolean func(int doc, FunctionValues[] vals) {
|
||||
for (FunctionValues dv : vals)
|
||||
if (dv.boolVal(doc)) return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -702,9 +702,9 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
|
|||
return "xor";
|
||||
}
|
||||
@Override
|
||||
protected boolean func(int doc, DocValues[] vals) {
|
||||
protected boolean func(int doc, FunctionValues[] vals) {
|
||||
int nTrue=0, nFalse=0;
|
||||
for (DocValues dv : vals) {
|
||||
for (FunctionValues dv : vals) {
|
||||
if (dv.boolVal(doc)) nTrue++;
|
||||
else nFalse++;
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ class DateValueSourceParser extends ValueSourceParser {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues aVals, DocValues bVals) {
|
||||
protected float func(int doc, FunctionValues aVals, FunctionValues bVals) {
|
||||
return ms1 - bVals.longVal(doc);
|
||||
}
|
||||
};
|
||||
|
@ -902,7 +902,7 @@ class DateValueSourceParser extends ValueSourceParser {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues aVals, DocValues bVals) {
|
||||
protected float func(int doc, FunctionValues aVals, FunctionValues bVals) {
|
||||
return aVals.longVal(doc) - ms2;
|
||||
}
|
||||
};
|
||||
|
@ -916,7 +916,7 @@ class DateValueSourceParser extends ValueSourceParser {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues aVals, DocValues bVals) {
|
||||
protected float func(int doc, FunctionValues aVals, FunctionValues bVals) {
|
||||
return aVals.longVal(doc) - bVals.longVal(doc);
|
||||
}
|
||||
};
|
||||
|
@ -945,7 +945,7 @@ class LongConstValueSource extends ConstNumberSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
return new LongDocValues(this) {
|
||||
@Override
|
||||
public float floatVal(int doc) {
|
||||
|
@ -1034,7 +1034,7 @@ abstract class DoubleParser extends NamedParser {
|
|||
super(name);
|
||||
}
|
||||
|
||||
public abstract double func(int doc, DocValues vals);
|
||||
public abstract double func(int doc, FunctionValues vals);
|
||||
|
||||
@Override
|
||||
public ValueSource parse(FunctionQParser fp) throws ParseException {
|
||||
|
@ -1052,8 +1052,8 @@ abstract class DoubleParser extends NamedParser {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues vals = source.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues vals = source.getValues(context, readerContext);
|
||||
return new DoubleDocValues(this) {
|
||||
@Override
|
||||
public double doubleVal(int doc) {
|
||||
|
@ -1074,7 +1074,7 @@ abstract class Double2Parser extends NamedParser {
|
|||
super(name);
|
||||
}
|
||||
|
||||
public abstract double func(int doc, DocValues a, DocValues b);
|
||||
public abstract double func(int doc, FunctionValues a, FunctionValues b);
|
||||
|
||||
@Override
|
||||
public ValueSource parse(FunctionQParser fp) throws ParseException {
|
||||
|
@ -1100,9 +1100,9 @@ abstract class Double2Parser extends NamedParser {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues aVals = a.getValues(context, readerContext);
|
||||
final DocValues bVals = b.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues aVals = a.getValues(context, readerContext);
|
||||
final FunctionValues bVals = b.getValues(context, readerContext);
|
||||
return new DoubleDocValues(this) {
|
||||
@Override
|
||||
public double doubleVal(int doc) {
|
||||
|
@ -1154,7 +1154,7 @@ class BoolConstValueSource extends ConstNumberSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
return new BoolDocValues(this) {
|
||||
@Override
|
||||
public boolean boolVal(int doc) {
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.lucene.index.MultiFields;
|
|||
import org.apache.lucene.index.TermsEnum;
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader.ReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -76,7 +76,7 @@ public class FileFloatSource extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final int off = readerContext.docBase;
|
||||
ReaderContext topLevelContext = ReaderUtil.getTopLevelContext(readerContext);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.solr.search.function.distance;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.spatial.geohash.GeoHashUtils;
|
||||
|
||||
|
@ -46,12 +46,12 @@ public class GeohashFunction extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues latDV = lat.getValues(context, readerContext);
|
||||
final DocValues lonDV = lon.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues latDV = lat.getValues(context, readerContext);
|
||||
final FunctionValues lonDV = lon.getValues(context, readerContext);
|
||||
|
||||
|
||||
return new DocValues() {
|
||||
return new FunctionValues() {
|
||||
|
||||
@Override
|
||||
public String strVal(int doc) {
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.solr.search.function.distance;
|
|||
*/
|
||||
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
|
||||
import org.apache.lucene.spatial.DistanceUtils;
|
||||
|
@ -55,9 +55,9 @@ public class GeohashHaversineFunction extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues gh1DV = geoHash1.getValues(context, readerContext);
|
||||
final DocValues gh2DV = geoHash2.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues gh1DV = geoHash1.getValues(context, readerContext);
|
||||
final FunctionValues gh2DV = geoHash2.getValues(context, readerContext);
|
||||
|
||||
return new DoubleDocValues(this) {
|
||||
@Override
|
||||
|
@ -75,7 +75,7 @@ public class GeohashHaversineFunction extends ValueSource {
|
|||
};
|
||||
}
|
||||
|
||||
protected double distance(int doc, DocValues gh1DV, DocValues gh2DV) {
|
||||
protected double distance(int doc, FunctionValues gh1DV, FunctionValues gh2DV) {
|
||||
double result = 0;
|
||||
String h1 = gh1DV.strVal(doc);
|
||||
String h2 = gh2DV.strVal(doc);
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.solr.search.function.distance;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
|
||||
import org.apache.lucene.queries.function.valuesource.ConstNumberSource;
|
||||
|
@ -198,9 +198,9 @@ public class HaversineConstFunction extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues latVals = latSource.getValues(context, readerContext);
|
||||
final DocValues lonVals = lonSource.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues latVals = latSource.getValues(context, readerContext);
|
||||
final FunctionValues lonVals = lonSource.getValues(context, readerContext);
|
||||
final double latCenterRad = this.latCenter * DistanceUtils.DEGREES_TO_RADIANS;
|
||||
final double lonCenterRad = this.lonCenter * DistanceUtils.DEGREES_TO_RADIANS;
|
||||
final double latCenterRad_cos = this.latCenterRad_cos;
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.solr.search.function.distance;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
|
||||
import org.apache.lucene.queries.function.valuesource.MultiValueSource;
|
||||
|
@ -70,7 +70,7 @@ public class HaversineFunction extends ValueSource {
|
|||
* @param p2DV
|
||||
* @return The haversine distance formula
|
||||
*/
|
||||
protected double distance(int doc, DocValues p1DV, DocValues p2DV) {
|
||||
protected double distance(int doc, FunctionValues p1DV, FunctionValues p2DV) {
|
||||
|
||||
double[] p1D = new double[2];
|
||||
double[] p2D = new double[2];
|
||||
|
@ -96,10 +96,10 @@ public class HaversineFunction extends ValueSource {
|
|||
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues vals1 = p1.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues vals1 = p1.getValues(context, readerContext);
|
||||
|
||||
final DocValues vals2 = p2.getValues(context, readerContext);
|
||||
final FunctionValues vals2 = p2.getValues(context, readerContext);
|
||||
return new DoubleDocValues(this) {
|
||||
@Override
|
||||
public double doubleVal(int doc) {
|
||||
|
|
|
@ -16,7 +16,7 @@ package org.apache.solr.search.function.distance;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.valuesource.MultiValueSource;
|
||||
import org.apache.lucene.spatial.DistanceUtils;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class SquaredEuclideanFunction extends VectorDistanceFunction {
|
|||
* @param doc The doc to score
|
||||
*/
|
||||
@Override
|
||||
protected double distance(int doc, DocValues dv1, DocValues dv2) {
|
||||
protected double distance(int doc, FunctionValues dv1, FunctionValues dv2) {
|
||||
|
||||
double[] vals1 = new double[source1.dimension()];
|
||||
double[] vals2 = new double[source1.dimension()];
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.solr.search.function.distance;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
|
||||
import org.apache.lucene.search.spell.StringDistance;
|
||||
|
@ -49,9 +49,9 @@ public class StringDistanceFunction extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final DocValues str1DV = str1.getValues(context, readerContext);
|
||||
final DocValues str2DV = str2.getValues(context, readerContext);
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
final FunctionValues str1DV = str1.getValues(context, readerContext);
|
||||
final FunctionValues str2DV = str2.getValues(context, readerContext);
|
||||
return new FloatDocValues(this) {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.solr.search.function.distance;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
|
||||
import org.apache.lucene.queries.function.valuesource.MultiValueSource;
|
||||
|
@ -69,7 +69,7 @@ public class VectorDistanceFunction extends ValueSource {
|
|||
* @param dv2 The values from the second MultiValueSource
|
||||
* @return The distance
|
||||
*/
|
||||
protected double distance(int doc, DocValues dv1, DocValues dv2) {
|
||||
protected double distance(int doc, FunctionValues dv1, FunctionValues dv2) {
|
||||
//Handle some special cases:
|
||||
double[] vals1 = new double[source1.dimension()];
|
||||
double[] vals2 = new double[source1.dimension()];
|
||||
|
@ -79,11 +79,11 @@ public class VectorDistanceFunction extends ValueSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
|
||||
final DocValues vals1 = source1.getValues(context, readerContext);
|
||||
final FunctionValues vals1 = source1.getValues(context, readerContext);
|
||||
|
||||
final DocValues vals2 = source2.getValues(context, readerContext);
|
||||
final FunctionValues vals2 = source2.getValues(context, readerContext);
|
||||
|
||||
|
||||
return new DoubleDocValues(this) {
|
||||
|
|
|
@ -16,7 +16,7 @@ package org.apache.solr.core;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.valuesource.SimpleFloatFunction;
|
||||
import org.apache.lucene.queryparser.classic.ParseException;
|
||||
|
@ -47,7 +47,7 @@ public class DummyValueSourceParser extends ValueSourceParser {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues vals) {
|
||||
protected float func(int doc, FunctionValues vals) {
|
||||
float result = 0;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.solr.search;
|
|||
|
||||
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader.ReaderContext;
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.util.ReaderUtil;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
|
@ -53,7 +53,7 @@ public class TestIndexSearcher extends SolrTestCaseJ4 {
|
|||
AtomicReaderContext[] leaves = ReaderUtil.leaves(topReaderContext);
|
||||
int idx = ReaderUtil.subIndex(doc, leaves);
|
||||
AtomicReaderContext leaf = leaves[idx];
|
||||
DocValues vals = vs.getValues(context, leaf);
|
||||
FunctionValues vals = vs.getValues(context, leaf);
|
||||
return vals.strVal(doc-leaf.docBase);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.solr.search.function;
|
||||
|
||||
import org.apache.lucene.queries.function.DocValues;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
import org.apache.lucene.queries.function.valuesource.SimpleFloatFunction;
|
||||
import org.apache.lucene.queryparser.classic.ParseException;
|
||||
|
@ -57,7 +57,7 @@ public class NvlValueSourceParser extends ValueSourceParser {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float func(int doc, DocValues vals) {
|
||||
protected float func(int doc, FunctionValues vals) {
|
||||
float v = vals.floatVal(doc);
|
||||
if (v == nvlFloatValue) {
|
||||
return nvl;
|
||||
|
|
Loading…
Reference in New Issue