LUCENE-6740: Reduce warnings emitted by javac #7

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1696098 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2015-08-15 21:05:57 +00:00
parent 94b12beb4a
commit 0a54365ffa
10 changed files with 31 additions and 29 deletions

View File

@ -292,7 +292,7 @@ public class PatternParser extends DefaultHandler {
* java.lang.String, java.lang.String)
*/
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
public void endElement(String uri, String local, String raw) {
if (token.length() > 0) {
@ -329,7 +329,7 @@ public class PatternParser extends DefaultHandler {
/**
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void characters(char ch[], int start, int length) {
StringBuilder chars = new StringBuilder(length);

View File

@ -40,10 +40,8 @@ import java.lang.reflect.Method;
* refactored StringBuffers to StringBuilder
* uses char[] as buffer instead of StringBuffer/StringBuilder
* eq_s,eq_s_b,insert,replace_s take CharSequence like eq_v and eq_v_b
* reflection calls (Lovins, etc) use EMPTY_ARGS/EMPTY_PARAMS
*/
public class Among {
private static final Class<?>[] EMPTY_PARAMS = new Class[0];
public Among(String s, int substring_i, int result,
String methodname, SnowballProgram methodobject) {
@ -56,8 +54,7 @@ public class Among {
this.method = null;
} else {
try {
this.method = methodobject.getClass().
getDeclaredMethod(methodname, EMPTY_PARAMS);
this.method = methodobject.getClass().getDeclaredMethod(methodname);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}

View File

@ -44,10 +44,8 @@ import org.apache.lucene.util.RamUsageEstimator;
* refactored StringBuffers to StringBuilder
* uses char[] as buffer instead of StringBuffer/StringBuilder
* eq_s,eq_s_b,insert,replace_s take CharSequence like eq_v and eq_v_b
* reflection calls (Lovins, etc) use EMPTY_ARGS/EMPTY_PARAMS
*/
public abstract class SnowballProgram {
private static final Object[] EMPTY_ARGS = new Object[0];
protected SnowballProgram()
{
@ -314,7 +312,7 @@ public abstract class SnowballProgram {
if (w.method == null) return w.result;
boolean res;
try {
Object resobj = w.method.invoke(w.methodobject, EMPTY_ARGS);
Object resobj = w.method.invoke(w.methodobject);
res = resobj.toString().equals("true");
} catch (InvocationTargetException e) {
res = false;
@ -382,7 +380,7 @@ public abstract class SnowballProgram {
boolean res;
try {
Object resobj = w.method.invoke(w.methodobject, EMPTY_ARGS);
Object resobj = w.method.invoke(w.methodobject);
res = resobj.toString().equals("true");
} catch (InvocationTargetException e) {
res = false;

View File

@ -61,6 +61,7 @@ abstract public class AbstractFirstPassGroupingCollector<GROUP_VALUE_TYPE> exten
* @param topNGroups How many top groups to keep.
* @throws IOException If I/O related errors occur
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public AbstractFirstPassGroupingCollector(Sort groupSort, int topNGroups) throws IOException {
if (topNGroups < 1) {
throw new IllegalArgumentException("topNGroups must be >= 1 (got " + topNGroups + ")");

View File

@ -18,7 +18,6 @@ package org.apache.lucene.search.grouping;
*/
import org.apache.lucene.search.FieldComparator;
import org.apache.lucene.search.LeafFieldComparator;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
@ -154,9 +153,12 @@ public class SearchGroup<GROUP_VALUE_TYPE> {
private static class GroupComparator<T> implements Comparator<MergedGroup<T>> {
@SuppressWarnings("rawtypes")
public final FieldComparator[] comparators;
public final int[] reversed;
@SuppressWarnings({"unchecked", "rawtypes"})
public GroupComparator(Sort groupSort) throws IOException {
final SortField[] sortFields = groupSort.getSort();
comparators = new FieldComparator[sortFields.length];

View File

@ -119,7 +119,7 @@ public abstract class TermAllGroupHeadsCollector<GH extends AbstractAllGroupHead
private final Sort sortWithinGroup;
private final Map<BytesRef, GroupHead> groups;
private Scorer scorer;
Scorer scorer;
GeneralAllGroupHeadsCollector(String groupField, Sort sortWithinGroup) {
super(groupField, sortWithinGroup.getSort().length);
@ -182,10 +182,13 @@ public abstract class TermAllGroupHeadsCollector<GH extends AbstractAllGroupHead
class GroupHead extends AbstractAllGroupHeadsCollector.GroupHead<BytesRef> {
@SuppressWarnings({"unchecked", "rawtypes"})
final FieldComparator[] comparators;
final LeafFieldComparator[] leafComparators;
private GroupHead(BytesRef groupValue, Sort sort, int doc) throws IOException {
@SuppressWarnings({"unchecked", "rawtypes"})
GroupHead(BytesRef groupValue, Sort sort, int doc) throws IOException {
super(groupValue, doc + readerContext.docBase);
final SortField[] sortFields = sort.getSort();
comparators = new FieldComparator[sortFields.length];
@ -221,10 +224,10 @@ public abstract class TermAllGroupHeadsCollector<GH extends AbstractAllGroupHead
private final SentinelIntSet ordSet;
private final List<GroupHead> collectedGroups;
private final SortField[] fields;
final SortField[] fields;
private SortedDocValues[] sortsIndex;
private Scorer scorer;
SortedDocValues[] sortsIndex;
Scorer scorer;
private GroupHead[] segmentGroupHeads;
OrdScoreAllGroupHeadsCollector(String groupField, Sort sortWithinGroup, int initialSize) {
@ -322,7 +325,7 @@ public abstract class TermAllGroupHeadsCollector<GH extends AbstractAllGroupHead
int[] sortOrds;
float[] scores;
private GroupHead(int doc, BytesRef groupValue) throws IOException {
GroupHead(int doc, BytesRef groupValue) throws IOException {
super(groupValue, doc + readerContext.docBase);
sortValues = new BytesRefBuilder[sortsIndex.length];
sortOrds = new int[sortsIndex.length];
@ -384,8 +387,8 @@ public abstract class TermAllGroupHeadsCollector<GH extends AbstractAllGroupHead
private final List<GroupHead> collectedGroups;
private final SortField[] fields;
private SortedDocValues[] sortsIndex;
private GroupHead[] segmentGroupHeads;
SortedDocValues[] sortsIndex;
GroupHead[] segmentGroupHeads;
OrdAllGroupHeadsCollector(String groupField, Sort sortWithinGroup, int initialSize) {
super(groupField, sortWithinGroup.getSort().length);
@ -473,7 +476,7 @@ public abstract class TermAllGroupHeadsCollector<GH extends AbstractAllGroupHead
BytesRefBuilder[] sortValues;
int[] sortOrds;
private GroupHead(int doc, BytesRef groupValue) {
GroupHead(int doc, BytesRef groupValue) {
super(groupValue, doc + readerContext.docBase);
sortValues = new BytesRefBuilder[sortsIndex.length];
sortOrds = new int[sortsIndex.length];
@ -512,12 +515,12 @@ public abstract class TermAllGroupHeadsCollector<GH extends AbstractAllGroupHead
// AbstractAllGroupHeadsCollector optimized for scores.
static class ScoreAllGroupHeadsCollector extends TermAllGroupHeadsCollector<ScoreAllGroupHeadsCollector.GroupHead> {
private final SentinelIntSet ordSet;
private final List<GroupHead> collectedGroups;
private final SortField[] fields;
final SentinelIntSet ordSet;
final List<GroupHead> collectedGroups;
final SortField[] fields;
private Scorer scorer;
private GroupHead[] segmentGroupHeads;
Scorer scorer;
GroupHead[] segmentGroupHeads;
ScoreAllGroupHeadsCollector(String groupField, Sort sortWithinGroup, int initialSize) {
super(groupField, sortWithinGroup.getSort().length);
@ -591,7 +594,7 @@ public abstract class TermAllGroupHeadsCollector<GH extends AbstractAllGroupHead
float[] scores;
private GroupHead(int doc, BytesRef groupValue) throws IOException {
GroupHead(int doc, BytesRef groupValue) throws IOException {
super(groupValue, doc + readerContext.docBase);
scores = new float[fields.length];
float score = scorer.score();

View File

@ -42,7 +42,7 @@ public class TermSecondPassGroupingCollector extends AbstractSecondPassGroupingC
private SortedDocValues index;
private final String groupField;
@SuppressWarnings({"unchecked"})
@SuppressWarnings({"unchecked", "rawtypes"})
public TermSecondPassGroupingCollector(String groupField, Collection<SearchGroup<BytesRef>> groups, Sort groupSort, Sort withinGroupSort,
int maxDocsPerGroup, boolean getScores, boolean getMaxScores, boolean fillSortFields)
throws IOException {

View File

@ -180,7 +180,7 @@ public class WeightedSpanTermExtractor {
}
}
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked","rawtypes"})
final List<SpanQuery>[] disjunctLists = new List[maxPosition + 1];
int distinctPositions = 0;

View File

@ -1221,7 +1221,7 @@ public class TestBlockJoin extends LuceneTestCase {
s.search(childJoinQuery, c);
//Get all child documents within groups
@SuppressWarnings({"unchecked"})
@SuppressWarnings({"unchecked","rawtypes"})
TopGroups<Integer>[] getTopGroupsResults = new TopGroups[2];
getTopGroupsResults[0] = c.getTopGroups(childJoinQuery, null, 0, 10, 0, true);
getTopGroupsResults[1] = c.getTopGroupsWithAllChildDocs(childJoinQuery, null, 0, 0, true);

View File

@ -68,6 +68,7 @@ public class BlockJoinComparatorSource extends FieldComparatorSource {
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public FieldComparator<Integer> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
// we keep parallel slots: the parent ids and the child ids
final int parentSlots[] = new int[numHits];