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