From 34ed85a40f186a2892007e89aabcfc8552bca36e Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 7 Oct 2010 18:41:17 +0200 Subject: [PATCH] internal refactoring of field data type --- .../lucene/geo/GeoBoundingBoxFilter.java | 6 +- .../lucene/geo/GeoDistanceDataComparator.java | 4 +- .../common/lucene/geo/GeoDistanceFilter.java | 6 +- .../common/lucene/geo/GeoPolygonFilter.java | 6 +- .../cache/field/data/FieldDataCache.java | 5 +- .../field/data/none/NoneFieldDataCache.java | 7 +- .../AbstractConcurrentMapFieldDataCache.java | 19 +-- .../index/field/data/DocFieldData.java | 2 +- .../index/field/data/FieldData.java | 144 +----------------- .../index/field/data/FieldDataType.java | 53 +++++++ .../field/data/doubles/DoubleFieldData.java | 5 +- .../doubles/DoubleFieldDataComparator.java | 6 +- .../data/doubles/DoubleFieldDataType.java | 50 ++++++ .../field/data/floats/FloatFieldData.java | 5 +- .../data/floats/FloatFieldDataComparator.java | 6 +- .../field/data/floats/FloatFieldDataType.java | 50 ++++++ .../index/field/data/ints/IntFieldData.java | 5 +- .../data/ints/IntFieldDataComparator.java | 6 +- .../field/data/ints/IntFieldDataType.java | 50 ++++++ .../index/field/data/longs/LongFieldData.java | 5 +- .../data/longs/LongFieldDataComparator.java | 6 +- .../field/data/longs/LongFieldDataType.java | 50 ++++++ .../field/data/shorts/ShortFieldData.java | 5 +- .../data/shorts/ShortFieldDataComparator.java | 6 +- .../field/data/shorts/ShortFieldDataType.java | 50 ++++++ .../field/data/strings/StringFieldData.java | 5 +- .../data/strings/StringFieldDataType.java | 50 ++++++ .../StringOrdValFieldDataComparator.java | 3 +- .../strings/StringValFieldDataComparator.java | 3 +- .../support/NumericFieldDataComparator.java | 4 +- .../index/mapper/FieldMapper.java | 4 +- .../xcontent/XContentBoostFieldMapper.java | 6 +- .../xcontent/XContentDateFieldMapper.java | 6 +- .../xcontent/XContentDoubleFieldMapper.java | 6 +- .../mapper/xcontent/XContentFieldMapper.java | 6 +- .../xcontent/XContentFloatFieldMapper.java | 6 +- .../xcontent/XContentIntegerFieldMapper.java | 6 +- .../xcontent/XContentLongFieldMapper.java | 6 +- .../xcontent/XContentNumberFieldMapper.java | 4 +- .../xcontent/XContentShortFieldMapper.java | 6 +- .../GeoDistanceFacetCollector.java | 4 +- .../ValueGeoDistanceFacetCollector.java | 4 +- .../histogram/HistogramFacetCollector.java | 4 +- .../KeyValueHistogramFacetCollector.java | 6 +- .../range/KeyValueRangeFacetCollector.java | 6 +- .../facets/range/RangeFacetCollector.java | 4 +- .../StatisticalFacetCollector.java | 4 +- .../facets/terms/TermsFacetCollector.java | 5 +- .../terms/TermsFieldsFacetCollector.java | 7 +- .../data/doubles/DoubleFieldDataTests.java | 3 - .../data/floats/FloatFieldDataTests.java | 3 - .../field/data/ints/IntFieldDataTests.java | 3 - .../field/data/longs/LongFieldDataTests.java | 3 - .../data/shorts/ShortFieldDataTests.java | 3 - .../data/strings/StringFieldDataTests.java | 2 - 55 files changed, 470 insertions(+), 269 deletions(-) create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/FieldDataType.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataType.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataType.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataType.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataType.java create mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldDataType.java diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoBoundingBoxFilter.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoBoundingBoxFilter.java index 4e7429603b4..1eb03177b33 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoBoundingBoxFilter.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoBoundingBoxFilter.java @@ -24,7 +24,7 @@ import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.Filter; import org.elasticsearch.common.lucene.docset.GetDocSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import java.io.IOException; @@ -42,11 +42,11 @@ public class GeoBoundingBoxFilter extends Filter { private final String lonFieldName; - private final FieldData.Type fieldDataType; + private final FieldDataType fieldDataType; private final FieldDataCache fieldDataCache; - public GeoBoundingBoxFilter(Point topLeft, Point bottomRight, String latFieldName, String lonFieldName, FieldData.Type fieldDataType, FieldDataCache fieldDataCache) { + public GeoBoundingBoxFilter(Point topLeft, Point bottomRight, String latFieldName, String lonFieldName, FieldDataType fieldDataType, FieldDataCache fieldDataCache) { this.topLeft = topLeft; this.bottomRight = bottomRight; this.latFieldName = latFieldName; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoDistanceDataComparator.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoDistanceDataComparator.java index 44351ffa4d8..3744ab23a37 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoDistanceDataComparator.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoDistanceDataComparator.java @@ -25,7 +25,7 @@ import org.apache.lucene.search.FieldComparatorSource; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; @@ -92,7 +92,7 @@ public class GeoDistanceDataComparator extends FieldComparator { protected final FieldDataCache fieldDataCache; - protected final FieldData.Type fieldDataType; + protected final FieldDataType fieldDataType; protected NumericFieldData latFieldData; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoDistanceFilter.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoDistanceFilter.java index 4c4cf918b89..438755105be 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoDistanceFilter.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoDistanceFilter.java @@ -25,7 +25,7 @@ import org.apache.lucene.search.Filter; import org.elasticsearch.common.lucene.docset.GetDocSet; import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import java.io.IOException; @@ -47,12 +47,12 @@ public class GeoDistanceFilter extends Filter { private final String lonFieldName; - private final FieldData.Type fieldDataType; + private final FieldDataType fieldDataType; private final FieldDataCache fieldDataCache; public GeoDistanceFilter(double lat, double lon, double distance, GeoDistance geoDistance, String latFieldName, String lonFieldName, - FieldData.Type fieldDataType, FieldDataCache fieldDataCache) { + FieldDataType fieldDataType, FieldDataCache fieldDataCache) { this.lat = lat; this.lon = lon; this.distance = distance; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoPolygonFilter.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoPolygonFilter.java index ab228e2cdee..7da3dbcdaaa 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoPolygonFilter.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/geo/GeoPolygonFilter.java @@ -24,7 +24,7 @@ import org.apache.lucene.search.DocIdSet; import org.apache.lucene.search.Filter; import org.elasticsearch.common.lucene.docset.GetDocSet; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import java.io.IOException; @@ -40,11 +40,11 @@ public class GeoPolygonFilter extends Filter { private final String lonFieldName; - private final FieldData.Type fieldDataType; + private final FieldDataType fieldDataType; private final FieldDataCache fieldDataCache; - public GeoPolygonFilter(Point[] points, String latFieldName, String lonFieldName, FieldData.Type fieldDataType, FieldDataCache fieldDataCache) { + public GeoPolygonFilter(Point[] points, String latFieldName, String lonFieldName, FieldDataType fieldDataType, FieldDataCache fieldDataCache) { this.points = points; this.latFieldName = latFieldName; this.lonFieldName = lonFieldName; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java index f312bfa4cfa..ea52c10b319 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/FieldDataCache.java @@ -22,6 +22,7 @@ package org.elasticsearch.index.cache.field.data; import org.apache.lucene.index.IndexReader; import org.elasticsearch.common.component.CloseableComponent; import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import java.io.IOException; @@ -30,9 +31,7 @@ import java.io.IOException; */ public interface FieldDataCache extends CloseableComponent { - T cache(Class type, IndexReader reader, String fieldName) throws IOException; - - FieldData cache(FieldData.Type type, IndexReader reader, String fieldName) throws IOException; + FieldData cache(FieldDataType type, IndexReader reader, String fieldName) throws IOException; String type(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java index 8320cdc1261..850496b456f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/none/NoneFieldDataCache.java @@ -27,6 +27,7 @@ import org.elasticsearch.index.AbstractIndexComponent; import org.elasticsearch.index.Index; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.settings.IndexSettings; import java.io.IOException; @@ -41,11 +42,7 @@ public class NoneFieldDataCache extends AbstractIndexComponent implements FieldD logger.debug("Using no field cache"); } - @Override public T cache(Class type, IndexReader reader, String fieldName) throws IOException { - return FieldData.load(type, reader, fieldName); - } - - @Override public FieldData cache(FieldData.Type type, IndexReader reader, String fieldName) throws IOException { + @Override public FieldData cache(FieldDataType type, IndexReader reader, String fieldName) throws IOException { return FieldData.load(type, reader, fieldName); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java index 46165f5a68c..c82ffc49609 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/field/data/support/AbstractConcurrentMapFieldDataCache.java @@ -28,6 +28,7 @@ import org.elasticsearch.index.AbstractIndexComponent; import org.elasticsearch.index.Index; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.settings.IndexSettings; import java.io.IOException; @@ -69,15 +70,7 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC // nothing to do here... } - @Override public FieldData cache(FieldData.Type type, IndexReader reader, String fieldName) throws IOException { - return cache(type.fieldDataClass(), reader, fieldName); - } - - protected ConcurrentMap buildFieldDataMap() { - return ConcurrentCollections.newConcurrentMap(); - } - - @Override public T cache(Class type, IndexReader reader, String fieldName) throws IOException { + @Override public FieldData cache(FieldDataType type, IndexReader reader, String fieldName) throws IOException { ConcurrentMap fieldDataCache = cache.get(reader.getFieldCacheKey()); if (fieldDataCache == null) { synchronized (creationMutex) { @@ -88,10 +81,10 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC } } } - T fieldData = (T) fieldDataCache.get(fieldName); + FieldData fieldData = (FieldData) fieldDataCache.get(fieldName); if (fieldData == null) { synchronized (fieldDataCache) { - fieldData = (T) fieldDataCache.get(fieldName); + fieldData = fieldDataCache.get(fieldName); if (fieldData == null) { fieldData = FieldData.load(type, reader, fieldName); fieldDataCache.put(fieldName, fieldData); @@ -100,4 +93,8 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC } return fieldData; } + + protected ConcurrentMap buildFieldDataMap() { + return ConcurrentCollections.newConcurrentMap(); + } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/DocFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/DocFieldData.java index eb93e7ddc7f..b09fb283d91 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/DocFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/DocFieldData.java @@ -52,7 +52,7 @@ public abstract class DocFieldData { return stringValue(); } - public FieldData.Type getType() { + public FieldDataType getType() { return fieldData.type(); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/FieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/FieldData.java index 31458a75b22..913c651956d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/FieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/FieldData.java @@ -21,22 +21,8 @@ package org.elasticsearch.index.field.data; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldComparator; -import org.apache.lucene.search.FieldComparatorSource; -import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.doubles.DoubleFieldData; -import org.elasticsearch.index.field.data.doubles.DoubleFieldDataComparator; -import org.elasticsearch.index.field.data.floats.FloatFieldData; -import org.elasticsearch.index.field.data.floats.FloatFieldDataComparator; -import org.elasticsearch.index.field.data.ints.IntFieldData; -import org.elasticsearch.index.field.data.ints.IntFieldDataComparator; -import org.elasticsearch.index.field.data.longs.LongFieldData; -import org.elasticsearch.index.field.data.longs.LongFieldDataComparator; -import org.elasticsearch.index.field.data.shorts.ShortFieldData; -import org.elasticsearch.index.field.data.shorts.ShortFieldDataComparator; -import org.elasticsearch.index.field.data.strings.StringFieldData; -import org.elasticsearch.index.field.data.strings.StringOrdValFieldDataComparator; import java.io.IOException; @@ -47,112 +33,6 @@ import java.io.IOException; // TODO Optimize the order (both int[] and int[][] when they are sparse, create an Order abstraction) public abstract class FieldData { - public static enum Type { - STRING() { - - @Override public Class fieldDataClass() { - return StringFieldData.class; - } - - @Override public boolean isNumeric() { - return false; - } - - @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { - return new FieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - return new StringOrdValFieldDataComparator(numHits, fieldname, sortPos, reversed, cache); - } - }; - }}, - SHORT() { - @Override public Class fieldDataClass() { - return ShortFieldData.class; - } - - @Override public boolean isNumeric() { - return true; - } - - @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { - return new FieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - return new ShortFieldDataComparator(numHits, fieldname, cache); - } - }; - }}, - INT() { - @Override public Class fieldDataClass() { - return IntFieldData.class; - } - - @Override public boolean isNumeric() { - return true; - } - - @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { - return new FieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - return new IntFieldDataComparator(numHits, fieldname, cache); - } - }; - }}, - LONG() { - @Override public Class fieldDataClass() { - return LongFieldData.class; - } - - @Override public boolean isNumeric() { - return true; - } - - @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { - return new FieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - return new LongFieldDataComparator(numHits, fieldname, cache); - } - }; - }}, - FLOAT() { - @Override public Class fieldDataClass() { - return FloatFieldData.class; - } - - @Override public boolean isNumeric() { - return true; - } - - @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { - return new FieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - return new FloatFieldDataComparator(numHits, fieldname, cache); - } - }; - }}, - DOUBLE() { - @Override public Class fieldDataClass() { - return DoubleFieldData.class; - } - - @Override public boolean isNumeric() { - return true; - } - - @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { - return new FieldComparatorSource() { - @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - return new DoubleFieldDataComparator(numHits, fieldname, cache); - } - }; - }}; - - public abstract Class fieldDataClass(); - - public abstract boolean isNumeric(); - - public abstract FieldComparatorSource newFieldComparatorSource(FieldDataCache cache); - } - private final ThreadLocal> cachedDocFieldData = new ThreadLocal>() { @Override protected ThreadLocals.CleanableValue initialValue() { return new ThreadLocals.CleanableValue(createFieldData()); @@ -207,29 +87,11 @@ public abstract class FieldData { /** * The type of this field data. */ - public abstract Type type(); + public abstract FieldDataType type(); public abstract FieldComparator newComparator(FieldDataCache fieldDataCache, int numHits, String field, int sortPos, boolean reversed); - public static FieldData load(Type type, IndexReader reader, String fieldName) throws IOException { - return load(type.fieldDataClass(), reader, fieldName); - } - - @SuppressWarnings({"unchecked"}) - public static T load(Class type, IndexReader reader, String fieldName) throws IOException { - if (type == StringFieldData.class) { - return (T) StringFieldData.load(reader, fieldName); - } else if (type == IntFieldData.class) { - return (T) IntFieldData.load(reader, fieldName); - } else if (type == LongFieldData.class) { - return (T) LongFieldData.load(reader, fieldName); - } else if (type == FloatFieldData.class) { - return (T) FloatFieldData.load(reader, fieldName); - } else if (type == DoubleFieldData.class) { - return (T) DoubleFieldData.load(reader, fieldName); - } else if (type == ShortFieldData.class) { - return (T) ShortFieldData.load(reader, fieldName); - } - throw new ElasticSearchIllegalArgumentException("No support for type [" + type + "] to load field data"); + public static FieldData load(FieldDataType type, IndexReader reader, String fieldName) throws IOException { + return type.load(reader, fieldName); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/FieldDataType.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/FieldDataType.java new file mode 100644 index 00000000000..07a0ede24ce --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/FieldDataType.java @@ -0,0 +1,53 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search 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.elasticsearch.index.field.data; + +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.search.FieldComparatorSource; +import org.elasticsearch.index.cache.field.data.FieldDataCache; +import org.elasticsearch.index.field.data.doubles.DoubleFieldDataType; +import org.elasticsearch.index.field.data.floats.FloatFieldDataType; +import org.elasticsearch.index.field.data.ints.IntFieldDataType; +import org.elasticsearch.index.field.data.longs.LongFieldDataType; +import org.elasticsearch.index.field.data.shorts.ShortFieldDataType; +import org.elasticsearch.index.field.data.strings.StringFieldDataType; + +import java.io.IOException; + +/** + * @author kimchy (shay.banon) + */ +public interface FieldDataType { + + public static final class DefaultTypes { + public static final StringFieldDataType STRING = new StringFieldDataType(); + public static final ShortFieldDataType SHORT = new ShortFieldDataType(); + public static final IntFieldDataType INT = new IntFieldDataType(); + public static final LongFieldDataType LONG = new LongFieldDataType(); + public static final FloatFieldDataType FLOAT = new FloatFieldDataType(); + public static final DoubleFieldDataType DOUBLE = new DoubleFieldDataType(); + } + + Class fieldDataClass(); + + FieldComparatorSource newFieldComparatorSource(FieldDataCache cache); + + T load(IndexReader reader, String fieldName) throws IOException; +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldData.java index 1204e9e130b..94715c661d1 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/doubles/DoubleFieldData.java @@ -24,6 +24,7 @@ import org.apache.lucene.search.FieldCache; import org.apache.lucene.search.FieldComparator; import org.elasticsearch.common.trove.TDoubleArrayList; import org.elasticsearch.index.cache.field.data.FieldDataCache; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.field.data.support.FieldDataLoader; @@ -93,8 +94,8 @@ public abstract class DoubleFieldData extends NumericFieldData { + + @Override public Class fieldDataClass() { + return DoubleFieldData.class; + } + + @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { + return new FieldComparatorSource() { + @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + return new DoubleFieldDataComparator(numHits, fieldname, cache); + } + }; + } + + @Override public DoubleFieldData load(IndexReader reader, String fieldName) throws IOException { + return DoubleFieldData.load(reader, fieldName); + } +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldData.java index 428557d9729..b219da0af4b 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldData.java @@ -24,6 +24,7 @@ import org.apache.lucene.search.FieldCache; import org.apache.lucene.search.FieldComparator; import org.elasticsearch.common.trove.TFloatArrayList; import org.elasticsearch.index.cache.field.data.FieldDataCache; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.field.data.support.FieldDataLoader; @@ -93,8 +94,8 @@ public abstract class FloatFieldData extends NumericFieldData return (double) value(docId); } - @Override public Type type() { - return Type.FLOAT; + @Override public FieldDataType type() { + return FieldDataType.DefaultTypes.FLOAT; } public void forEachValue(ValueProc proc) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataComparator.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataComparator.java index 5a2a27364ad..e8d3328c103 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataComparator.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataComparator.java @@ -20,7 +20,7 @@ package org.elasticsearch.index.field.data.floats; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** @@ -37,8 +37,8 @@ public class FloatFieldDataComparator extends NumericFieldDataComparator { values = new float[numHits]; } - @Override public FieldData.Type fieldDataType() { - return FieldData.Type.FLOAT; + @Override public FieldDataType fieldDataType() { + return FieldDataType.DefaultTypes.FLOAT; } @Override public int compare(int slot1, int slot2) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java new file mode 100644 index 00000000000..9bce9aaf757 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/floats/FloatFieldDataType.java @@ -0,0 +1,50 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search 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.elasticsearch.index.field.data.floats; + +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.search.FieldComparator; +import org.apache.lucene.search.FieldComparatorSource; +import org.elasticsearch.index.cache.field.data.FieldDataCache; +import org.elasticsearch.index.field.data.FieldDataType; + +import java.io.IOException; + +/** + * @author kimchy (shay.banon) + */ +public class FloatFieldDataType implements FieldDataType { + + @Override public Class fieldDataClass() { + return FloatFieldData.class; + } + + @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { + return new FieldComparatorSource() { + @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + return new FloatFieldDataComparator(numHits, fieldname, cache); + } + }; + } + + @Override public FloatFieldData load(IndexReader reader, String fieldName) throws IOException { + return FloatFieldData.load(reader, fieldName); + } +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldData.java index d81f447d717..5ee38e99415 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldData.java @@ -24,6 +24,7 @@ import org.apache.lucene.search.FieldCache; import org.apache.lucene.search.FieldComparator; import org.elasticsearch.common.trove.TIntArrayList; import org.elasticsearch.index.cache.field.data.FieldDataCache; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.field.data.support.FieldDataLoader; @@ -93,8 +94,8 @@ public abstract class IntFieldData extends NumericFieldData { return (double) value(docId); } - @Override public Type type() { - return Type.INT; + @Override public FieldDataType type() { + return FieldDataType.DefaultTypes.INT; } public void forEachValue(ValueProc proc) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataComparator.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataComparator.java index 18d63f6aa74..68007c133b0 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataComparator.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataComparator.java @@ -20,7 +20,7 @@ package org.elasticsearch.index.field.data.ints; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** @@ -38,8 +38,8 @@ public class IntFieldDataComparator extends NumericFieldDataComparator { values = new int[numHits]; } - @Override public FieldData.Type fieldDataType() { - return FieldData.Type.INT; + @Override public FieldDataType fieldDataType() { + return FieldDataType.DefaultTypes.INT; } @Override public int compare(int slot1, int slot2) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataType.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataType.java new file mode 100644 index 00000000000..cb3493c8dc8 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/ints/IntFieldDataType.java @@ -0,0 +1,50 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search 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.elasticsearch.index.field.data.ints; + +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.search.FieldComparator; +import org.apache.lucene.search.FieldComparatorSource; +import org.elasticsearch.index.cache.field.data.FieldDataCache; +import org.elasticsearch.index.field.data.FieldDataType; + +import java.io.IOException; + +/** + * @author kimchy (shay.banon) + */ +public class IntFieldDataType implements FieldDataType { + + @Override public Class fieldDataClass() { + return IntFieldData.class; + } + + @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { + return new FieldComparatorSource() { + @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + return new IntFieldDataComparator(numHits, fieldname, cache); + } + }; + } + + @Override public IntFieldData load(IndexReader reader, String fieldName) throws IOException { + return IntFieldData.load(reader, fieldName); + } +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java index 1954306c497..134c8b38a00 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldData.java @@ -26,6 +26,7 @@ import org.elasticsearch.common.joda.time.MutableDateTime; import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.common.trove.TLongArrayList; import org.elasticsearch.index.cache.field.data.FieldDataCache; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.field.data.support.FieldDataLoader; @@ -110,8 +111,8 @@ public abstract class LongFieldData extends NumericFieldData { return (double) value(docId); } - @Override public Type type() { - return Type.LONG; + @Override public FieldDataType type() { + return FieldDataType.DefaultTypes.LONG; } public void forEachValue(ValueProc proc) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataComparator.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataComparator.java index 51f86cc7aa7..47c964c0e4d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataComparator.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataComparator.java @@ -20,7 +20,7 @@ package org.elasticsearch.index.field.data.longs; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** @@ -37,8 +37,8 @@ public class LongFieldDataComparator extends NumericFieldDataComparator { values = new long[numHits]; } - @Override public FieldData.Type fieldDataType() { - return FieldData.Type.LONG; + @Override public FieldDataType fieldDataType() { + return FieldDataType.DefaultTypes.LONG; } @Override public int compare(int slot1, int slot2) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataType.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataType.java new file mode 100644 index 00000000000..9814a058d03 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/longs/LongFieldDataType.java @@ -0,0 +1,50 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search 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.elasticsearch.index.field.data.longs; + +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.search.FieldComparator; +import org.apache.lucene.search.FieldComparatorSource; +import org.elasticsearch.index.cache.field.data.FieldDataCache; +import org.elasticsearch.index.field.data.FieldDataType; + +import java.io.IOException; + +/** + * @author kimchy (shay.banon) + */ +public class LongFieldDataType implements FieldDataType { + + @Override public Class fieldDataClass() { + return LongFieldData.class; + } + + @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { + return new FieldComparatorSource() { + @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + return new LongFieldDataComparator(numHits, fieldname, cache); + } + }; + } + + @Override public LongFieldData load(IndexReader reader, String fieldName) throws IOException { + return LongFieldData.load(reader, fieldName); + } +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldData.java index c0b119a6cc5..0c13f5ba3cf 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldData.java @@ -24,6 +24,7 @@ import org.apache.lucene.search.FieldCache; import org.apache.lucene.search.FieldComparator; import org.elasticsearch.common.trove.TShortArrayList; import org.elasticsearch.index.cache.field.data.FieldDataCache; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.field.data.support.FieldDataLoader; @@ -93,8 +94,8 @@ public abstract class ShortFieldData extends NumericFieldData return (double) value(docId); } - @Override public Type type() { - return Type.SHORT; + @Override public FieldDataType type() { + return FieldDataType.DefaultTypes.SHORT; } public void forEachValue(ValueProc proc) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataComparator.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataComparator.java index 0fdc05ca67f..0629d77ff30 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataComparator.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataComparator.java @@ -20,7 +20,7 @@ package org.elasticsearch.index.field.data.shorts; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.NumericFieldDataComparator; /** @@ -37,8 +37,8 @@ public class ShortFieldDataComparator extends NumericFieldDataComparator { values = new short[numHits]; } - @Override public FieldData.Type fieldDataType() { - return FieldData.Type.SHORT; + @Override public FieldDataType fieldDataType() { + return FieldDataType.DefaultTypes.SHORT; } @Override public int compare(int slot1, int slot2) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataType.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataType.java new file mode 100644 index 00000000000..15769b45e6a --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataType.java @@ -0,0 +1,50 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search 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.elasticsearch.index.field.data.shorts; + +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.search.FieldComparator; +import org.apache.lucene.search.FieldComparatorSource; +import org.elasticsearch.index.cache.field.data.FieldDataCache; +import org.elasticsearch.index.field.data.FieldDataType; + +import java.io.IOException; + +/** + * @author kimchy (shay.banon) + */ +public class ShortFieldDataType implements FieldDataType { + + @Override public Class fieldDataClass() { + return ShortFieldData.class; + } + + @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { + return new FieldComparatorSource() { + @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + return new ShortFieldDataComparator(numHits, fieldname, cache); + } + }; + } + + @Override public ShortFieldData load(IndexReader reader, String fieldName) throws IOException { + return ShortFieldData.load(reader, fieldName); + } +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldData.java index acbce180adb..fc570506b42 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldData.java @@ -21,6 +21,7 @@ package org.elasticsearch.index.field.data.strings; import org.apache.lucene.index.IndexReader; import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.support.FieldDataLoader; import java.io.IOException; @@ -54,8 +55,8 @@ public abstract class StringFieldData extends FieldData { return new StringDocFieldData(this); } - @Override public Type type() { - return Type.STRING; + @Override public FieldDataType type() { + return FieldDataType.DefaultTypes.STRING; } @Override public void forEachValue(StringValueProc proc) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldDataType.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldDataType.java new file mode 100644 index 00000000000..1ddbb3e9048 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringFieldDataType.java @@ -0,0 +1,50 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search 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.elasticsearch.index.field.data.strings; + +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.search.FieldComparator; +import org.apache.lucene.search.FieldComparatorSource; +import org.elasticsearch.index.cache.field.data.FieldDataCache; +import org.elasticsearch.index.field.data.FieldDataType; + +import java.io.IOException; + +/** + * @author kimchy (shay.banon) + */ +public class StringFieldDataType implements FieldDataType { + + @Override public Class fieldDataClass() { + return StringFieldData.class; + } + + @Override public FieldComparatorSource newFieldComparatorSource(final FieldDataCache cache) { + return new FieldComparatorSource() { + @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { + return new StringOrdValFieldDataComparator(numHits, fieldname, sortPos, reversed, cache); + } + }; + } + + @Override public StringFieldData load(IndexReader reader, String fieldName) throws IOException { + return StringFieldData.load(reader, fieldName); + } +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringOrdValFieldDataComparator.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringOrdValFieldDataComparator.java index ecb21bd3726..47daf70f7d3 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringOrdValFieldDataComparator.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringOrdValFieldDataComparator.java @@ -23,6 +23,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldComparator; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import java.io.IOException; @@ -140,7 +141,7 @@ public class StringOrdValFieldDataComparator extends FieldComparator { } @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { - FieldData cleanFieldData = fieldDataCache.cache(FieldData.Type.STRING, reader, field); + FieldData cleanFieldData = fieldDataCache.cache(FieldDataType.DefaultTypes.STRING, reader, field); if (cleanFieldData instanceof MultiValueStringFieldData) { throw new IOException("Can't sort on string types with more than one value per doc, or more than one token per field"); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringValFieldDataComparator.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringValFieldDataComparator.java index 9509965c05b..06b702bf73d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringValFieldDataComparator.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/strings/StringValFieldDataComparator.java @@ -23,6 +23,7 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldComparator; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import java.io.IOException; @@ -81,7 +82,7 @@ public class StringValFieldDataComparator extends FieldComparator { } @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { - currentFieldData = fieldDataCache.cache(FieldData.Type.STRING, reader, fieldName); + currentFieldData = fieldDataCache.cache(FieldDataType.DefaultTypes.STRING, reader, fieldName); } @Override public void setBottom(final int bottom) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/support/NumericFieldDataComparator.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/support/NumericFieldDataComparator.java index 1d57215b478..38d9c26ee05 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/support/NumericFieldDataComparator.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/data/support/NumericFieldDataComparator.java @@ -22,7 +22,7 @@ package org.elasticsearch.index.field.data.support; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.FieldComparator; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import java.io.IOException; @@ -43,7 +43,7 @@ public abstract class NumericFieldDataComparator extends FieldComparator { this.fieldDataCache = fieldDataCache; } - public abstract FieldData.Type fieldDataType(); + public abstract FieldDataType fieldDataType(); @Override public void setNextReader(IndexReader reader, int docBase) throws IOException { currentFieldData = (NumericFieldData) fieldDataCache.cache(fieldDataType(), reader, fieldName); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java index eea6f670363..78664809f7c 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java @@ -27,7 +27,7 @@ import org.apache.lucene.search.Filter; import org.apache.lucene.search.Query; import org.elasticsearch.common.util.concurrent.Immutable; import org.elasticsearch.common.util.concurrent.ThreadSafe; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; /** * @author kimchy (Shay Banon) @@ -163,5 +163,5 @@ public interface FieldMapper { */ Filter rangeFilter(String lowerTerm, String upperTerm, boolean includeLower, boolean includeUpper); - FieldData.Type fieldDataType(); + FieldDataType fieldDataType(); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentBoostFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentBoostFieldMapper.java index e3976821d4e..66fb793b67c 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentBoostFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentBoostFieldMapper.java @@ -31,7 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericFloatAnalyzer; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.mapper.BoostFieldMapper; import org.elasticsearch.index.mapper.MergeMappingException; @@ -168,8 +168,8 @@ public class XContentBoostFieldMapper extends XContentNumberFieldMapper i return value; } - @Override public FieldData.Type fieldDataType() { - return FieldData.Type.FLOAT; + @Override public FieldDataType fieldDataType() { + return FieldDataType.DefaultTypes.FLOAT; } @Override protected String contentType() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDateFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDateFieldMapper.java index 62cb63b17cb..a0ae0959958 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDateFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDateFieldMapper.java @@ -34,7 +34,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericDateAnalyzer; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.MergeMappingException; @@ -202,8 +202,8 @@ public class XContentDateFieldMapper extends XContentNumberFieldMapper { return field; } - @Override public FieldData.Type fieldDataType() { - return FieldData.Type.LONG; + @Override public FieldDataType fieldDataType() { + return FieldDataType.DefaultTypes.LONG; } @Override protected String contentType() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDoubleFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDoubleFieldMapper.java index 55b8b0a09f6..764fa89796b 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDoubleFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentDoubleFieldMapper.java @@ -31,7 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericDoubleAnalyzer; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.MergeMappingException; @@ -184,8 +184,8 @@ public class XContentDoubleFieldMapper extends XContentNumberFieldMapper return field; } - @Override public FieldData.Type fieldDataType() { - return FieldData.Type.DOUBLE; + @Override public FieldDataType fieldDataType() { + return FieldDataType.DefaultTypes.DOUBLE; } @Override protected String contentType() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFieldMapper.java index 56ece576775..958b8631c01 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFieldMapper.java @@ -28,7 +28,7 @@ import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.lucene.search.TermFilter; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.analysis.NamedAnalyzer; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.FieldMapperListener; import org.elasticsearch.index.mapper.MapperParsingException; @@ -384,8 +384,8 @@ public abstract class XContentFieldMapper implements FieldMapper, XContent } } - @Override public FieldData.Type fieldDataType() { - return FieldData.Type.STRING; + @Override public FieldDataType fieldDataType() { + return FieldDataType.DefaultTypes.STRING; } @Override public void toXContent(XContentBuilder builder, Params params) throws IOException { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFloatFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFloatFieldMapper.java index 2ee6c8cda95..0dcdc0dec8c 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFloatFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentFloatFieldMapper.java @@ -32,7 +32,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericFloatAnalyzer; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.MergeMappingException; @@ -183,8 +183,8 @@ public class XContentFloatFieldMapper extends XContentNumberFieldMapper { return field; } - @Override public FieldData.Type fieldDataType() { - return FieldData.Type.FLOAT; + @Override public FieldDataType fieldDataType() { + return FieldDataType.DefaultTypes.FLOAT; } @Override protected String contentType() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentIntegerFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentIntegerFieldMapper.java index 5db93fd7c54..8290b991ee0 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentIntegerFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentIntegerFieldMapper.java @@ -32,7 +32,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericIntegerAnalyzer; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.MergeMappingException; @@ -183,8 +183,8 @@ public class XContentIntegerFieldMapper extends XContentNumberFieldMapper { return field; } - @Override public FieldData.Type fieldDataType() { - return FieldData.Type.LONG; + @Override public FieldDataType fieldDataType() { + return FieldDataType.DefaultTypes.LONG; } @Override protected String contentType() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentNumberFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentNumberFieldMapper.java index d32b601e779..54160a6a8e5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentNumberFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentNumberFieldMapper.java @@ -30,7 +30,7 @@ import org.elasticsearch.common.thread.ThreadLocals; import org.elasticsearch.common.trove.TIntObjectHashMap; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.analysis.NamedAnalyzer; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.mapper.MergeMappingException; import java.io.IOException; @@ -171,7 +171,7 @@ public abstract class XContentNumberFieldMapper extends XConte builder.field("precision_step", precisionStep); } - @Override public abstract FieldData.Type fieldDataType(); + @Override public abstract FieldDataType fieldDataType(); /** * Removes a cached numeric token stream. The stream will be returned to the cahed once it is used diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentShortFieldMapper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentShortFieldMapper.java index 26a490b1d59..db5adaaf41e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentShortFieldMapper.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/xcontent/XContentShortFieldMapper.java @@ -32,7 +32,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.analysis.NumericIntegerAnalyzer; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.MergeMappingException; @@ -183,8 +183,8 @@ public class XContentShortFieldMapper extends XContentNumberFieldMapper { return field; } - @Override public FieldData.Type fieldDataType() { - return FieldData.Type.SHORT; + @Override public FieldDataType fieldDataType() { + return FieldDataType.DefaultTypes.SHORT; } @Override protected String contentType() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/GeoDistanceFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/GeoDistanceFacetCollector.java index 8c33871a904..1a377f059e5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/GeoDistanceFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/GeoDistanceFacetCollector.java @@ -23,7 +23,7 @@ import org.apache.lucene.index.IndexReader; import org.elasticsearch.common.lucene.geo.GeoDistance; import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; @@ -56,7 +56,7 @@ public class GeoDistanceFacetCollector extends AbstractFacetCollector { protected final FieldDataCache fieldDataCache; - protected final FieldData.Type fieldDataType; + protected final FieldDataType fieldDataType; protected NumericFieldData latFieldData; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/ValueGeoDistanceFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/ValueGeoDistanceFacetCollector.java index 4cbf3f93ef2..e8b4809da63 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/ValueGeoDistanceFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/geodistance/ValueGeoDistanceFacetCollector.java @@ -22,7 +22,7 @@ package org.elasticsearch.search.facets.geodistance; import org.apache.lucene.index.IndexReader; import org.elasticsearch.common.lucene.geo.GeoDistance; import org.elasticsearch.common.unit.DistanceUnit; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.search.facets.Facet; @@ -40,7 +40,7 @@ public class ValueGeoDistanceFacetCollector extends GeoDistanceFacetCollector { private final String indexValueFieldName; - private final FieldData.Type valueFieldDataType; + private final FieldDataType valueFieldDataType; private NumericFieldData valueFieldData; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/histogram/HistogramFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/histogram/HistogramFacetCollector.java index 2414d4d6301..2b3236a8526 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/histogram/HistogramFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/histogram/HistogramFacetCollector.java @@ -23,7 +23,7 @@ import org.apache.lucene.index.IndexReader; import org.elasticsearch.common.trove.TLongDoubleHashMap; import org.elasticsearch.common.trove.TLongLongHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; @@ -52,7 +52,7 @@ public class HistogramFacetCollector extends AbstractFacetCollector { private final FieldDataCache fieldDataCache; - private final FieldData.Type fieldDataType; + private final FieldDataType fieldDataType; private NumericFieldData fieldData; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/histogram/KeyValueHistogramFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/histogram/KeyValueHistogramFacetCollector.java index 40490fa84a3..95d225a8251 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/histogram/KeyValueHistogramFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/histogram/KeyValueHistogramFacetCollector.java @@ -23,7 +23,7 @@ import org.apache.lucene.index.IndexReader; import org.elasticsearch.common.trove.TLongDoubleHashMap; import org.elasticsearch.common.trove.TLongLongHashMap; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; @@ -53,10 +53,10 @@ public class KeyValueHistogramFacetCollector extends AbstractFacetCollector { private final FieldDataCache fieldDataCache; - private final FieldData.Type keyFieldDataType; + private final FieldDataType keyFieldDataType; private NumericFieldData keyFieldData; - private final FieldData.Type valueFieldDataType; + private final FieldDataType valueFieldDataType; private NumericFieldData valueFieldData; private final TLongLongHashMap counts = new TLongLongHashMap(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/KeyValueRangeFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/KeyValueRangeFacetCollector.java index e6ec3a4e329..85e5b230f9a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/KeyValueRangeFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/KeyValueRangeFacetCollector.java @@ -21,7 +21,7 @@ package org.elasticsearch.search.facets.range; import org.apache.lucene.index.IndexReader; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; @@ -45,10 +45,10 @@ public class KeyValueRangeFacetCollector extends AbstractFacetCollector { private final FieldDataCache fieldDataCache; - private final FieldData.Type keyFieldDataType; + private final FieldDataType keyFieldDataType; private NumericFieldData keyFieldData; - private final FieldData.Type valueFieldDataType; + private final FieldDataType valueFieldDataType; private NumericFieldData valueFieldData; private final RangeFacet.Entry[] entries; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/RangeFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/RangeFacetCollector.java index 759d8d81a0a..9df9a303850 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/RangeFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/range/RangeFacetCollector.java @@ -21,7 +21,7 @@ package org.elasticsearch.search.facets.range; import org.apache.lucene.index.IndexReader; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.search.facets.Facet; @@ -42,7 +42,7 @@ public class RangeFacetCollector extends AbstractFacetCollector { private final FieldDataCache fieldDataCache; - private final FieldData.Type fieldDataType; + private final FieldDataType fieldDataType; private NumericFieldData fieldData; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/statistical/StatisticalFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/statistical/StatisticalFacetCollector.java index 9e579f97714..370f0aca417 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/statistical/StatisticalFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/statistical/StatisticalFacetCollector.java @@ -21,7 +21,7 @@ package org.elasticsearch.search.facets.statistical; import org.apache.lucene.index.IndexReader; import org.elasticsearch.index.cache.field.data.FieldDataCache; -import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.field.data.NumericFieldData; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.search.facets.Facet; @@ -42,7 +42,7 @@ public class StatisticalFacetCollector extends AbstractFacetCollector { private final FieldDataCache fieldDataCache; - private final FieldData.Type fieldDataType; + private final FieldDataType fieldDataType; private NumericFieldData fieldData; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/terms/TermsFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/terms/TermsFacetCollector.java index a23c4e01267..1c9ae4aa22f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/terms/TermsFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/terms/TermsFacetCollector.java @@ -29,6 +29,7 @@ import org.elasticsearch.common.trove.TObjectIntHashMap; import org.elasticsearch.common.trove.TObjectIntIterator; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.script.search.SearchScript; import org.elasticsearch.search.facets.Facet; @@ -66,7 +67,7 @@ public class TermsFacetCollector extends AbstractFacetCollector { private final int numberOfShards; - private final FieldData.Type fieldDataType; + private final FieldDataType fieldDataType; private FieldData fieldData; @@ -87,7 +88,7 @@ public class TermsFacetCollector extends AbstractFacetCollector { MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { this.indexFieldName = fieldName; - this.fieldDataType = FieldData.Type.STRING; + this.fieldDataType = FieldDataType.DefaultTypes.STRING; } else { // add type filter if there is exact doc mapper associated with it if (smartMappers.hasDocMapper()) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/terms/TermsFieldsFacetCollector.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/terms/TermsFieldsFacetCollector.java index 65fe9ebe266..af4e6c29f79 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/terms/TermsFieldsFacetCollector.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/facets/terms/TermsFieldsFacetCollector.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.trove.TObjectIntHashMap; import org.elasticsearch.common.trove.TObjectIntIterator; import org.elasticsearch.index.cache.field.data.FieldDataCache; import org.elasticsearch.index.field.data.FieldData; +import org.elasticsearch.index.field.data.FieldDataType; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.script.search.SearchScript; import org.elasticsearch.search.facets.Facet; @@ -58,7 +59,7 @@ public class TermsFieldsFacetCollector extends AbstractFacetCollector { private final int numberOfShards; - private final FieldData.Type[] fieldsDataType; + private final FieldDataType[] fieldsDataType; private FieldData[] fieldsData; @@ -76,7 +77,7 @@ public class TermsFieldsFacetCollector extends AbstractFacetCollector { this.fieldsNames = fieldsNames; - fieldsDataType = new FieldData.Type[fieldsNames.length]; + fieldsDataType = new FieldDataType[fieldsNames.length]; fieldsData = new FieldData[fieldsNames.length]; indexFieldsNames = new String[fieldsNames.length]; @@ -84,7 +85,7 @@ public class TermsFieldsFacetCollector extends AbstractFacetCollector { MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldsNames[i]); if (smartMappers == null || !smartMappers.hasMapper()) { this.indexFieldsNames[i] = fieldsNames[i]; - this.fieldsDataType[i] = FieldData.Type.STRING; + this.fieldsDataType[i] = FieldDataType.DefaultTypes.STRING; } else { this.indexFieldsNames[i] = smartMappers.mapper().names().indexName(); this.fieldsDataType[i] = smartMappers.mapper().fieldDataType(); diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataTests.java index 1f1f25e4fa9..53e9aab207a 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/doubles/DoubleFieldDataTests.java @@ -25,7 +25,6 @@ import org.apache.lucene.index.IndexWriter; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; -import org.elasticsearch.index.field.data.FieldData; import org.testng.annotations.Test; import java.util.ArrayList; @@ -72,11 +71,9 @@ public class DoubleFieldDataTests { DoubleFieldData mFieldData = DoubleFieldData.load(reader, "mvalue"); assertThat(sFieldData.fieldName(), equalTo("svalue")); - assertThat(sFieldData.type(), equalTo(FieldData.Type.DOUBLE)); assertThat(sFieldData.multiValued(), equalTo(false)); assertThat(mFieldData.fieldName(), equalTo("mvalue")); - assertThat(mFieldData.type(), equalTo(FieldData.Type.DOUBLE)); assertThat(mFieldData.multiValued(), equalTo(true)); // svalue diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/floats/FloatFieldDataTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/floats/FloatFieldDataTests.java index 5f770f4e49a..8dfd37432bb 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/floats/FloatFieldDataTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/floats/FloatFieldDataTests.java @@ -25,7 +25,6 @@ import org.apache.lucene.index.IndexWriter; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; -import org.elasticsearch.index.field.data.FieldData; import org.testng.annotations.Test; import java.util.ArrayList; @@ -72,11 +71,9 @@ public class FloatFieldDataTests { FloatFieldData mFieldData = FloatFieldData.load(reader, "mvalue"); assertThat(sFieldData.fieldName(), equalTo("svalue")); - assertThat(sFieldData.type(), equalTo(FieldData.Type.FLOAT)); assertThat(sFieldData.multiValued(), equalTo(false)); assertThat(mFieldData.fieldName(), equalTo("mvalue")); - assertThat(mFieldData.type(), equalTo(FieldData.Type.FLOAT)); assertThat(mFieldData.multiValued(), equalTo(true)); // svalue diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/ints/IntFieldDataTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/ints/IntFieldDataTests.java index 2d60d8943eb..4eced60511e 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/ints/IntFieldDataTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/ints/IntFieldDataTests.java @@ -25,7 +25,6 @@ import org.apache.lucene.index.IndexWriter; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; -import org.elasticsearch.index.field.data.FieldData; import org.testng.annotations.Test; import java.util.ArrayList; @@ -72,11 +71,9 @@ public class IntFieldDataTests { IntFieldData mFieldData = IntFieldData.load(reader, "mvalue"); assertThat(sFieldData.fieldName(), equalTo("svalue")); - assertThat(sFieldData.type(), equalTo(FieldData.Type.INT)); assertThat(sFieldData.multiValued(), equalTo(false)); assertThat(mFieldData.fieldName(), equalTo("mvalue")); - assertThat(mFieldData.type(), equalTo(FieldData.Type.INT)); assertThat(mFieldData.multiValued(), equalTo(true)); // svalue diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/longs/LongFieldDataTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/longs/LongFieldDataTests.java index 6f5597dda44..f7985e29f52 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/longs/LongFieldDataTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/longs/LongFieldDataTests.java @@ -25,7 +25,6 @@ import org.apache.lucene.index.IndexWriter; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; -import org.elasticsearch.index.field.data.FieldData; import org.testng.annotations.Test; import java.util.ArrayList; @@ -72,11 +71,9 @@ public class LongFieldDataTests { LongFieldData mFieldData = LongFieldData.load(reader, "mvalue"); assertThat(sFieldData.fieldName(), equalTo("svalue")); - assertThat(sFieldData.type(), equalTo(FieldData.Type.LONG)); assertThat(sFieldData.multiValued(), equalTo(false)); assertThat(mFieldData.fieldName(), equalTo("mvalue")); - assertThat(mFieldData.type(), equalTo(FieldData.Type.LONG)); assertThat(mFieldData.multiValued(), equalTo(true)); // svalue diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataTests.java index d231041b12e..e7ceb529105 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/shorts/ShortFieldDataTests.java @@ -25,7 +25,6 @@ import org.apache.lucene.index.IndexWriter; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.elasticsearch.common.lucene.Lucene; -import org.elasticsearch.index.field.data.FieldData; import org.testng.annotations.Test; import java.util.ArrayList; @@ -72,11 +71,9 @@ public class ShortFieldDataTests { ShortFieldData mFieldData = ShortFieldData.load(reader, "mvalue"); assertThat(sFieldData.fieldName(), equalTo("svalue")); - assertThat(sFieldData.type(), equalTo(FieldData.Type.SHORT)); assertThat(sFieldData.multiValued(), equalTo(false)); assertThat(mFieldData.fieldName(), equalTo("mvalue")); - assertThat(mFieldData.type(), equalTo(FieldData.Type.SHORT)); assertThat(mFieldData.multiValued(), equalTo(true)); // svalue diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/strings/StringFieldDataTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/strings/StringFieldDataTests.java index 0455c4ba8b3..36f4b32b534 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/strings/StringFieldDataTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/field/data/strings/StringFieldDataTests.java @@ -65,11 +65,9 @@ public class StringFieldDataTests { StringFieldData mFieldData = StringFieldData.load(reader, "mvalue"); assertThat(sFieldData.fieldName(), equalTo("svalue")); - assertThat(sFieldData.type(), equalTo(FieldData.Type.STRING)); assertThat(sFieldData.multiValued(), equalTo(false)); assertThat(mFieldData.fieldName(), equalTo("mvalue")); - assertThat(mFieldData.type(), equalTo(FieldData.Type.STRING)); assertThat(mFieldData.multiValued(), equalTo(true)); // svalue