diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index e67a493c249..5c3f8cda646 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -306,6 +306,8 @@ Other Changes * SOLR-14542: Fix or suppress warnings in solr/handler/dataimport (Erick Erickson) +* SOLR-14543: Fix or suppress warnings in apache/solr/search (Erick Erickson) + ================== 8.5.2 ================== Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. diff --git a/solr/core/src/java/org/apache/solr/search/AbstractReRankQuery.java b/solr/core/src/java/org/apache/solr/search/AbstractReRankQuery.java index c87565813e7..f0e67025886 100644 --- a/solr/core/src/java/org/apache/solr/search/AbstractReRankQuery.java +++ b/solr/core/src/java/org/apache/solr/search/AbstractReRankQuery.java @@ -56,7 +56,7 @@ public abstract class AbstractReRankQuery extends RankQuery { return null; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) public TopDocsCollector getTopDocsCollector(int len, QueryCommand cmd, IndexSearcher searcher) throws IOException { if(this.boostedPriority == null) { SolrRequestInfo info = SolrRequestInfo.getRequestInfo(); diff --git a/solr/core/src/java/org/apache/solr/search/CacheConfig.java b/solr/core/src/java/org/apache/solr/search/CacheConfig.java index 864054fd1c7..647091540c3 100644 --- a/solr/core/src/java/org/apache/solr/search/CacheConfig.java +++ b/solr/core/src/java/org/apache/solr/search/CacheConfig.java @@ -49,6 +49,7 @@ public class CacheConfig implements MapSerializable{ private String nodeName; + @SuppressWarnings({"rawtypes"}) private Class clazz; private Map args; private CacheRegenerator regenerator; @@ -61,6 +62,7 @@ public class CacheConfig implements MapSerializable{ public CacheConfig() {} + @SuppressWarnings({"rawtypes"}) public CacheConfig(Class clazz, Map args, CacheRegenerator regenerator) { this.clazz = clazz; this.args = args; @@ -91,6 +93,7 @@ public class CacheConfig implements MapSerializable{ } + @SuppressWarnings({"unchecked"}) public static CacheConfig getConfig(SolrConfig solrConfig, String xpath) { Node node = solrConfig.getNode(xpath, false); if(node == null || !"true".equals(DOMUtil.getAttrOrDefault(node, "enabled", "true"))) { @@ -103,9 +106,11 @@ public class CacheConfig implements MapSerializable{ } + @SuppressWarnings({"unchecked"}) public static CacheConfig getConfig(SolrConfig solrConfig, String nodeName, Map attrs, String xpath) { CacheConfig config = new CacheConfig(); config.nodeName = nodeName; + @SuppressWarnings({"rawtypes"}) Map attrsCopy = new LinkedHashMap<>(attrs.size()); for (Map.Entry e : attrs.entrySet()) { attrsCopy.put(e.getKey(), String.valueOf(e.getValue())); @@ -138,6 +143,7 @@ public class CacheConfig implements MapSerializable{ return config; } + @SuppressWarnings({"rawtypes"}) public SolrCache newInstance() { try { SolrCache cache = clazz.getConstructor().newInstance(); @@ -152,7 +158,9 @@ public class CacheConfig implements MapSerializable{ } @Override + @SuppressWarnings({"unchecked"}) public Map toMap(Map map) { + @SuppressWarnings({"rawtypes"}) Map result = Collections.unmodifiableMap(args); return result; } diff --git a/solr/core/src/java/org/apache/solr/search/CacheRegenerator.java b/solr/core/src/java/org/apache/solr/search/CacheRegenerator.java index 4daaa525909..f958bf2f491 100644 --- a/solr/core/src/java/org/apache/solr/search/CacheRegenerator.java +++ b/solr/core/src/java/org/apache/solr/search/CacheRegenerator.java @@ -38,5 +38,7 @@ public interface CacheRegenerator { * @param oldVal the old value of the cache item * @return true to continue with autowarming, false to stop */ - public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache, SolrCache oldCache, Object oldKey, Object oldVal) throws IOException; + public boolean regenerateItem(SolrIndexSearcher newSearcher, + @SuppressWarnings({"rawtypes"})SolrCache newCache, + @SuppressWarnings({"rawtypes"})SolrCache oldCache, Object oldKey, Object oldVal) throws IOException; } diff --git a/solr/core/src/java/org/apache/solr/search/CaffeineCache.java b/solr/core/src/java/org/apache/solr/search/CaffeineCache.java index 318e0e889f1..8da244b972e 100644 --- a/solr/core/src/java/org/apache/solr/search/CaffeineCache.java +++ b/solr/core/src/java/org/apache/solr/search/CaffeineCache.java @@ -136,7 +136,9 @@ public class CaffeineCache extends SolrCacheBase implements SolrCache buildCache(Cache prev) { + @SuppressWarnings({"rawtypes"}) Caffeine builder = Caffeine.newBuilder() .initialCapacity(initialSize) .executor(executor) diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java index e7125772e33..b9e8eb9b8dc 100644 --- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java @@ -366,6 +366,7 @@ public class CollapsingQParserPlugin extends QParserPlugin { } } + @SuppressWarnings({"unchecked"}) public DelegatingCollector getFilterCollector(IndexSearcher indexSearcher) { try { @@ -376,6 +377,7 @@ public class CollapsingQParserPlugin extends QParserPlugin { //because the QueryElevationComponent runs after the Queries are constructed. IntIntHashMap boostDocsMap = null; + @SuppressWarnings({"rawtypes"}) Map context = null; SolrRequestInfo info = SolrRequestInfo.getRequestInfo(); if(info != null) { @@ -1451,8 +1453,9 @@ public class CollapsingQParserPlugin extends QParserPlugin { * If it is, then "this" will be added to the readerContext * using the "CSCORE" key, and true will be returned. If not returns false. */ + @SuppressWarnings({"unchecked"}) public boolean setupIfNeeded(final GroupHeadSelector groupHeadSelector, - final Map readerContext) { + @SuppressWarnings({"rawtypes"})final Map readerContext) { // HACK, but not really any better options until/unless we can recursively // ask value sources if they depend on score if (wantsCScore(groupHeadSelector.selectorText)) { @@ -1832,6 +1835,7 @@ public class CollapsingQParserPlugin extends QParserPlugin { private ValueSource valueSource; private FunctionValues functionValues; private IntFloatDynamicMap ordVals; + @SuppressWarnings({"rawtypes"}) private Map rcontext; private final CollapseScore collapseScore = new CollapseScore(); private boolean needsScores4Collapsing; @@ -2353,6 +2357,7 @@ public class CollapsingQParserPlugin extends QParserPlugin { private ValueSource valueSource; private FunctionValues functionValues; + @SuppressWarnings({"rawtypes"}) private Map rcontext; private final CollapseScore collapseScore = new CollapseScore(); private int index=-1; @@ -2632,6 +2637,7 @@ public class CollapsingQParserPlugin extends QParserPlugin { final private int numClauses; final private SortField[] sorts; final private int[] reverseMul; + @SuppressWarnings({"rawtypes"}) final private FieldComparator[] fieldComparators; final private LeafFieldComparator[] leafFieldComparators; @@ -2642,6 +2648,7 @@ public class CollapsingQParserPlugin extends QParserPlugin { * Constructs an instance based on the the (raw, un-rewritten) SortFields to be used, * and an initial number of expected groups (will grow as needed). */ + @SuppressWarnings({"rawtypes"}) public SortFieldsCompare(SortField[] sorts, int initNumGroups) { this.sorts = sorts; numClauses = sorts.length; @@ -2757,6 +2764,7 @@ public class CollapsingQParserPlugin extends QParserPlugin { * accordance with the SortFields. * (otherwise returns false) */ + @SuppressWarnings({"unchecked", "rawtypes"}) private boolean testAndSetGroupValues(Object[] values, int contextDoc) throws IOException { Object[] stash = new Object[numClauses]; int lastCompare = 0; diff --git a/solr/core/src/java/org/apache/solr/search/ComplexPhraseQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/ComplexPhraseQParserPlugin.java index 85b40cdb7d0..6313e5bb2a2 100644 --- a/solr/core/src/java/org/apache/solr/search/ComplexPhraseQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/ComplexPhraseQParserPlugin.java @@ -39,7 +39,7 @@ public class ComplexPhraseQParserPlugin extends QParserPlugin { private boolean inOrder = true; @Override - public void init(NamedList args) { + public void init(@SuppressWarnings({"rawtypes"})NamedList args) { super.init(args); if (args != null) { Object val = args.get("inOrder"); diff --git a/solr/core/src/java/org/apache/solr/search/CursorMark.java b/solr/core/src/java/org/apache/solr/search/CursorMark.java index 2a63da53255..80484714116 100644 --- a/solr/core/src/java/org/apache/solr/search/CursorMark.java +++ b/solr/core/src/java/org/apache/solr/search/CursorMark.java @@ -172,6 +172,7 @@ public final class CursorMark { * * @see #getSerializedTotem */ + @SuppressWarnings({"unchecked"}) public void parseSerializedTotem(final String serialized) { if (CURSOR_MARK_START.equals(serialized)) { values = null; diff --git a/solr/core/src/java/org/apache/solr/search/ExportQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/ExportQParserPlugin.java index bdf943e0551..097f1fcf078 100644 --- a/solr/core/src/java/org/apache/solr/search/ExportQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/ExportQParserPlugin.java @@ -95,6 +95,7 @@ public class ExportQParserPlugin extends QParserPlugin { } } + @SuppressWarnings({"rawtypes"}) public TopDocsCollector getTopDocsCollector(int len, QueryCommand cmd, IndexSearcher searcher) throws IOException { @@ -137,10 +138,12 @@ public class ExportQParserPlugin extends QParserPlugin { } } + @SuppressWarnings({"rawtypes"}) private static class ExportCollector extends TopDocsCollector { private FixedBitSet[] sets; + @SuppressWarnings({"unchecked"}) public ExportCollector(FixedBitSet[] sets) { super(null); this.sets = sets; @@ -172,6 +175,7 @@ public class ExportQParserPlugin extends QParserPlugin { return docs; } + @SuppressWarnings({"unchecked"}) public TopDocs topDocs(int start, int howMany) { assert(sets != null); @@ -180,6 +184,7 @@ public class ExportQParserPlugin extends QParserPlugin { SolrQueryRequest req = null; if(info != null && ((req = info.getReq()) != null)) { + @SuppressWarnings({"rawtypes"}) Map context = req.getContext(); context.put("export", sets); context.put("totalHits", totalHits); diff --git a/solr/core/src/java/org/apache/solr/search/FloatPayloadValueSource.java b/solr/core/src/java/org/apache/solr/search/FloatPayloadValueSource.java index c5484185ce3..0103d3dedfb 100644 --- a/solr/core/src/java/org/apache/solr/search/FloatPayloadValueSource.java +++ b/solr/core/src/java/org/apache/solr/search/FloatPayloadValueSource.java @@ -53,7 +53,8 @@ public class FloatPayloadValueSource extends ValueSource { } @Override - public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException { + public FunctionValues getValues(@SuppressWarnings({"rawtypes"})Map context + , LeafReaderContext readerContext) throws IOException { final Terms terms = readerContext.reader().terms(indexedField); diff --git a/solr/core/src/java/org/apache/solr/search/Grouping.java b/solr/core/src/java/org/apache/solr/search/Grouping.java index c17cf587d4d..8d0038843fb 100644 --- a/solr/core/src/java/org/apache/solr/search/Grouping.java +++ b/solr/core/src/java/org/apache/solr/search/Grouping.java @@ -82,6 +82,7 @@ public class Grouping { private final SolrIndexSearcher searcher; private final QueryResult qr; private final QueryCommand cmd; + @SuppressWarnings({"rawtypes"}) private final List commands = new ArrayList<>(); private final boolean main; private final boolean cacheSecondPassSearch; @@ -103,6 +104,7 @@ public class Grouping { private Query query; private DocSet filter; private Filter luceneFilter; + @SuppressWarnings({"rawtypes"}) private NamedList grouped = new SimpleOrderedMap(); private Set idSet = new LinkedHashSet<>(); // used for tracking unique docs when we need a doclist private int maxMatches; // max number of matches from any grouping command @@ -134,7 +136,7 @@ public class Grouping { this.main = main; } - public void add(Grouping.Command groupingCommand) { + public void add(@SuppressWarnings({"rawtypes"})Grouping.Command groupingCommand) { commands.add(groupingCommand); } @@ -180,6 +182,7 @@ public class Grouping { public void addFunctionCommand(String groupByStr, SolrQueryRequest request) throws SyntaxError { QParser parser = QParser.getParser(groupByStr, FunctionQParserPlugin.NAME, request); Query q = parser.getQuery(); + @SuppressWarnings({"rawtypes"}) final Grouping.Command gc; if (q instanceof FunctionQuery) { ValueSource valueSource = ((FunctionQuery) q).getValueSource(); @@ -288,6 +291,7 @@ public class Grouping { return this; } + @SuppressWarnings({"rawtypes"}) public List getCommands() { return commands; } @@ -317,13 +321,13 @@ public class Grouping { getDocList = (cmd.getFlags() & SolrIndexSearcher.GET_DOCLIST) != 0; query = QueryUtils.makeQueryable(cmd.getQuery()); - for (Command cmd : commands) { + for (@SuppressWarnings({"rawtypes"})Command cmd : commands) { cmd.prepare(); } AllGroupHeadsCollector allGroupHeadsCollector = null; List collectors = new ArrayList<>(commands.size()); - for (Command cmd : commands) { + for (@SuppressWarnings({"rawtypes"})Command cmd : commands) { Collector collector = cmd.createFirstPassCollector(); if (collector != null) { collectors.add(collector); @@ -370,7 +374,7 @@ public class Grouping { } collectors.clear(); - for (Command cmd : commands) { + for (@SuppressWarnings({"rawtypes"})Command cmd : commands) { Collector collector = cmd.createSecondPassCollector(); if (collector != null) collectors.add(collector); @@ -401,7 +405,7 @@ public class Grouping { } } - for (Command cmd : commands) { + for (@SuppressWarnings({"rawtypes"})Command cmd : commands) { cmd.finish(); } @@ -592,6 +596,7 @@ public class Grouping { } } + @SuppressWarnings({"unchecked", "rawtypes"}) protected NamedList commonResponse() { NamedList groupResult = new SimpleOrderedMap(); grouped.add(key, groupResult); // grouped={ key={ @@ -606,7 +611,7 @@ public class Grouping { return groupResult; } - protected DocList getDocList(GroupDocs groups) { + protected DocList getDocList(@SuppressWarnings({"rawtypes"})GroupDocs groups) { assert groups.totalHits.relation == TotalHits.Relation.EQUAL_TO; int max = Math.toIntExact(groups.totalHits.value); int off = groupOffset; @@ -640,12 +645,15 @@ public class Grouping { return docs; } - protected void addDocList(NamedList rsp, GroupDocs groups) { + @SuppressWarnings({"unchecked"}) + protected void addDocList(@SuppressWarnings({"rawtypes"})NamedList rsp + , @SuppressWarnings({"rawtypes"})GroupDocs groups) { rsp.add("doclist", getDocList(groups)); } // Flatten the groups and get up offset + rows documents protected DocList createSimpleResponse() { + @SuppressWarnings({"rawtypes"}) GroupDocs[] groups = result != null ? result.groups : new GroupDocs[0]; List ids = new ArrayList<>(); @@ -655,7 +663,7 @@ public class Grouping { float maxScore = Float.NaN; outer: - for (GroupDocs group : groups) { + for (@SuppressWarnings({"rawtypes"})GroupDocs group : groups) { maxScore = maxAvoidNaN(maxScore, group.maxScore); for (ScoreDoc scoreDoc : group.scoreDocs) { @@ -768,6 +776,7 @@ public class Grouping { } @Override + @SuppressWarnings({"unchecked"}) protected void finish() throws IOException { if (secondPass != null) { result = secondPass.getTopGroups(0); @@ -778,6 +787,7 @@ public class Grouping { return; } + @SuppressWarnings({"rawtypes"}) NamedList groupResult = commonResponse(); if (format == Format.simple) { @@ -785,6 +795,7 @@ public class Grouping { return; } + @SuppressWarnings({"rawtypes"}) List groupList = new ArrayList(); groupResult.add("groups", groupList); // grouped={ key={ groups=[ @@ -796,6 +807,7 @@ public class Grouping { if (numGroups == 0) return; for (GroupDocs group : result.groups) { + @SuppressWarnings({"rawtypes"}) NamedList nl = new SimpleOrderedMap(); groupList.add(nl); // grouped={ key={ groups=[ { @@ -844,6 +856,7 @@ public class Grouping { * A group command for grouping on a query. */ //NOTE: doesn't need to be generic. Maybe Command interface --> First / Second pass abstract impl. + @SuppressWarnings({"rawtypes"}) public class CommandQuery extends Command { public Query query; @@ -911,6 +924,7 @@ public class Grouping { public class CommandFunc extends Command { public ValueSource groupBy; + @SuppressWarnings({"rawtypes"}) Map context; private ValueSourceGroupSelector newSelector() { @@ -985,6 +999,7 @@ public class Grouping { } @Override + @SuppressWarnings({"unchecked"}) protected void finish() throws IOException { if (secondPass != null) { result = secondPass.getTopGroups(0); @@ -995,6 +1010,7 @@ public class Grouping { return; } + @SuppressWarnings({"rawtypes"}) NamedList groupResult = commonResponse(); if (format == Format.simple) { @@ -1002,6 +1018,7 @@ public class Grouping { return; } + @SuppressWarnings({"rawtypes"}) List groupList = new ArrayList(); groupResult.add("groups", groupList); // grouped={ key={ groups=[ @@ -1013,6 +1030,7 @@ public class Grouping { if (numGroups == 0) return; for (GroupDocs group : result.groups) { + @SuppressWarnings({"rawtypes"}) NamedList nl = new SimpleOrderedMap(); groupList.add(nl); // grouped={ key={ groups=[ { nl.add("groupValue", group.groupValue.toObject()); diff --git a/solr/core/src/java/org/apache/solr/search/IGainTermsQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/IGainTermsQParserPlugin.java index c9e14344632..5364b1ba22a 100644 --- a/solr/core/src/java/org/apache/solr/search/IGainTermsQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/IGainTermsQParserPlugin.java @@ -143,8 +143,10 @@ public class IGainTermsQParserPlugin extends QParserPlugin { @Override public void finish() throws IOException { NamedList analytics = new NamedList(); + @SuppressWarnings({"unchecked", "rawtypes"}) NamedList topFreq = new NamedList(); + @SuppressWarnings({"unchecked", "rawtypes"}) NamedList allFreq = new NamedList(); rb.rsp.add("featuredTerms", analytics); diff --git a/solr/core/src/java/org/apache/solr/search/QParserPlugin.java b/solr/core/src/java/org/apache/solr/search/QParserPlugin.java index 1fab7e66d6d..43076822dc3 100644 --- a/solr/core/src/java/org/apache/solr/search/QParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/QParserPlugin.java @@ -97,7 +97,7 @@ public abstract class QParserPlugin implements NamedListInitializedPlugin, SolrI public abstract QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req); @Override - public void init( NamedList args ) { + public void init( @SuppressWarnings({"rawtypes"})NamedList args ) { } @Override diff --git a/solr/core/src/java/org/apache/solr/search/QueryContext.java b/solr/core/src/java/org/apache/solr/search/QueryContext.java index ebffc328bf6..48c7ace0e0a 100644 --- a/solr/core/src/java/org/apache/solr/search/QueryContext.java +++ b/solr/core/src/java/org/apache/solr/search/QueryContext.java @@ -48,6 +48,7 @@ public class QueryContext extends IdentityHashMap implements Closeable { return context; } + @SuppressWarnings({"unchecked"}) public QueryContext(IndexSearcher searcher) { this.searcher = searcher instanceof SolrIndexSearcher ? (SolrIndexSearcher)searcher : null; indexSearcher = searcher; diff --git a/solr/core/src/java/org/apache/solr/search/QueryParsing.java b/solr/core/src/java/org/apache/solr/search/QueryParsing.java index cc35c7811a0..22ad4213f0b 100644 --- a/solr/core/src/java/org/apache/solr/search/QueryParsing.java +++ b/solr/core/src/java/org/apache/solr/search/QueryParsing.java @@ -251,6 +251,7 @@ public class QueryParsing { out.append(q.includesUpper() ? ']' : '}'); } else if (query instanceof LegacyNumericRangeQuery) { + @SuppressWarnings({"rawtypes"}) LegacyNumericRangeQuery q = (LegacyNumericRangeQuery) query; String fname = q.getField(); FieldType ft = writeFieldName(fname, schema, out, flags); diff --git a/solr/core/src/java/org/apache/solr/search/RankQuery.java b/solr/core/src/java/org/apache/solr/search/RankQuery.java index 4812e4117a9..2aa991af802 100644 --- a/solr/core/src/java/org/apache/solr/search/RankQuery.java +++ b/solr/core/src/java/org/apache/solr/search/RankQuery.java @@ -29,6 +29,7 @@ import java.io.IOException; public abstract class RankQuery extends ExtendedQueryBase { + @SuppressWarnings({"rawtypes"}) public abstract TopDocsCollector getTopDocsCollector(int len, QueryCommand cmd, IndexSearcher searcher) throws IOException; public abstract MergeStrategy getMergeStrategy(); public abstract RankQuery wrap(Query mainQuery); diff --git a/solr/core/src/java/org/apache/solr/search/ReRankCollector.java b/solr/core/src/java/org/apache/solr/search/ReRankCollector.java index ed917c3f86f..27b07ba7b46 100644 --- a/solr/core/src/java/org/apache/solr/search/ReRankCollector.java +++ b/solr/core/src/java/org/apache/solr/search/ReRankCollector.java @@ -42,8 +42,10 @@ import org.apache.solr.handler.component.QueryElevationComponent; import org.apache.solr.request.SolrRequestInfo; /* A TopDocsCollector used by reranking queries. */ +@SuppressWarnings({"rawtypes"}) public class ReRankCollector extends TopDocsCollector { + @SuppressWarnings({"rawtypes"}) final private TopDocsCollector mainCollector; final private IndexSearcher searcher; final private int reRankDocs; @@ -54,6 +56,7 @@ public class ReRankCollector extends TopDocsCollector { final private Query query; + @SuppressWarnings({"unchecked"}) public ReRankCollector(int reRankDocs, int length, Rescorer reRankQueryRescorer, @@ -92,6 +95,7 @@ public class ReRankCollector extends TopDocsCollector { return sort == null || sort.needsScores() ? ScoreMode.COMPLETE : ScoreMode.COMPLETE_NO_SCORES; } + @SuppressWarnings({"unchecked"}) public TopDocs topDocs(int start, int howMany) { try { @@ -152,6 +156,7 @@ public class ReRankCollector extends TopDocsCollector { } } + @SuppressWarnings({"rawtypes"}) public static class BoostedComp implements Comparator { IntFloatHashMap boostedMap; diff --git a/solr/core/src/java/org/apache/solr/search/SignificantTermsQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/SignificantTermsQParserPlugin.java index d5776a849cf..130490fe9b8 100644 --- a/solr/core/src/java/org/apache/solr/search/SignificantTermsQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/SignificantTermsQParserPlugin.java @@ -134,12 +134,18 @@ public class SignificantTermsQParserPlugin extends QParserPlugin { @Override public void finish() throws IOException { + @SuppressWarnings({"unchecked", "rawtypes"}) List outTerms = new ArrayList(); + @SuppressWarnings({"unchecked", "rawtypes"}) List outFreq = new ArrayList(); + @SuppressWarnings({"unchecked", "rawtypes"}) List outQueryFreq = new ArrayList(); + @SuppressWarnings({"unchecked", "rawtypes"}) List scores = new ArrayList(); + @SuppressWarnings({"unchecked", "rawtypes"}) NamedList allFreq = new NamedList(); + @SuppressWarnings({"unchecked", "rawtypes"}) NamedList allQueryFreq = new NamedList(); LinkedHashMap response = new LinkedHashMap<>(); diff --git a/solr/core/src/java/org/apache/solr/search/SolrCache.java b/solr/core/src/java/org/apache/solr/search/SolrCache.java index 4c770b5ed0e..47a45e389df 100644 --- a/solr/core/src/java/org/apache/solr/search/SolrCache.java +++ b/solr/core/src/java/org/apache/solr/search/SolrCache.java @@ -64,7 +64,7 @@ public interface SolrCache extends SolrInfoBean { * regenerate an item in the new cache from an entry in the old cache. * */ - public Object init(Map args, Object persistence, CacheRegenerator regenerator); + public Object init(@SuppressWarnings({"rawtypes"})Map args, Object persistence, CacheRegenerator regenerator); // I don't think we need a factory for faster creation given that these // will be associated with slow-to-create SolrIndexSearchers. // change to NamedList when other plugins do? diff --git a/solr/core/src/java/org/apache/solr/search/SolrConstantScoreQuery.java b/solr/core/src/java/org/apache/solr/search/SolrConstantScoreQuery.java index 0d37abb95b2..82beecbad4e 100644 --- a/solr/core/src/java/org/apache/solr/search/SolrConstantScoreQuery.java +++ b/solr/core/src/java/org/apache/solr/search/SolrConstantScoreQuery.java @@ -84,6 +84,7 @@ public class SolrConstantScoreQuery extends Query implements ExtendedQuery { } protected class ConstantWeight extends ConstantScoreWeight { + @SuppressWarnings({"rawtypes"}) private Map context; private ScoreMode scoreMode; diff --git a/solr/core/src/java/org/apache/solr/search/SolrCoreParser.java b/solr/core/src/java/org/apache/solr/search/SolrCoreParser.java index def2919c04c..23d3a9345cc 100755 --- a/solr/core/src/java/org/apache/solr/search/SolrCoreParser.java +++ b/solr/core/src/java/org/apache/solr/search/SolrCoreParser.java @@ -52,6 +52,7 @@ public class SolrCoreParser extends CoreParser implements NamedListInitializedPl } @Override + @SuppressWarnings({"unchecked", "rawtypes"}) public void init(NamedList initArgs) { if (initArgs == null || initArgs.size() == 0) { return; diff --git a/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java b/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java index c2a80c68be7..443e1438e89 100644 --- a/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java +++ b/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java @@ -108,6 +108,7 @@ public class SolrDocumentFetcher { private Collection storedHighlightFieldNames; // lazy populated; use getter + @SuppressWarnings({"unchecked"}) SolrDocumentFetcher(SolrIndexSearcher searcher, SolrConfig solrConfig, boolean cachingEnabled) { this.searcher = searcher; this.enableLazyFieldLoading = solrConfig.enableLazyFieldLoading; diff --git a/solr/core/src/java/org/apache/solr/search/SolrFilter.java b/solr/core/src/java/org/apache/solr/search/SolrFilter.java index f1bf5054c19..0dc255a6043 100644 --- a/solr/core/src/java/org/apache/solr/search/SolrFilter.java +++ b/solr/core/src/java/org/apache/solr/search/SolrFilter.java @@ -34,9 +34,11 @@ public abstract class SolrFilter extends Filter { /** Implementations should propagate createWeight to sub-ValueSources which can store weight info in the context. * The context object will be passed to getDocIdSet() where this info can be retrieved. */ - public abstract void createWeight(Map context, IndexSearcher searcher) throws IOException; + public abstract void createWeight(@SuppressWarnings({"rawtypes"})Map context + , IndexSearcher searcher) throws IOException; - public abstract DocIdSet getDocIdSet(Map context, LeafReaderContext readerContext, Bits acceptDocs) throws IOException; + public abstract DocIdSet getDocIdSet(@SuppressWarnings({"rawtypes"})Map context + , LeafReaderContext readerContext, Bits acceptDocs) throws IOException; @Override public DocIdSet getDocIdSet(LeafReaderContext context, Bits acceptDocs) throws IOException { diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java index a779bd89b33..6ffe8d24cc3 100644 --- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java +++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java @@ -97,7 +97,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI // These should *only* be used for debugging or monitoring purposes public static final AtomicLong numOpens = new AtomicLong(); public static final AtomicLong numCloses = new AtomicLong(); + @SuppressWarnings({"rawtypes"}) private static final Map NO_GENERIC_CACHES = Collections.emptyMap(); + @SuppressWarnings({"rawtypes"}) private static final SolrCache[] NO_CACHES = new SolrCache[0]; private final SolrCore core; @@ -122,9 +124,11 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI private final SolrCache fieldValueCache; // map of generic caches - not synchronized since it's read-only after the constructor. + @SuppressWarnings({"rawtypes"}) private final Map cacheMap; // list of all caches associated with this searcher. + @SuppressWarnings({"rawtypes"}) private final SolrCache[] cacheList; private DirectoryFactory directoryFactory; @@ -229,6 +233,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI this.releaseDirectory = true; } + @SuppressWarnings({"unchecked", "rawtypes"}) public SolrIndexSearcher(SolrCore core, String path, IndexSchema schema, String name, DirectoryReader r, boolean closeReader, boolean enableCache, boolean reserveDirectory, DirectoryFactory directoryFactory) throws IOException { @@ -428,12 +433,12 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI // register self infoRegistry.put(STATISTICS_KEY, this); infoRegistry.put(name, this); - for (SolrCache cache : cacheList) { + for (@SuppressWarnings({"rawtypes"})SolrCache cache : cacheList) { cache.setState(SolrCache.State.LIVE); infoRegistry.put(cache.name(), cache); } this.solrMetricsContext = core.getSolrMetricsContext().getChildContext(this); - for (SolrCache cache : cacheList) { + for (@SuppressWarnings({"rawtypes"})SolrCache cache : cacheList) { cache.initializeMetrics(solrMetricsContext, SolrMetricManager.mkName(cache.name(), STATISTICS_KEY)); } initializeMetrics(solrMetricsContext, STATISTICS_KEY); @@ -451,7 +456,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI if (cachingEnabled) { final StringBuilder sb = new StringBuilder(); sb.append("Closing ").append(name); - for (SolrCache cache : cacheList) { + for (@SuppressWarnings({"rawtypes"})SolrCache cache : cacheList) { sb.append("\n\t"); sb.append(cache); } @@ -478,7 +483,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI core.getDeletionPolicy().releaseCommitPoint(cpg); } - for (SolrCache cache : cacheList) { + for (@SuppressWarnings({"rawtypes"})SolrCache cache : cacheList) { try { cache.close(); } catch (Exception e) { @@ -524,7 +529,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI if (solrConfig.fieldValueCacheConfig != null && solrConfig.fieldValueCacheConfig.getRegenerator() == null) { solrConfig.fieldValueCacheConfig.setRegenerator(new CacheRegenerator() { @Override - public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache, SolrCache oldCache, + public boolean regenerateItem(SolrIndexSearcher newSearcher, + @SuppressWarnings({"rawtypes"})SolrCache newCache, + @SuppressWarnings({"rawtypes"})SolrCache oldCache, Object oldKey, Object oldVal) throws IOException { if (oldVal instanceof UnInvertedField) { UnInvertedField.getUnInvertedField((String) oldKey, newSearcher); @@ -537,7 +544,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI if (solrConfig.filterCacheConfig != null && solrConfig.filterCacheConfig.getRegenerator() == null) { solrConfig.filterCacheConfig.setRegenerator(new CacheRegenerator() { @Override - public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache, SolrCache oldCache, + @SuppressWarnings({"rawtypes"})public boolean regenerateItem(SolrIndexSearcher newSearcher + , @SuppressWarnings({"rawtypes"})SolrCache newCache + , @SuppressWarnings({"rawtypes"})SolrCache oldCache, Object oldKey, Object oldVal) throws IOException { newSearcher.cacheDocSet((Query) oldKey, null, false); return true; @@ -549,6 +558,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI final int queryResultWindowSize = solrConfig.queryResultWindowSize; solrConfig.queryResultCacheConfig.setRegenerator(new CacheRegenerator() { @Override + @SuppressWarnings({"rawtypes"}) public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache, SolrCache oldCache, Object oldKey, Object oldVal) throws IOException { QueryResultKey key = (QueryResultKey) oldKey; @@ -1484,6 +1494,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI * @param cmd * The Command whose properties should determine the type of TopDocsCollector to use. */ + @SuppressWarnings({"rawtypes"}) private TopDocsCollector buildTopDocsCollector(int len, QueryCommand cmd) throws IOException { int minNumFound = cmd.getMinExactCount(); Query q = cmd.getQuery(); @@ -1679,6 +1690,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI // no docs on this page, so cursor doesn't change qr.setNextCursorMark(cmd.getCursorMark()); } else { + @SuppressWarnings({"rawtypes"}) final TopDocsCollector topCollector = buildTopDocsCollector(len, cmd); DocSetCollector setCollector = new DocSetCollector(maxDoc); MaxScoreCollector maxScoreCollector = null; @@ -1999,6 +2011,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI // bit of a hack to tell if a set is sorted - do it better in the future. boolean inOrder = set instanceof BitDocSet || set instanceof SortedIntDocSet; + @SuppressWarnings({"rawtypes"}) TopDocsCollector topCollector = buildTopDocsCollector(nDocs, cmd); DocIterator iter = set.iterator(); @@ -2121,6 +2134,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI /** * Warm this searcher based on an old one (primarily for auto-cache warming). */ + @SuppressWarnings({"unchecked"}) public void warm(SolrIndexSearcher old) { // Make sure this is first! filters can help queryResults execute! long warmingStartTime = System.nanoTime(); @@ -2165,6 +2179,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI /** * return the named generic cache */ + @SuppressWarnings({"rawtypes"}) public SolrCache getCache(String cacheName) { return cacheMap.get(cacheName); } @@ -2172,7 +2187,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI /** * lookup an entry in a generic cache */ + @SuppressWarnings({"unchecked"}) public Object cacheLookup(String cacheName, Object key) { + @SuppressWarnings({"rawtypes"}) SolrCache cache = cacheMap.get(cacheName); return cache == null ? null : cache.get(key); } @@ -2180,7 +2197,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI /** * insert an entry in a generic cache */ + @SuppressWarnings({"unchecked"}) public Object cacheInsert(String cacheName, Object key, Object val) { + @SuppressWarnings({"rawtypes"}) SolrCache cache = cacheMap.get(cacheName); return cache == null ? null : cache.put(key, val); } diff --git a/solr/core/src/java/org/apache/solr/search/TextLogisticRegressionQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/TextLogisticRegressionQParserPlugin.java index 5d3bb46d4f2..0fd0f6ab044 100644 --- a/solr/core/src/java/org/apache/solr/search/TextLogisticRegressionQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/TextLogisticRegressionQParserPlugin.java @@ -53,7 +53,7 @@ public class TextLogisticRegressionQParserPlugin extends QParserPlugin { public static final String NAME = "tlogit"; @Override - public void init(NamedList args) { + public void init(@SuppressWarnings({"rawtypes"})NamedList args) { } @Override @@ -165,6 +165,7 @@ public class TextLogisticRegressionQParserPlugin extends QParserPlugin { } + @SuppressWarnings({"unchecked"}) public void finish() throws IOException { Map docVectors = new HashMap<>(); @@ -211,6 +212,7 @@ public class TextLogisticRegressionQParserPlugin extends QParserPlugin { } } + @SuppressWarnings({"rawtypes"}) NamedList analytics = new NamedList(); rbsp.rsp.add("logit", analytics); diff --git a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java index 2a4c1a2c10c..4ebe37f2230 100644 --- a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java +++ b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java @@ -98,7 +98,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin { * Initialize the plugin. */ @Override - public void init(NamedList args) {} + public void init(@SuppressWarnings({"rawtypes"})NamedList args) {} /** * Parse the user input into a ValueSource. @@ -1186,7 +1186,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin { static class DateValueSourceParser extends ValueSourceParser { @Override - public void init(NamedList args) { + public void init(@SuppressWarnings({"rawtypes"})NamedList args) { } public Date getDate(FunctionQParser fp, String arg) { @@ -1304,7 +1304,8 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin { } @Override - public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException { + public FunctionValues getValues(@SuppressWarnings({"rawtypes"})Map context + , LeafReaderContext readerContext) throws IOException { return new LongDocValues(this) { @Override public float floatVal(int doc) { @@ -1409,7 +1410,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin { } @Override - public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException { + public FunctionValues getValues(@SuppressWarnings({"rawtypes"})Map context, LeafReaderContext readerContext) throws IOException { final FunctionValues vals = source.getValues(context, readerContext); return new DoubleDocValues(this) { @Override @@ -1456,7 +1457,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin { } @Override - public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException { + public FunctionValues getValues(@SuppressWarnings({"rawtypes"})Map context, LeafReaderContext readerContext) throws IOException { final FunctionValues aVals = a.getValues(context, readerContext); final FunctionValues bVals = b.getValues(context, readerContext); return new DoubleDocValues(this) { @@ -1472,7 +1473,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin { } @Override - public void createWeight(Map context, IndexSearcher searcher) throws IOException { + public void createWeight(@SuppressWarnings({"rawtypes"})Map context, IndexSearcher searcher) throws IOException { } @Override @@ -1512,7 +1513,8 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin { } @Override - public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException { + public FunctionValues getValues(@SuppressWarnings({"rawtypes"})Map context, + LeafReaderContext readerContext) throws IOException { return new BoolDocValues(this) { @Override public boolean boolVal(int doc) { @@ -1572,7 +1574,8 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin { } @Override - public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException { + public FunctionValues getValues(@SuppressWarnings({"rawtypes"})Map context + , LeafReaderContext readerContext) throws IOException { if (context.get(this) == null) { SolrRequestInfo requestInfo = SolrRequestInfo.getRequestInfo(); throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "testfunc: unweighted value source detected. delegate="+source + " request=" + (requestInfo==null ? "null" : requestInfo.getReq())); @@ -1596,7 +1599,8 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin { } @Override - public void createWeight(Map context, IndexSearcher searcher) throws IOException { + @SuppressWarnings({"unchecked"}) + public void createWeight(@SuppressWarnings({"rawtypes"})Map context, IndexSearcher searcher) throws IOException { context.put(this, this); } diff --git a/solr/core/src/java/org/apache/solr/search/XmlQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/XmlQParserPlugin.java index 26ee523f366..a09f621ca4f 100755 --- a/solr/core/src/java/org/apache/solr/search/XmlQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/XmlQParserPlugin.java @@ -66,10 +66,11 @@ import org.apache.solr.schema.IndexSchema; public class XmlQParserPlugin extends QParserPlugin { public static final String NAME = "xmlparser"; + @SuppressWarnings({"rawtypes"}) private NamedList args; @Override - public void init( NamedList args ) { + public void init( @SuppressWarnings({"rawtypes"})NamedList args ) { super.init(args); this.args = args; } diff --git a/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java b/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java index e7fdfd3f63b..534c26e4c1d 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java @@ -59,6 +59,7 @@ public class CommandHandler { public static class Builder { private QueryCommand queryCommand; + @SuppressWarnings({"rawtypes"}) private List commands = new ArrayList<>(); private SolrIndexSearcher searcher; private boolean needDocSet = false; @@ -71,7 +72,7 @@ public class CommandHandler { return this; } - public Builder addCommandField(Command commandField) { + public Builder addCommandField(@SuppressWarnings({"rawtypes"})Command commandField) { commands.add(commandField); return this; } @@ -116,6 +117,7 @@ public class CommandHandler { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final QueryCommand queryCommand; + @SuppressWarnings({"rawtypes"}) private final List commands; private final SolrIndexSearcher searcher; private final boolean needDocset; @@ -127,7 +129,7 @@ public class CommandHandler { private DocSet docSet; private CommandHandler(QueryCommand queryCommand, - List commands, + @SuppressWarnings({"rawtypes"})List commands, SolrIndexSearcher searcher, boolean needDocset, boolean truncateGroups, @@ -144,7 +146,7 @@ public class CommandHandler { public void execute() throws IOException { final int nrOfCommands = commands.size(); List collectors = new ArrayList<>(nrOfCommands); - for (Command command : commands) { + for (@SuppressWarnings({"rawtypes"})Command command : commands) { collectors.addAll(command.create()); } @@ -162,17 +164,19 @@ public class CommandHandler { searchWithTimeLimiter(query, filter, null); } - for (Command command : commands) { + for (@SuppressWarnings({"rawtypes"})Command command : commands) { command.postCollect(searcher); } } private DocSet computeGroupedDocSet(Query query, ProcessedFilter filter, List collectors) throws IOException { + @SuppressWarnings({"rawtypes"}) Command firstCommand = commands.get(0); String field = firstCommand.getKey(); SchemaField sf = searcher.getSchema().getField(field); FieldType fieldType = sf.getType(); + @SuppressWarnings({"rawtypes"}) final AllGroupHeadsCollector allGroupHeadsCollector; if (fieldType.getNumberType() != null) { ValueSource vs = fieldType.getValueSource(sf, null); @@ -201,7 +205,7 @@ public class CommandHandler { return DocSetUtil.getDocSet( docSetCollector, searcher ); } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) public NamedList processResult(QueryResult queryResult, ShardResultTransformer transformer) throws IOException { if (docSet != null) { queryResult.setDocSet(docSet); diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/GroupConverter.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/GroupConverter.java index 3d2779841e8..f02a42dd282 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/GroupConverter.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/GroupConverter.java @@ -133,16 +133,16 @@ class GroupConverter { return result; } + @SuppressWarnings({"unchecked", "rawtypes"}) static TopGroups fromMutable(SchemaField field, TopGroups values) { if (values == null) { return null; } FieldType fieldType = field.getType(); - - @SuppressWarnings("unchecked") + GroupDocs groupDocs[] = new GroupDocs[values.groups.length]; - + for (int i = 0; i < values.groups.length; i++) { GroupDocs original = values.groups[i]; final BytesRef groupValue; diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java index 06b49f6c9fa..7c7362b69d7 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java @@ -138,6 +138,7 @@ public class QueryCommand implements Command { private final String queryString; private final Query mainQuery; + @SuppressWarnings({"rawtypes"}) private TopDocsCollector topDocsCollector; private FilterCollector filterCollector; private MaxScoreCollector maxScoreCollector; diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java index 425a9877ff4..1dad199e46c 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java @@ -83,7 +83,9 @@ public class SearchGroupsFieldCommand implements Command> topGroups; if (firstPassGroupingCollector != null) { diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java index b6182864e60..c13a3b6fa4e 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java @@ -116,6 +116,7 @@ public class TopGroupsFieldCommand implements Command> { private final int maxDocPerGroup; private final boolean needScores; private final boolean needMaxScore; + @SuppressWarnings({"rawtypes"}) private TopGroupsCollector secondPassCollector; private TopGroups topGroups; @@ -161,6 +162,7 @@ public class TopGroupsFieldCommand implements Command> { } @Override + @SuppressWarnings({"unchecked", "rawtypes"}) public void postCollect(IndexSearcher searcher) throws IOException { if (firstPhaseGroups.isEmpty()) { topGroups = new TopGroups<>(groupSort.getSort(), withinGroupSort.getSort(), 0, 0, new GroupDocs[0], Float.NaN); diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java index 016da1db233..c3ced664173 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java @@ -48,6 +48,7 @@ import org.apache.solr.search.grouping.distributed.shardresultserializer.SearchG public class SearchGroupShardResponseProcessor implements ShardResponseProcessor { @Override + @SuppressWarnings({"unchecked"}) public void process(ResponseBuilder rb, ShardRequest shardRequest) { SortSpec groupSortSpec = rb.getGroupingSpec().getGroupSortSpec(); Sort groupSort = rb.getGroupingSpec().getGroupSortSpec().getSort(); @@ -104,7 +105,7 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessor continue; // continue if there was an error and we're tolerant. } maxElapsedTime = (int) Math.max(maxElapsedTime, srsp.getSolrResponse().getElapsedTime()); - @SuppressWarnings("unchecked") + @SuppressWarnings({"rawtypes"}) NamedList firstPhaseResult = (NamedList) srsp.getSolrResponse().getResponse().get("firstPhase"); final Map result = serializer.transformToNative(firstPhaseResult, groupSort, withinGroupSort, srsp.getShard()); for (Map.Entry>>> entry : commandSearchGroups.entrySet()) { diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java index 32ea64a32f6..5e84980d60d 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java @@ -119,6 +119,7 @@ public class TopGroupsShardResponseProcessor implements ShardResponseProcessor { rb.rsp.getResponseHeader().asShallowMap().put(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY, Boolean.TRUE); continue; // continue if there was an error and we're tolerant. } + @SuppressWarnings({"rawtypes"}) NamedList secondPhaseResult = (NamedList) srsp.getSolrResponse().getResponse().get("secondPhase"); if(secondPhaseResult == null) continue; @@ -156,11 +157,12 @@ public class TopGroupsShardResponseProcessor implements ShardResponseProcessor { continue; } + @SuppressWarnings({"rawtypes"}) TopGroups[] topGroupsArr = new TopGroups[topGroups.size()]; int docsPerGroup = docsPerGroupDefault; if (docsPerGroup < 0) { docsPerGroup = 0; - for (TopGroups subTopGroups : topGroups) { + for (@SuppressWarnings({"rawtypes"})TopGroups subTopGroups : topGroups) { docsPerGroup += subTopGroups.totalGroupedHitCount; } } diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/SearchGroupsResultTransformer.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/SearchGroupsResultTransformer.java index 425ca5bdcaf..0ecc3c4df0b 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/SearchGroupsResultTransformer.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/SearchGroupsResultTransformer.java @@ -35,6 +35,7 @@ import java.util.*; /** * Implementation for transforming {@link SearchGroup} into a {@link NamedList} structure and visa versa. */ +@SuppressWarnings({"rawtypes"}) public class SearchGroupsResultTransformer implements ShardResultTransformer, Map> { private static final String TOP_GROUPS = "topGroups"; @@ -47,6 +48,7 @@ public class SearchGroupsResultTransformer implements ShardResultTransformer data) throws IOException { final NamedList result = new NamedList<>(data.size()); for (Command command : data) { @@ -71,6 +73,7 @@ public class SearchGroupsResultTransformer implements ShardResultTransformer deserializeOneSearchGroup(SchemaField groupField, String groupValue, SortField[] groupSortField, List rawSearchGroupData) { SearchGroup searchGroup = new SearchGroup<>(); @@ -93,12 +96,13 @@ public class SearchGroupsResultTransformer implements ShardResultTransformer transformToNative(NamedList shardResponse, Sort groupSort, Sort withinGroupSort, String shard) { final Map result = new HashMap<>(shardResponse.size()); for (Map.Entry command : shardResponse) { List> searchGroups = new ArrayList<>(); NamedList topGroupsAndGroupCount = command.getValue(); - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked"}) final NamedList> rawSearchGroups = (NamedList>) topGroupsAndGroupCount.get(TOP_GROUPS); if (rawSearchGroups != null) { final SchemaField groupField = searcher.getSchema().getFieldOrNull(command.getKey()); @@ -128,6 +132,7 @@ public class SearchGroupsResultTransformer implements ShardResultTransformer> data, SearchGroupsFieldCommand command) { final NamedList result = new NamedList<>(data.size()); diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/ShardResultTransformer.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/ShardResultTransformer.java index 47e20a0018c..e604b1f51ca 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/ShardResultTransformer.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/ShardResultTransformer.java @@ -37,6 +37,7 @@ public interface ShardResultTransformer { * @return {@link NamedList} structure * @throws IOException If I/O related errors occur during transforming */ + @SuppressWarnings({"rawtypes"}) NamedList transform(T data) throws IOException; /** @@ -48,6 +49,7 @@ public interface ShardResultTransformer { * @param shard The shard address where the response originated from * @return native structure of the data */ + @SuppressWarnings({"rawtypes"}) R transformToNative(NamedList shardResponse, Sort groupSort, Sort withinGroupSort, String shard); } diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java index fb5bd32ef9e..047c31ed3d7 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java @@ -54,6 +54,7 @@ import static org.apache.solr.common.params.CommonParams.ID; * Implementation for transforming {@link TopGroups} and {@link TopDocs} into a {@link NamedList} structure and * vice versa. */ +@SuppressWarnings({"rawtypes"}) public class TopGroupsResultTransformer implements ShardResultTransformer, Map> { private final ResponseBuilder rb; @@ -138,7 +139,7 @@ public class TopGroupsResultTransformer implements ShardResultTransformer(Float.NaN, maxScore, new TotalHits(totalGroupHits.longValue(), TotalHits.Relation.EQUAL_TO), scoreDocs, groupValueRef, null)); } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked"}) GroupDocs[] groupDocsArr = groupDocs.toArray(new GroupDocs[groupDocs.size()]); TopGroups topGroups = new TopGroups<>( groupSort.getSort(), withinGroupSort.getSort(), totalHitCount, totalGroupedHitCount, groupDocsArr, Float.NaN diff --git a/solr/core/src/java/org/apache/solr/search/grouping/endresulttransformer/GroupedEndResultTransformer.java b/solr/core/src/java/org/apache/solr/search/grouping/endresulttransformer/GroupedEndResultTransformer.java index 3ba3470dc5a..1b4058c478f 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/endresulttransformer/GroupedEndResultTransformer.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/endresulttransformer/GroupedEndResultTransformer.java @@ -68,6 +68,7 @@ public class GroupedEndResultTransformer implements EndResultTransformer { command.add("ngroups", totalGroupCount); } + @SuppressWarnings({"rawtypes"}) List groups = new ArrayList<>(); SchemaField groupField = searcher.getSchema().getField(entry.getKey()); FieldType groupFieldType = groupField.getType(); diff --git a/solr/core/src/java/org/apache/solr/search/join/XCJFQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/join/XCJFQParserPlugin.java index d8323915f87..a7300e6b112 100644 --- a/solr/core/src/java/org/apache/solr/search/join/XCJFQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/join/XCJFQParserPlugin.java @@ -45,11 +45,11 @@ public class XCJFQParserPlugin extends QParserPlugin { } @Override - public void init(NamedList args) { + @SuppressWarnings({"unchecked"}) + public void init(@SuppressWarnings({"rawtypes"})NamedList args) { routerField = (String) args.get("routerField"); solrUrlWhitelist = new HashSet<>(); if (args.get("solrUrl") != null) { - //noinspection unchecked for (String s : (List) args.get("solrUrl")) { if (!StringUtils.isEmpty(s)) solrUrlWhitelist.add(s); diff --git a/solr/core/src/java/org/apache/solr/search/mlt/CloudMLTQParser.java b/solr/core/src/java/org/apache/solr/search/mlt/CloudMLTQParser.java index f7a79dc82d1..70ce4e4cb8f 100644 --- a/solr/core/src/java/org/apache/solr/search/mlt/CloudMLTQParser.java +++ b/solr/core/src/java/org/apache/solr/search/mlt/CloudMLTQParser.java @@ -91,6 +91,7 @@ public class CloudMLTQParser extends QParser { String[] fieldNames; if (qf != null) { + @SuppressWarnings({"unchecked", "rawtypes"}) ArrayList fields = new ArrayList(); for (String fieldName : qf) { if (!StringUtils.isEmpty(fieldName)) { @@ -106,6 +107,7 @@ public class CloudMLTQParser extends QParser { boostFields = SolrPluginUtils.parseFieldBoosts(fields.toArray(new String[0])); fieldNames = boostFields.keySet().toArray(new String[0]); } else { + @SuppressWarnings({"unchecked", "rawtypes"}) ArrayList fields = new ArrayList(); for (String field : doc.getFieldNames()) { // Only use fields that are stored and have an explicit analyzer. @@ -128,6 +130,7 @@ public class CloudMLTQParser extends QParser { for (String field : fieldNames) { Collection fieldValues = doc.getFieldValues(field); if (fieldValues != null) { + @SuppressWarnings({"unchecked", "rawtypes"}) Collection values = new ArrayList(); for (Object val : fieldValues) { if (val instanceof IndexableField) { @@ -187,6 +190,7 @@ public class CloudMLTQParser extends QParser { }; core.getRequestHandler("/get").handleRequest(request, rsp); + @SuppressWarnings({"rawtypes"}) NamedList response = rsp.getValues(); return (SolrDocument) response.get("doc"); diff --git a/solr/core/src/java/org/apache/solr/search/mlt/SimpleMLTQParser.java b/solr/core/src/java/org/apache/solr/search/mlt/SimpleMLTQParser.java index c57fb000062..04648e0f9d0 100644 --- a/solr/core/src/java/org/apache/solr/search/mlt/SimpleMLTQParser.java +++ b/solr/core/src/java/org/apache/solr/search/mlt/SimpleMLTQParser.java @@ -99,6 +99,7 @@ public class SimpleMLTQParser extends QParser { fieldNames = boostFields.keySet().toArray(new String[0]); } else { Map fieldDefinitions = req.getSearcher().getSchema().getFields(); + @SuppressWarnings({"unchecked", "rawtypes"}) ArrayList fields = new ArrayList(); for (Map.Entry entry : fieldDefinitions.entrySet()) { if (entry.getValue().indexed() && entry.getValue().stored()) diff --git a/solr/core/src/java/org/apache/solr/search/stats/ExactStatsCache.java b/solr/core/src/java/org/apache/solr/search/stats/ExactStatsCache.java index 63690c32164..e0ffee224c2 100644 --- a/solr/core/src/java/org/apache/solr/search/stats/ExactStatsCache.java +++ b/solr/core/src/java/org/apache/solr/search/stats/ExactStatsCache.java @@ -70,7 +70,9 @@ public class ExactStatsCache extends StatsCache { @Override protected StatsSource doGet(SolrQueryRequest req) { + @SuppressWarnings({"unchecked"}) Map currentGlobalColStats = (Map) req.getContext().getOrDefault(CURRENT_GLOBAL_COL_STATS, Collections.emptyMap()); + @SuppressWarnings({"unchecked"}) Map currentGlobalTermStats = (Map) req.getContext().getOrDefault(CURRENT_GLOBAL_TERM_STATS, Collections.emptyMap()); if (log.isDebugEnabled()) { log.debug("Returning StatsSource. Collection stats={}, Term stats size= {}", currentGlobalColStats, currentGlobalTermStats.size()); @@ -127,12 +129,15 @@ public class ExactStatsCache extends StatsCache { } protected void addToPerShardColStats(SolrQueryRequest req, String shard, Map colStats) { + @SuppressWarnings({"unchecked"}) Map> perShardColStats = (Map>) req.getContext().computeIfAbsent(PER_SHARD_COL_STATS, Utils.NEW_HASHMAP_FUN); perShardColStats.put(shard, colStats); } protected void printStats(SolrQueryRequest req) { + @SuppressWarnings({"unchecked"}) Map> perShardTermStats = (Map>) req.getContext().getOrDefault(PER_SHARD_TERM_STATS, Collections.emptyMap()); + @SuppressWarnings({"unchecked"}) Map> perShardColStats = (Map>) req.getContext().getOrDefault(PER_SHARD_COL_STATS, Collections.emptyMap()); log.debug("perShardColStats={}, perShardTermStats={}", perShardColStats, perShardTermStats); } @@ -140,6 +145,7 @@ public class ExactStatsCache extends StatsCache { protected void addToPerShardTermStats(SolrQueryRequest req, String shard, String termStatsString) { Map termStats = StatsUtil.termStatsMapFromString(termStatsString); if (termStats != null) { + @SuppressWarnings({"unchecked"}) Map> perShardTermStats = (Map>) req.getContext().computeIfAbsent(PER_SHARD_TERM_STATS, Utils.NEW_HASHMAP_FUN); perShardTermStats.put(shard, termStats); } @@ -275,11 +281,13 @@ public class ExactStatsCache extends StatsCache { } protected Map getPerShardColStats(ResponseBuilder rb, String shard) { + @SuppressWarnings({"unchecked"}) Map> perShardColStats = (Map>) rb.req.getContext().getOrDefault(PER_SHARD_COL_STATS, Collections.emptyMap()); return perShardColStats.get(shard); } protected TermStats getPerShardTermStats(SolrQueryRequest req, String t, String shard) { + @SuppressWarnings({"unchecked"}) Map> perShardTermStats = (Map>) req.getContext().getOrDefault(PER_SHARD_TERM_STATS, Collections.emptyMap()); Map cache = perShardTermStats.get(shard); return (cache != null) ? cache.get(t) : null; //Term doesn't exist in shard @@ -309,11 +317,13 @@ public class ExactStatsCache extends StatsCache { protected void addToGlobalColStats(SolrQueryRequest req, Entry e) { + @SuppressWarnings({"unchecked"}) Map currentGlobalColStats = (Map) req.getContext().computeIfAbsent(CURRENT_GLOBAL_COL_STATS, Utils.NEW_HASHMAP_FUN); currentGlobalColStats.put(e.getKey(), e.getValue()); } protected void addToGlobalTermStats(SolrQueryRequest req, Entry e) { + @SuppressWarnings({"unchecked"}) Map currentGlobalTermStats = (Map) req.getContext().computeIfAbsent(CURRENT_GLOBAL_TERM_STATS, Utils.NEW_HASHMAP_FUN); currentGlobalTermStats.put(e.getKey(), e.getValue()); } diff --git a/solr/core/src/java/org/apache/solr/search/stats/LRUStatsCache.java b/solr/core/src/java/org/apache/solr/search/stats/LRUStatsCache.java index 0760fa7584a..7e94f565126 100644 --- a/solr/core/src/java/org/apache/solr/search/stats/LRUStatsCache.java +++ b/solr/core/src/java/org/apache/solr/search/stats/LRUStatsCache.java @@ -185,7 +185,9 @@ public class LRUStatsCache extends ExactStatsCache { protected void addToPerShardTermStats(SolrQueryRequest req, String shard, String termStatsString) { Map termStats = StatsUtil.termStatsMapFromString(termStatsString); if (termStats != null) { + @SuppressWarnings({"unchecked"}) SolrCache cache = perShardTermStats.computeIfAbsent(shard, s -> { + @SuppressWarnings({"rawtypes"}) CaffeineCache c = new CaffeineCache<>(); Map map = new HashMap<>(lruCacheInitArgs); map.put(CommonParams.NAME, s);