SOLR-10011: Add NumberType getNumberType() to FieldType and deprecate LegacyNumericType getNumericType()

Modify references to getNumericType() to use the new getNumberType(). NumberType is shared for the different numeric implementations supported in Solr (TrieFields and PointFields).
CC SOLR-8396
This commit is contained in:
Tomas Fernandez Lobbe 2017-02-07 10:38:22 -08:00
parent e1a5776457
commit 59c41e2a6c
29 changed files with 158 additions and 110 deletions

View File

@ -87,7 +87,7 @@ Other Changes
* SOLR-10011: Refactor PointField & TrieField to now have a common base class, NumericFieldType. The
TrieField.TrieTypes and PointField.PointTypes are now consolidated to NumericFieldType.NumberType. This
refactoring also fixes a bug whereby PointFields were not using DocValues for range queries for
indexed=false, docValues=true fields.
indexed=false, docValues=true fields. (Ishan Chattopadhyaya, Tomás Fernández Löbbe)
================== 6.5.0 ==================

View File

@ -58,7 +58,7 @@ public class FieldFacetAccumulator extends ValueAccumulator {
this.schemaField = schemaField;
this.name = schemaField.getName();
this.multiValued = schemaField.multiValued();
this.numField = schemaField.getType().getNumericType()!=null;
this.numField = schemaField.getType().getNumberType()!=null;
this.dateField = schemaField.getType() instanceof DateValueFieldType;
this.parent = parent;
this.parser = AnalyticsParsers.getParser(schemaField.getType().getClass());

View File

@ -229,8 +229,7 @@ public abstract class RangeEndpointCalculator<T extends Comparable<T>> {
final FieldType ft = sf.getType();
final RangeEndpointCalculator<?> calc;
if (ft instanceof TrieField) {
final TrieField trie = (TrieField)ft;
switch (trie.getType()) {
switch (ft.getNumberType()) {
case FLOAT:
calc = new FloatRangeEndpointCalculator(request);
break;

View File

@ -34,7 +34,6 @@ import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.schema.DateRangeField;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.PointField;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.schema.TrieDateField;
import org.apache.solr.schema.TrieField;
@ -144,9 +143,7 @@ public class RangeFacetRequest extends FacetComponent.FacetBase {
FieldType ft = schemaField.getType();
if (ft instanceof TrieField) {
final TrieField trie = (TrieField) ft;
switch (trie.getType()) {
switch (ft.getNumberType()) {
case FLOAT:
calc = new FloatRangeEndpointCalculator(this);
break;
@ -170,8 +167,7 @@ public class RangeFacetRequest extends FacetComponent.FacetBase {
} else if (ft instanceof DateRangeField) {
calc = new DateRangeEndpointCalculator(this, null);
} else if (ft.isPointField()) {
final PointField pointField = (PointField) ft;
switch (pointField.getType()) {
switch (ft.getNumberType()) {
case FLOAT:
calc = new FloatRangeEndpointCalculator(this);
break;

View File

@ -29,7 +29,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.lucene.legacy.LegacyNumericType;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.ValueSource;
@ -46,6 +45,7 @@ import org.apache.solr.common.util.StrUtils;
import org.apache.solr.request.DocValuesStats;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.NumberType;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.search.DocIterator;
import org.apache.solr.search.DocSet;
@ -57,8 +57,8 @@ import org.apache.solr.search.SyntaxError;
import org.apache.solr.util.hll.HLL;
import org.apache.solr.util.hll.HLLType;
import com.google.common.hash.Hashing;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
/**
* Models all of the information associated with a single {@link StatsParams#STATS_FIELD}
@ -636,13 +636,13 @@ public class StatsField {
return null;
}
final LegacyNumericType hashableNumType = getHashableNumericType(field);
final NumberType hashableNumType = getHashableNumericType(field);
// some sane defaults
int log2m = 13; // roughly equivilent to "cardinality='0.33'"
int regwidth = 6; // with decent hash, this is plenty for all valid long hashes
if (LegacyNumericType.FLOAT.equals(hashableNumType) || LegacyNumericType.INT.equals(hashableNumType)) {
if (NumberType.FLOAT.equals(hashableNumType) || NumberType.INTEGER.equals(hashableNumType)) {
// for 32bit values, we can adjust our default regwidth down a bit
regwidth--;
@ -706,7 +706,7 @@ public class StatsField {
if (null == hasher) {
// if this is a function, or a non Long field, pre-hashed is invalid
// NOTE: we ignore hashableNumType - it's LONG for non numerics like Strings
if (null == field || !LegacyNumericType.LONG.equals(field.getType().getNumericType())) {
if (null == field || !(NumberType.LONG.equals(field.getType().getNumberType()) || NumberType.DATE.equals(field.getType().getNumberType()))) {
throw new SolrException(ErrorCode.BAD_REQUEST, "hllPreHashed is only supported with Long based fields");
}
}
@ -739,16 +739,16 @@ public class StatsField {
}
/**
* Returns the effective {@link LegacyNumericType} for the field for the purposes of hash values.
* ie: If the field has an explict LegacyNumericType that is returned; If the field has no explicit
* LegacyNumericType then {@link LegacyNumericType#LONG} is returned; If field is null, then
* {@link LegacyNumericType#FLOAT} is assumed for ValueSource.
* Returns the effective {@link NumberType} for the field for the purposes of hash values.
* ie: If the field has an explict NumberType that is returned; If the field has no explicit
* NumberType then {@link NumberType#LONG} is returned; If field is null, then
* {@link NumberType#FLOAT} is assumed for ValueSource.
*/
private static LegacyNumericType getHashableNumericType(SchemaField field) {
private static NumberType getHashableNumericType(SchemaField field) {
if (null == field) {
return LegacyNumericType.FLOAT;
return NumberType.FLOAT;
}
final LegacyNumericType result = field.getType().getNumericType();
return null == result ? LegacyNumericType.LONG : result;
final NumberType result = field.getType().getNumberType();
return null == result ? NumberType.LONG : result;
}
}

View File

@ -31,7 +31,6 @@ import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.legacy.LegacyNumericType;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.Bits;
@ -42,9 +41,9 @@ import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.request.IntervalFacets.FacetInterval;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.NumberType;
import org.apache.solr.schema.PointField;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.schema.TrieDateField;
import org.apache.solr.search.DocIterator;
import org.apache.solr.search.DocSet;
import org.apache.solr.search.Filter;
@ -175,7 +174,7 @@ public class IntervalFacets implements Iterable<FacetInterval> {
}
private void doCount() throws IOException {
if (schemaField.getType().getNumericType() != null && !schemaField.multiValued()) {
if (schemaField.getType().getNumberType() != null && !schemaField.multiValued()) {
getCountNumeric();
} else {
getCountString();
@ -185,7 +184,7 @@ public class IntervalFacets implements Iterable<FacetInterval> {
private void getCountNumeric() throws IOException {
final FieldType ft = schemaField.getType();
final String fieldName = schemaField.getName();
final LegacyNumericType numericType = ft.getNumericType();
final NumberType numericType = ft.getNumberType();
if (numericType == null) {
throw new IllegalStateException();
}
@ -203,9 +202,8 @@ public class IntervalFacets implements Iterable<FacetInterval> {
assert doc >= ctx.docBase;
switch (numericType) {
case LONG:
longs = DocValues.getNumeric(ctx.reader(), fieldName);
break;
case INT:
case DATE:
case INTEGER:
longs = DocValues.getNumeric(ctx.reader(), fieldName);
break;
case FLOAT:
@ -515,7 +513,7 @@ public class IntervalFacets implements Iterable<FacetInterval> {
}
// TODO: what about escaping star (*)?
// TODO: escaping spaces on ends?
if (schemaField.getType().getNumericType() != null) {
if (schemaField.getType().getNumberType() != null) {
setNumericLimits(schemaField);
}
if (start != null && end != null && start.compareTo(end) > 0) {
@ -537,7 +535,7 @@ public class IntervalFacets implements Iterable<FacetInterval> {
*/
public FacetInterval(SchemaField schemaField, String startStr, String endStr,
boolean includeLower, boolean includeUpper, String key) {
assert schemaField.getType().getNumericType() != null: "Only numeric fields supported with this constructor";
assert schemaField.getType().getNumberType() != null: "Only numeric fields supported with this constructor";
this.key = key;
this.startOpen = !includeLower;
this.endOpen = !includeUpper;
@ -559,15 +557,14 @@ public class IntervalFacets implements Iterable<FacetInterval> {
if (start == null) {
startLimit = Long.MIN_VALUE;
} else {
switch (schemaField.getType().getNumericType()) {
switch (schemaField.getType().getNumberType()) {
case LONG:
if (schemaField.getType() instanceof TrieDateField) {
startLimit = ((Date) schemaField.getType().toObject(schemaField, start)).getTime();
} else {
startLimit = (long) schemaField.getType().toObject(schemaField, start);
}
startLimit = (long) schemaField.getType().toObject(schemaField, start);
break;
case INT:
case DATE:
startLimit = ((Date) schemaField.getType().toObject(schemaField, start)).getTime();
break;
case INTEGER:
startLimit = ((Integer) schemaField.getType().toObject(schemaField, start)).longValue();
break;
case FLOAT:
@ -588,15 +585,14 @@ public class IntervalFacets implements Iterable<FacetInterval> {
if (end == null) {
endLimit = Long.MAX_VALUE;
} else {
switch (schemaField.getType().getNumericType()) {
switch (schemaField.getType().getNumberType()) {
case LONG:
if (schemaField.getType() instanceof TrieDateField) {
endLimit = ((Date) schemaField.getType().toObject(schemaField, end)).getTime();
} else {
endLimit = (long) schemaField.getType().toObject(schemaField, end);
}
endLimit = (long) schemaField.getType().toObject(schemaField, end);
break;
case INT:
case DATE:
endLimit = ((Date) schemaField.getType().toObject(schemaField, end)).getTime();
break;
case INTEGER:
endLimit = ((Integer) schemaField.getType().toObject(schemaField, end)).longValue();
break;
case FLOAT:

View File

@ -34,7 +34,6 @@ import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.ReaderUtil;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.legacy.LegacyNumericType;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.util.BytesRef;
@ -44,6 +43,7 @@ import org.apache.lucene.util.StringHelper;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.NumberType;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.schema.TrieField;
import org.apache.solr.search.DocIterator;
@ -133,7 +133,7 @@ final class NumericFacets {
mincount = Math.max(mincount, 1);
final SchemaField sf = searcher.getSchema().getField(fieldName);
final FieldType ft = sf.getType();
final LegacyNumericType numericType = ft.getNumericType();
final NumberType numericType = ft.getNumberType();
if (numericType == null) {
throw new IllegalStateException();
}
@ -154,9 +154,9 @@ final class NumericFacets {
assert doc >= ctx.docBase;
switch (numericType) {
case LONG:
longs = DocValues.getNumeric(ctx.reader(), fieldName);
break;
case INT:
case DATE:
case INTEGER:
// Long, Date and Integer
longs = DocValues.getNumeric(ctx.reader(), fieldName);
break;
case FLOAT:
@ -182,7 +182,7 @@ final class NumericFacets {
};
break;
default:
throw new AssertionError();
throw new AssertionError("Unexpected type: " + numericType);
}
}
int valuesDocID = longs.docID();

View File

@ -459,7 +459,7 @@ public class SimpleFacets {
break;
case FCS:
assert !multiToken;
if (ft.getNumericType() != null && !sf.multiValued()) {
if (ft.getNumberType() != null && !sf.multiValued()) {
// force numeric faceting
if (prefix != null && !prefix.isEmpty()) {
throw new SolrException(ErrorCode.BAD_REQUEST, FacetParams.FACET_PREFIX + " is not supported on numeric types");
@ -593,7 +593,7 @@ public class SimpleFacets {
/* Always use filters for booleans if not DocValues only... we know the number of values is very small. */
if (type instanceof BoolField && (field.indexed() == true || field.hasDocValues() == false)) {
method = FacetMethod.ENUM;
} else if (type.getNumericType() != null && !field.multiValued()) {
} else if (type.getNumberType() != null && !field.multiValued()) {
/* the per-segment approach is optimal for numeric field types since there
are no global ords to merge and no need to create an expensive
top-level reader */
@ -606,7 +606,7 @@ public class SimpleFacets {
/* FC without docValues does not support single valued numeric facets */
if (method == FacetMethod.FC
&& type.getNumericType() != null && !field.multiValued()) {
&& type.getNumberType() != null && !field.multiValued()) {
method = FacetMethod.FCS;
}
@ -692,7 +692,7 @@ public class SimpleFacets {
private Collector getInsanityWrapper(final String field, Collector collector) {
SchemaField sf = searcher.getSchema().getFieldOrNull(field);
if (sf != null && !sf.hasDocValues() && !sf.multiValued() && sf.getType().getNumericType() != null) {
if (sf != null && !sf.hasDocValues() && !sf.multiValued() && sf.getType().getNumberType() != null) {
// it's a single-valued numeric field: we must currently create insanity :(
// there isn't a GroupedFacetCollector that works on numerics right now...
return new FilterCollector(collector) {

View File

@ -233,9 +233,18 @@ public class EnumField extends PrimitiveFieldType {
* {@inheritDoc}
*/
@Override
@Deprecated
public LegacyNumericType getNumericType() {
return LegacyNumericType.INT;
}
/**
* {@inheritDoc}
*/
@Override
public NumberType getNumberType() {
return NumberType.INTEGER;
}
/**
* {@inheritDoc}

View File

@ -616,10 +616,21 @@ public abstract class FieldType extends FieldProperties {
/** Return the numeric type of this field, or null if this field is not a
* numeric field. */
* numeric field.
* @deprecated Please use {@link FieldType#getNumberType()} instead
*/
@Deprecated
public LegacyNumericType getNumericType() {
return null;
}
/**
* Return the numeric type of this field, or null if this field is not a
* numeric field.
*/
public NumberType getNumberType() {
return null;
}
/**
* Sets the Similarity used when scoring fields of this type

View File

@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.schema;
public enum NumberType {
INTEGER,
LONG,
FLOAT,
DOUBLE,
DATE
}

View File

@ -28,20 +28,13 @@ import org.apache.solr.util.DateMathParser;
public abstract class NumericFieldType extends PrimitiveFieldType {
public static enum NumberType {
INTEGER,
LONG,
FLOAT,
DOUBLE,
DATE
}
protected NumberType type;
/**
* @return the type of this field
*/
final public NumberType getType() {
@Override
public NumberType getNumberType() {
return type;
}
@ -58,7 +51,7 @@ public abstract class NumericFieldType extends PrimitiveFieldType {
boolean minInclusive, boolean maxInclusive) {
assert field.hasDocValues() && !field.multiValued();
switch (getType()) {
switch (getNumberType()) {
case INTEGER:
return numericDocValuesRangeQuery(field.getName(),
min == null ? null : (long) Integer.parseInt(min),
@ -87,18 +80,18 @@ public abstract class NumericFieldType extends PrimitiveFieldType {
Query query;
String fieldName = sf.getName();
Number minVal = min == null ? null : getType() == NumberType.FLOAT ? Float.parseFloat(min): Double.parseDouble(min);
Number maxVal = max == null ? null : getType() == NumberType.FLOAT ? Float.parseFloat(max): Double.parseDouble(max);
Number minVal = min == null ? null : getNumberType() == NumberType.FLOAT ? Float.parseFloat(min): Double.parseDouble(min);
Number maxVal = max == null ? null : getNumberType() == NumberType.FLOAT ? Float.parseFloat(max): Double.parseDouble(max);
Long minBits =
min == null ? null : getType() == NumberType.FLOAT ? (long) Float.floatToIntBits(minVal.floatValue()): Double.doubleToLongBits(minVal.doubleValue());
min == null ? null : getNumberType() == NumberType.FLOAT ? (long) Float.floatToIntBits(minVal.floatValue()): Double.doubleToLongBits(minVal.doubleValue());
Long maxBits =
max == null ? null : getType() == NumberType.FLOAT ? (long) Float.floatToIntBits(maxVal.floatValue()): Double.doubleToLongBits(maxVal.doubleValue());
max == null ? null : getNumberType() == NumberType.FLOAT ? (long) Float.floatToIntBits(maxVal.floatValue()): Double.doubleToLongBits(maxVal.doubleValue());
long negativeInfinityBits = getType() == NumberType.FLOAT ? FLOAT_NEGATIVE_INFINITY_BITS : DOUBLE_NEGATIVE_INFINITY_BITS;
long positiveInfinityBits = getType() == NumberType.FLOAT ? FLOAT_POSITIVE_INFINITY_BITS : DOUBLE_POSITIVE_INFINITY_BITS;
long minusZeroBits = getType() == NumberType.FLOAT ? FLOAT_MINUS_ZERO_BITS : DOUBLE_MINUS_ZERO_BITS;
long zeroBits = getType() == NumberType.FLOAT ? FLOAT_ZERO_BITS : DOUBLE_ZERO_BITS;
long negativeInfinityBits = getNumberType() == NumberType.FLOAT ? FLOAT_NEGATIVE_INFINITY_BITS : DOUBLE_NEGATIVE_INFINITY_BITS;
long positiveInfinityBits = getNumberType() == NumberType.FLOAT ? FLOAT_POSITIVE_INFINITY_BITS : DOUBLE_POSITIVE_INFINITY_BITS;
long minusZeroBits = getNumberType() == NumberType.FLOAT ? FLOAT_MINUS_ZERO_BITS : DOUBLE_MINUS_ZERO_BITS;
long zeroBits = getNumberType() == NumberType.FLOAT ? FLOAT_ZERO_BITS : DOUBLE_ZERO_BITS;
// If min is negative (or -0d) and max is positive (or +0d), then issue a FunctionRangeQuery
if ((minVal == null || minVal.doubleValue() < 0d || minBits == minusZeroBits) &&

View File

@ -80,14 +80,20 @@ public class SpatialPointVectorFieldType extends AbstractSpatialFieldType<PointV
}
@Override
@Deprecated
public LegacyNumericType getNumericType() {
return LegacyNumericType.DOUBLE;
}
@Override
public NumberType getNumberType() {
return NumberType.DOUBLE;
}
@Override
protected PointVectorStrategy newSpatialStrategy(String fieldName) {
// TODO update to how BBoxField does things
if (this.getNumericType() != null) {
if (this.getNumberType() != null) {
// create strategy based on legacy numerics
// todo remove in 7.0
LegacyFieldType fieldType = new LegacyFieldType(PointVectorStrategy.LEGACY_FIELDTYPE);

View File

@ -34,7 +34,6 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
@ -42,8 +41,28 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.DocumentStoredFieldVisitor;
import org.apache.lucene.document.LazyDocument;
import org.apache.lucene.index.*;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.ExitableDirectoryReader;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.MultiPostingsEnum;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.ReaderUtil;
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.index.StoredFieldVisitor;
import org.apache.lucene.index.StoredFieldVisitor.Status;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermContext;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
@ -98,8 +117,7 @@ import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.schema.BoolField;
import org.apache.solr.schema.EnumField;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.NumericFieldType;
import org.apache.solr.schema.PointField;
import org.apache.solr.schema.NumberType;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.schema.TrieDateField;
import org.apache.solr.schema.TrieDoubleField;
@ -832,7 +850,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
}
Object newVal = val;
if (schemaField.getType().isPointField()) {
NumericFieldType.NumberType type = ((PointField)schemaField.getType()).getType();
NumberType type = schemaField.getType().getNumberType();
switch (type) {
case INTEGER:
newVal = val.intValue();

View File

@ -19,9 +19,9 @@ package org.apache.solr.search.facet;
import java.util.HashMap;
import java.util.Map;
import org.apache.lucene.legacy.LegacyNumericType;
import org.apache.solr.common.SolrException;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.NumberType;
import org.apache.solr.schema.SchemaField;
// Any type of facet request that generates a variable number of buckets
@ -98,7 +98,7 @@ public class FacetField extends FacetRequestSorted {
FieldType ft = sf.getType();
boolean multiToken = sf.multiValued() || ft.multiValuedFieldCache();
LegacyNumericType ntype = ft.getNumericType();
NumberType ntype = ft.getNumberType();
// ensure we can support the requested options for numeric faceting:
if (ntype != null) {
if (prefix != null) {

View File

@ -149,7 +149,7 @@ class FacetFieldProcessorByEnumTermsStream extends FacetFieldProcessor implement
if (freq.prefix != null) {
String indexedPrefix = sf.getType().toInternal(freq.prefix);
startTermBytes = new BytesRef(indexedPrefix);
} else if (sf.getType().getNumericType() != null) {
} else if (sf.getType().getNumberType() != null) {
String triePrefix = TrieField.getMainValuePrefix(sf.getType());
if (triePrefix != null) {
startTermBytes = new BytesRef(triePrefix);

View File

@ -215,7 +215,7 @@ class FacetFieldProcessorByHashDV extends FacetFieldProcessor {
private SimpleOrderedMap<Object> calcFacets() throws IOException {
if (sf.getType().getNumericType() != null) {
if (sf.getType().getNumberType() != null) {
calc = FacetRangeProcessor.getNumericCalc(sf);
} else {
calc = new TermOrdCalc(); // kind of a hack

View File

@ -119,9 +119,7 @@ class FacetRangeProcessor extends FacetProcessor<FacetRange> {
final FieldType ft = sf.getType();
if (ft instanceof TrieField) {
final TrieField trie = (TrieField)ft;
switch (trie.getType()) {
switch (ft.getNumberType()) {
case FLOAT:
calc = new FloatCalc(sf);
break;
@ -143,9 +141,8 @@ class FacetRangeProcessor extends FacetProcessor<FacetRange> {
"Expected numeric field type :" + sf);
}
} else if (ft instanceof PointField) {
final PointField pfield = (PointField)ft;
switch (pfield.getType()) {
// TODO, this is the same in Trie and Point now
switch (ft.getNumberType()) {
case FLOAT:
calc = new FloatCalc(sf);
break;
@ -179,9 +176,7 @@ class FacetRangeProcessor extends FacetProcessor<FacetRange> {
final FieldType ft = sf.getType();
if (ft instanceof TrieField) {
final TrieField trie = (TrieField)ft;
switch (trie.getType()) {
switch (ft.getNumberType()) {
case FLOAT:
calc = new FloatCalc(sf);
break;

View File

@ -57,7 +57,7 @@ public class HLLAgg extends StrAggValueSource {
return new UniqueMultivaluedSlotAcc(fcontext, getArg(), numSlots, fcontext.isShard() ? factory : null);
}
} else {
if (sf.getType().getNumericType() != null) {
if (sf.getType().getNumberType() != null) {
// always use hll here since we don't know how many values there are?
return new NumericAcc(fcontext, getArg(), numSlots);
} else {

View File

@ -48,7 +48,7 @@ public class UniqueAgg extends StrAggValueSource {
return new UniqueMultivaluedSlotAcc(fcontext, getArg(), numSlots, null);
}
} else {
if (sf.getType().getNumericType() != null) {
if (sf.getType().getNumberType() != null) {
return new NumericAcc(fcontext, getArg(), numSlots);
} else {
return new UniqueSinglevaluedSlotAcc(fcontext, getArg(), numSlots, null);

View File

@ -77,7 +77,7 @@ public class OrdFieldSource extends ValueSource {
if (o instanceof SolrIndexSearcher) {
SolrIndexSearcher is = (SolrIndexSearcher) o;
SchemaField sf = is.getSchema().getFieldOrNull(field);
if (sf != null && sf.hasDocValues() == false && sf.multiValued() == false && sf.getType().getNumericType() != null) {
if (sf != null && sf.hasDocValues() == false && sf.multiValued() == false && sf.getType().getNumberType() != null) {
// it's a single-valued numeric field: we must currently create insanity :(
List<LeafReaderContext> leaves = is.getIndexReader().leaves();
LeafReader insaneLeaves[] = new LeafReader[leaves.size()];

View File

@ -77,7 +77,7 @@ public class ReverseOrdFieldSource extends ValueSource {
if (o instanceof SolrIndexSearcher) {
SolrIndexSearcher is = (SolrIndexSearcher) o;
SchemaField sf = is.getSchema().getFieldOrNull(field);
if (sf != null && sf.hasDocValues() == false && sf.multiValued() == false && sf.getType().getNumericType() != null) {
if (sf != null && sf.hasDocValues() == false && sf.multiValued() == false && sf.getType().getNumberType() != null) {
// it's a single-valued numeric field: we must currently create insanity :(
List<LeafReaderContext> leaves = is.getIndexReader().leaves();
LeafReader insaneLeaves[] = new LeafReader[leaves.size()];

View File

@ -172,7 +172,7 @@ public class CommandHandler {
FieldType fieldType = sf.getType();
final AllGroupHeadsCollector allGroupHeadsCollector;
if (fieldType.getNumericType() != null) {
if (fieldType.getNumberType() != null) {
ValueSource vs = fieldType.getValueSource(sf, null);
allGroupHeadsCollector = new FunctionAllGroupHeadsCollector(vs, new HashMap(), firstCommand.getSortWithinGroup());
} else {

View File

@ -33,8 +33,8 @@ import org.apache.lucene.util.mutable.MutableValueFloat;
import org.apache.lucene.util.mutable.MutableValueInt;
import org.apache.lucene.util.mutable.MutableValueLong;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.NumberType;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.schema.TrieField;
/**
* this is a transition class: for numeric types we use function-based distributed grouping,
@ -70,7 +70,7 @@ class GroupConverter {
for (SearchGroup<BytesRef> original : values) {
SearchGroup<MutableValue> converted = new SearchGroup<MutableValue>();
converted.sortValues = original.sortValues; // ?
TrieField.NumberType type = ((TrieField)fieldType).getType();
NumberType type = fieldType.getNumberType();
final MutableValue v;
switch (type) {
case INTEGER:

View File

@ -96,7 +96,7 @@ public class SearchGroupsFieldCommand implements Command<SearchGroupsFieldComman
final List<Collector> collectors = new ArrayList<>(2);
final FieldType fieldType = field.getType();
if (topNGroups > 0) {
if (fieldType.getNumericType() != null) {
if (fieldType.getNumberType() != null) {
ValueSource vs = fieldType.getValueSource(field, null);
firstPassGroupingCollector = new FunctionFirstPassGroupingCollector(vs, new HashMap<Object,Object>(), groupSort, topNGroups);
} else {
@ -105,7 +105,7 @@ public class SearchGroupsFieldCommand implements Command<SearchGroupsFieldComman
collectors.add(firstPassGroupingCollector);
}
if (includeGroupCount) {
if (fieldType.getNumericType() != null) {
if (fieldType.getNumberType() != null) {
ValueSource vs = fieldType.getValueSource(field, null);
allGroupsCollector = new FunctionAllGroupsCollector(vs, new HashMap<Object,Object>());
} else {
@ -120,7 +120,7 @@ public class SearchGroupsFieldCommand implements Command<SearchGroupsFieldComman
public SearchGroupsFieldCommandResult result() throws IOException {
final Collection<SearchGroup<BytesRef>> topGroups;
if (firstPassGroupingCollector != null) {
if (field.getType().getNumericType() != null) {
if (field.getType().getNumberType() != null) {
topGroups = GroupConverter.fromMutable(field, firstPassGroupingCollector.getTopGroups(0, true));
} else {
topGroups = firstPassGroupingCollector.getTopGroups(0, true);

View File

@ -132,7 +132,7 @@ public class TopGroupsFieldCommand implements Command<TopGroups<BytesRef>> {
final List<Collector> collectors = new ArrayList<>(1);
final FieldType fieldType = field.getType();
if (fieldType.getNumericType() != null) {
if (fieldType.getNumberType() != null) {
ValueSource vs = fieldType.getValueSource(field, null);
Collection<SearchGroup<MutableValue>> v = GroupConverter.toMutable(field, firstPhaseGroups);
secondPassCollector = new FunctionSecondPassGroupingCollector(
@ -155,7 +155,7 @@ public class TopGroupsFieldCommand implements Command<TopGroups<BytesRef>> {
}
FieldType fieldType = field.getType();
if (fieldType.getNumericType() != null) {
if (fieldType.getNumberType() != null) {
return GroupConverter.fromMutable(field, secondPassCollector.getTopGroups(0));
} else {
return secondPassCollector.getTopGroups(0);

View File

@ -190,7 +190,7 @@ public class CloudMLTQParser extends QParser {
}
private Query createIdQuery(String defaultField, String uniqueValue) {
return new TermQuery(req.getSchema().getField(defaultField).getType().getNumericType() != null
return new TermQuery(req.getSchema().getField(defaultField).getType().getNumberType() != null
? createNumericTerm(defaultField, uniqueValue)
: new Term(defaultField, uniqueValue));
}

View File

@ -101,7 +101,7 @@ public class SimpleMLTQParser extends QParser {
ArrayList<String> fields = new ArrayList();
for (String fieldName : fieldDefinitions.keySet()) {
if (fieldDefinitions.get(fieldName).indexed() && fieldDefinitions.get(fieldName).stored())
if (fieldDefinitions.get(fieldName).getType().getNumericType() == null)
if (fieldDefinitions.get(fieldName).getType().getNumberType() == null)
fields.add(fieldName);
}
fieldNames = fields.toArray(new String[0]);
@ -150,7 +150,7 @@ public class SimpleMLTQParser extends QParser {
}
private Query createIdQuery(String defaultField, String uniqueValue) {
return new TermQuery(req.getSchema().getField(defaultField).getType().getNumericType() != null
return new TermQuery(req.getSchema().getField(defaultField).getType().getNumberType() != null
? createNumericTerm(defaultField, uniqueValue)
: new Term(defaultField, uniqueValue));
}

View File

@ -163,7 +163,7 @@ public class TestRandomDVFaceting extends SolrTestCaseJ4 {
SchemaField sf = req.getSchema().getField(ftype.fname);
boolean multiValued = sf.getType().multiValuedFieldCache();
boolean indexed = sf.indexed();
boolean numeric = sf.getType().getNumericType() != null;
boolean numeric = sf.getType().getNumberType() != null;
int offset = 0;
if (rand.nextInt(100) < 20) {