Apache Solr open-source search software
LUCENE-3850: Removed some of the rawtypes compiler warnings
Martijn van Groningen1c91c60468a1
diff --git a/modules/grouping/src/java/org/apache/lucene/search/grouping/dv/DVAllGroupHeadsCollector.java b/modules/grouping/src/java/org/apache/lucene/search/grouping/dv/DVAllGroupHeadsCollector.javaindex b97a83ab128..cc914a79734 100644--- a/modules/grouping/src/java/org/apache/lucene/search/grouping/dv/DVAllGroupHeadsCollector.java+++ b/modules/grouping/src/java/org/apache/lucene/search/grouping/dv/DVAllGroupHeadsCollector.java@@ -67,25 +67,27 @@ public abstract class DVAllGroupHeadsCollector<GH extends AbstractAllGroupHeadsC* @return an <code>AbstractAllGroupHeadsCollector</code> instance based on the supplied arguments* @throws IOException If I/O related errors occur*/- public static AbstractAllGroupHeadsCollector<?> create(String groupField, Sort sortWithinGroup, DocValues.Type type, boolean diskResident) throws IOException {+ @SuppressWarnings("unchecked")+ public static <T extends AbstractAllGroupHeadsCollector.GroupHead<?>> DVAllGroupHeadsCollector<T> create(String groupField, Sort sortWithinGroup, DocValues.Type type, boolean diskResident) throws IOException {switch (type) {case VAR_INTS:case FIXED_INTS_8:case FIXED_INTS_16:case FIXED_INTS_32:case FIXED_INTS_64:- return new GeneralAllGroupHeadsCollector.Lng(groupField, type, sortWithinGroup, diskResident);+ // Type erasure b/c otherwise we have inconvertible types...+ return (DVAllGroupHeadsCollector) new GeneralAllGroupHeadsCollector.Lng(groupField, type, sortWithinGroup, diskResident);case FLOAT_32:case FLOAT_64:- return new GeneralAllGroupHeadsCollector.Dbl(groupField, type, sortWithinGroup, diskResident);+ return (DVAllGroupHeadsCollector) new GeneralAllGroupHeadsCollector.Dbl(groupField, type, sortWithinGroup, diskResident);case BYTES_FIXED_STRAIGHT:case BYTES_FIXED_DEREF:case BYTES_VAR_STRAIGHT:case BYTES_VAR_DEREF:- return new GeneralAllGroupHeadsCollector.BR(groupField, type, sortWithinGroup, diskResident);+ return (DVAllGroupHeadsCollector) new GeneralAllGroupHeadsCollector.BR(groupField, type, sortWithinGroup, diskResident);case BYTES_VAR_SORTED:case BYTES_FIXED_SORTED:- return new GeneralAllGroupHeadsCollector.SortedBR(groupField, type, sortWithinGroup, diskResident);+ return (DVAllGroupHeadsCollector) new GeneralAllGroupHeadsCollector.SortedBR(groupField, type, sortWithinGroup, diskResident);default:throw new IllegalArgumentException(String.format("ValueType %s not supported", type));}diff --git a/modules/grouping/src/java/org/apache/lucene/search/grouping/dv/DVAllGroupsCollector.java b/modules/grouping/src/java/org/apache/lucene/search/grouping/dv/DVAllGroupsCollector.javaindex 5e2c5d3c278..893239a3e38 100644--- a/modules/grouping/src/java/org/apache/lucene/search/grouping/dv/DVAllGroupsCollector.java+++ b/modules/grouping/src/java/org/apache/lucene/search/grouping/dv/DVAllGroupsCollector.java@@ -52,25 +52,30 @@ public abstract class DVAllGroupsCollector<GROUP_VALUE_TYPE> extends AbstractAll* heap usage is 4 bytes * initialSize. Not all concrete implementions use this!* @return the most optimal all groups collector implementation for grouping by {@link DocValues}*/- public static DVAllGroupsCollector<?> create(String groupField, DocValues.Type type, boolean diskResident, int initialSize) {+ @SuppressWarnings("unchecked")+ public static <T> DVAllGroupsCollector<T> create(String groupField, DocValues.Type type, boolean diskResident, int initialSize) {switch (type) {case VAR_INTS:case FIXED_INTS_8:case FIXED_INTS_16:case FIXED_INTS_32:case FIXED_INTS_64:- return new Lng(groupField, type, diskResident);+ // Type erasure b/c otherwise we have inconvertible types...+ return (DVAllGroupsCollector) new Lng(groupField, type, diskResident);case FLOAT_32:case FLOAT_64:- return new Dbl(groupField, type, diskResident);+ // Type erasure b/c otherwise we have inconvertible types...+ return (DVAllGroupsCollector) new Dbl(groupField, type, diskResident);case BYTES_FIXED_STRAIGHT:case BYTES_FIXED_DEREF:case BYTES_VAR_STRAIGHT:case BYTES_VAR_DEREF:- return new BR(groupField, type, diskResident);+ // Type erasure b/c otherwise we have inconvertible types...+ return (DVAllGroupsCollector) new BR(groupField, type, diskResident);case BYTES_VAR_SORTED:case BYTES_FIXED_SORTED:- return new SortedBR(groupField, type, diskResident, initialSize);+ // Type erasure b/c otherwise we have inconvertible types...+ return (DVAllGroupsCollector) new SortedBR(groupField, type, diskResident, initialSize);default:throw new IllegalArgumentException(String.format("ValueType %s not supported", type));}@@ -87,7 +92,7 @@ public abstract class DVAllGroupsCollector<GROUP_VALUE_TYPE> extends AbstractAll* @param diskResident Wether the values to group by should be disk resident* @return the most optimal all groups collector implementation for grouping by {@link DocValues}*/- public static DVAllGroupsCollector<?> create(String groupField, DocValues.Type type, boolean diskResident) {+ public static <T> DVAllGroupsCollector<T> create(String groupField, DocValues.Type type, boolean diskResident) {return create(groupField, type, diskResident, DEFAULT_INITIAL_SIZE);}diff --git a/modules/grouping/src/test/org/apache/lucene/search/grouping/AllGroupHeadsCollectorTest.java b/modules/grouping/src/test/org/apache/lucene/search/grouping/AllGroupHeadsCollectorTest.javaindex 8d4368ab4e9..c19236c3ffd 100644--- a/modules/grouping/src/test/org/apache/lucene/search/grouping/AllGroupHeadsCollectorTest.java+++ b/modules/grouping/src/test/org/apache/lucene/search/grouping/AllGroupHeadsCollectorTest.java@@ -507,7 +507,7 @@ public class AllGroupHeadsCollectorTest extends LuceneTestCase {}private AbstractAllGroupHeadsCollector<?> createRandomCollector(String groupField, Sort sortWithinGroup, boolean canUseIDV, Type valueType) throws IOException {- AbstractAllGroupHeadsCollector<?> collector;+ AbstractAllGroupHeadsCollector<? extends AbstractAllGroupHeadsCollector.GroupHead> collector;if (random.nextBoolean()) {ValueSource vs = new BytesRefFieldSource(groupField);collector = new FunctionAllGroupHeadsCollector(vs, new HashMap<Object, Object>(), sortWithinGroup);