LUCENE-3850: Removed some of the rawtypes compiler warnings

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1298395 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Martijn van Groningen 2012-03-08 13:59:33 +00:00
parent 424bf9a427
commit 1c91c60468
3 changed files with 19 additions and 12 deletions

View File

@ -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));
}

View File

@ -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);
}

View File

@ -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);