mirror of https://github.com/apache/lucene.git
SOLR-2288: Small tweaks to eliminate compiler warnings
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1056558 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a83e98970b
commit
3ba7eafdef
|
@ -686,6 +686,10 @@ Other Changes
|
|||
* SOLR-2289: Tweak spatial coords for example docs so they are a bit
|
||||
more spread out (Erick Erickson via hossman)
|
||||
|
||||
* SOLR-2288: Small tweaks to eliminate compiler warnings. primarily
|
||||
using Generics where applicable in method/object declatations, and
|
||||
adding @SuppressWarnings("unchecked") when appropriate (hossman)
|
||||
|
||||
Build
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -102,9 +102,9 @@ public class JavaBinCodec {
|
|||
}
|
||||
|
||||
|
||||
public SimpleOrderedMap readOrderedMap(FastInputStream dis) throws IOException {
|
||||
public SimpleOrderedMap<Object> readOrderedMap(FastInputStream dis) throws IOException {
|
||||
int sz = readSize(dis);
|
||||
SimpleOrderedMap nl = new SimpleOrderedMap();
|
||||
SimpleOrderedMap<Object> nl = new SimpleOrderedMap<Object>();
|
||||
for (int i = 0; i < sz; i++) {
|
||||
String name = (String) readVal(dis);
|
||||
Object val = readVal(dis);
|
||||
|
@ -113,9 +113,9 @@ public class JavaBinCodec {
|
|||
return nl;
|
||||
}
|
||||
|
||||
public NamedList readNamedList(FastInputStream dis) throws IOException {
|
||||
public NamedList<Object> readNamedList(FastInputStream dis) throws IOException {
|
||||
int sz = readSize(dis);
|
||||
NamedList nl = new NamedList();
|
||||
NamedList<Object> nl = new NamedList<Object>();
|
||||
for (int i = 0; i < sz; i++) {
|
||||
String name = (String) readVal(dis);
|
||||
Object val = readVal(dis);
|
||||
|
@ -124,7 +124,7 @@ public class JavaBinCodec {
|
|||
return nl;
|
||||
}
|
||||
|
||||
public void writeNamedList(NamedList nl) throws IOException {
|
||||
public void writeNamedList(NamedList<?> nl) throws IOException {
|
||||
writeTag(nl instanceof SimpleOrderedMap ? ORDERED_MAP : NAMED_LST, nl.size());
|
||||
for (int i = 0; i < nl.size(); i++) {
|
||||
String name = nl.getName(i);
|
||||
|
@ -218,7 +218,7 @@ public class JavaBinCodec {
|
|||
public boolean writeKnownType(Object val) throws IOException {
|
||||
if (writePrimitive(val)) return true;
|
||||
if (val instanceof NamedList) {
|
||||
writeNamedList((NamedList) val);
|
||||
writeNamedList((NamedList<?>) val);
|
||||
return true;
|
||||
}
|
||||
if (val instanceof SolrDocumentList) { // SolrDocumentList is a List, so must come before List check
|
||||
|
@ -336,7 +336,8 @@ public class JavaBinCodec {
|
|||
solrDocs.setStart((Long) list.get(1));
|
||||
solrDocs.setMaxScore((Float) list.get(2));
|
||||
|
||||
List l = (List) readVal(dis);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SolrDocument> l = (List<SolrDocument>) readVal(dis);
|
||||
solrDocs.addAll(l);
|
||||
return solrDocs;
|
||||
}
|
||||
|
@ -344,7 +345,7 @@ public class JavaBinCodec {
|
|||
public void writeSolrDocumentList(SolrDocumentList docs)
|
||||
throws IOException {
|
||||
writeTag(SOLRDOCLST);
|
||||
List l = new ArrayList(3);
|
||||
List<Number> l = new ArrayList<Number>(3);
|
||||
l.add(docs.getNumFound());
|
||||
l.add(docs.getStart());
|
||||
l.add(docs.getMaxScore());
|
||||
|
@ -352,10 +353,10 @@ public class JavaBinCodec {
|
|||
writeArray(docs);
|
||||
}
|
||||
|
||||
public Map readMap(FastInputStream dis)
|
||||
public Map<Object,Object> readMap(FastInputStream dis)
|
||||
throws IOException {
|
||||
int sz = readVInt(dis);
|
||||
Map m = new LinkedHashMap();
|
||||
Map<Object,Object> m = new LinkedHashMap<Object,Object>();
|
||||
for (int i = 0; i < sz; i++) {
|
||||
Object key = readVal(dis);
|
||||
Object val = readVal(dis);
|
||||
|
@ -373,8 +374,8 @@ public class JavaBinCodec {
|
|||
writeVal(END_OBJ);
|
||||
}
|
||||
|
||||
public List readIterator(FastInputStream fis) throws IOException {
|
||||
ArrayList l = new ArrayList();
|
||||
public List<Object> readIterator(FastInputStream fis) throws IOException {
|
||||
ArrayList<Object> l = new ArrayList<Object>();
|
||||
while (true) {
|
||||
Object o = readVal(fis);
|
||||
if (o == END_OBJ) break;
|
||||
|
@ -406,9 +407,9 @@ public class JavaBinCodec {
|
|||
}
|
||||
}
|
||||
|
||||
public List readArray(FastInputStream dis) throws IOException {
|
||||
public List<Object> readArray(FastInputStream dis) throws IOException {
|
||||
int sz = readSize(dis);
|
||||
ArrayList l = new ArrayList(sz);
|
||||
ArrayList<Object> l = new ArrayList<Object>(sz);
|
||||
for (int i = 0; i < sz; i++) {
|
||||
l.add(readVal(dis));
|
||||
}
|
||||
|
@ -603,10 +604,9 @@ public class JavaBinCodec {
|
|||
}
|
||||
|
||||
|
||||
public void writeMap(Map val)
|
||||
throws IOException {
|
||||
public void writeMap(Map<?,?> val) throws IOException {
|
||||
writeTag(MAP, val.size());
|
||||
for (Map.Entry entry : (Set<Map.Entry>) val.entrySet()) {
|
||||
for (Map.Entry<?,?> entry : val.entrySet()) {
|
||||
Object key = entry.getKey();
|
||||
if (key instanceof String) {
|
||||
writeExternString((String) key);
|
||||
|
|
|
@ -50,11 +50,11 @@ import java.io.Serializable;
|
|||
* @version $Id$
|
||||
*/
|
||||
public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry<String,T>> {
|
||||
protected final List nvPairs;
|
||||
protected final List<Object> nvPairs;
|
||||
|
||||
/** Creates an empty instance */
|
||||
public NamedList() {
|
||||
nvPairs = new ArrayList();
|
||||
nvPairs = new ArrayList<Object>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry
|
|||
* @deprecated Use {@link #NamedList(java.util.Map.Entry[])} for the NamedList instantiation
|
||||
*/
|
||||
@Deprecated
|
||||
public NamedList(List nameValuePairs) {
|
||||
public NamedList(List<Object> nameValuePairs) {
|
||||
nvPairs=nameValuePairs;
|
||||
}
|
||||
|
||||
|
@ -104,8 +104,8 @@ public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry
|
|||
* @see https://issues.apache.org/jira/browse/SOLR-912
|
||||
*/
|
||||
@Deprecated
|
||||
private List nameValueMapToList(Map.Entry<String, ? extends T>[] nameValuePairs) {
|
||||
List result = new ArrayList();
|
||||
private List<Object> nameValueMapToList(Map.Entry<String, ? extends T>[] nameValuePairs) {
|
||||
List<Object> result = new ArrayList<Object>();
|
||||
for (Map.Entry<String, ?> ent : nameValuePairs) {
|
||||
result.add(ent.getKey());
|
||||
result.add(ent.getValue());
|
||||
|
@ -158,6 +158,7 @@ public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry
|
|||
*/
|
||||
public T setVal(int idx, T val) {
|
||||
int index = (idx<<1)+1;
|
||||
@SuppressWarnings("unchecked")
|
||||
T old = (T)nvPairs.get( index );
|
||||
nvPairs.set(index, val);
|
||||
return old;
|
||||
|
@ -170,7 +171,9 @@ public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry
|
|||
public T remove(int idx) {
|
||||
int index = (idx<<1);
|
||||
nvPairs.remove(index);
|
||||
return (T)nvPairs.remove(index); // same index, as things shifted in previous remove
|
||||
@SuppressWarnings("unchecked")
|
||||
T result = (T)nvPairs.remove(index); // same index, as things shifted in previous remove
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -315,7 +318,7 @@ public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry
|
|||
* Makes a <i>shallow copy</i> of the named list.
|
||||
*/
|
||||
public NamedList<T> clone() {
|
||||
ArrayList newList = new ArrayList(nvPairs.size());
|
||||
ArrayList<Object> newList = new ArrayList<Object>(nvPairs.size());
|
||||
newList.addAll(nvPairs);
|
||||
return new NamedList<T>(newList);
|
||||
}
|
||||
|
@ -330,7 +333,7 @@ public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry
|
|||
*/
|
||||
public Iterator<Map.Entry<String,T>> iterator() {
|
||||
|
||||
final NamedList list = this;
|
||||
final NamedList<T> list = this;
|
||||
|
||||
Iterator<Map.Entry<String,T>> iter = new Iterator<Map.Entry<String,T>>() {
|
||||
|
||||
|
@ -349,7 +352,7 @@ public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getValue() {
|
||||
return (T)list.getVal( index );
|
||||
return list.getVal( index );
|
||||
}
|
||||
|
||||
public String toString()
|
||||
|
@ -358,7 +361,7 @@ public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry
|
|||
}
|
||||
|
||||
public T setValue(T value) {
|
||||
return (T) list.setVal(index, value);
|
||||
return list.setVal(index, value);
|
||||
}
|
||||
};
|
||||
return nv;
|
||||
|
|
|
@ -1286,7 +1286,7 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
rsp.add("responseHeader", responseHeader);
|
||||
|
||||
// toLog is a local ref to the same NamedList used by the request
|
||||
NamedList toLog = rsp.getToLog();
|
||||
NamedList<Object> toLog = rsp.getToLog();
|
||||
// for back compat, we set these now just in case other code
|
||||
// are expecting them during handleRequest
|
||||
toLog.add("webapp", req.getContext().get("webapp"));
|
||||
|
@ -1312,7 +1312,7 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
|
||||
public static void setResponseHeaderValues(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp) {
|
||||
// TODO should check that responseHeader has not been replaced by handler
|
||||
NamedList responseHeader = rsp.getResponseHeader();
|
||||
NamedList<Object> responseHeader = rsp.getResponseHeader();
|
||||
final int qtime=(int)(rsp.getEndTime() - req.getStartTime());
|
||||
int status = 0;
|
||||
Exception exception = rsp.getException();
|
||||
|
@ -1586,7 +1586,7 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
}
|
||||
|
||||
public NamedList getStatistics() {
|
||||
NamedList lst = new SimpleOrderedMap();
|
||||
NamedList<Object> lst = new SimpleOrderedMap<Object>();
|
||||
lst.add("coreName", name==null ? "(null)" : name);
|
||||
lst.add("startTime", new Date(startTime));
|
||||
lst.add("refCount", getOpenCount());
|
||||
|
|
|
@ -168,8 +168,8 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo
|
|||
return null; // this can be overridden, but not required
|
||||
}
|
||||
|
||||
public NamedList getStatistics() {
|
||||
NamedList lst = new SimpleOrderedMap();
|
||||
public NamedList<Object> getStatistics() {
|
||||
NamedList<Object> lst = new SimpleOrderedMap<Object>();
|
||||
lst.add("handlerStart",handlerStart);
|
||||
lst.add("requests", numRequests);
|
||||
lst.add("errors", numErrors);
|
||||
|
|
|
@ -35,17 +35,17 @@ public class SolrInfoMBeanHandler extends RequestHandlerBase {
|
|||
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
|
||||
SolrCore core = req.getCore();
|
||||
|
||||
NamedList cats = new NamedList();
|
||||
NamedList<NamedList<NamedList<Object>>> cats = new NamedList<NamedList<NamedList<Object>>>();
|
||||
rsp.add("solr-mbeans", cats);
|
||||
|
||||
String[] requestedCats = req.getParams().getParams("cat");
|
||||
if (null == requestedCats || 0 == requestedCats.length) {
|
||||
for (SolrInfoMBean.Category cat : SolrInfoMBean.Category.values()) {
|
||||
cats.add(cat.name(), new SimpleOrderedMap());
|
||||
cats.add(cat.name(), new SimpleOrderedMap<NamedList<Object>>());
|
||||
}
|
||||
} else {
|
||||
for (String catName : requestedCats) {
|
||||
cats.add(catName,new SimpleOrderedMap());
|
||||
cats.add(catName,new SimpleOrderedMap<NamedList<Object>>());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,10 +58,10 @@ public class SolrInfoMBeanHandler extends RequestHandlerBase {
|
|||
|
||||
if ( ! ( requestedKeys.isEmpty() || requestedKeys.contains(key) ) ) continue;
|
||||
|
||||
NamedList catInfo = (NamedList) cats.get(m.getCategory().name());
|
||||
NamedList<NamedList<Object>> catInfo = cats.get(m.getCategory().name());
|
||||
if ( null == catInfo ) continue;
|
||||
|
||||
NamedList mBeanInfo = new SimpleOrderedMap();
|
||||
NamedList<Object> mBeanInfo = new SimpleOrderedMap<Object>();
|
||||
mBeanInfo.add("class", m.getName());
|
||||
mBeanInfo.add("version", m.getVersion());
|
||||
mBeanInfo.add("description", m.getDescription());
|
||||
|
|
|
@ -115,7 +115,7 @@ public class DebugComponent extends SearchComponent
|
|||
@Override
|
||||
public void finishStage(ResponseBuilder rb) {
|
||||
if (rb.isDebug() && rb.stage == ResponseBuilder.STAGE_GET_FIELDS) {
|
||||
NamedList info = null;
|
||||
NamedList<Object> info = null;
|
||||
NamedList explain = new SimpleOrderedMap();
|
||||
|
||||
Map.Entry<String, Object>[] arr = new NamedList.NamedListEntry[rb.resultIds.size()];
|
||||
|
@ -140,11 +140,11 @@ public class DebugComponent extends SearchComponent
|
|||
}
|
||||
|
||||
if (rb.isDebugResults()) {
|
||||
explain = SolrPluginUtils.removeNulls(new SimpleOrderedMap(arr));
|
||||
explain = SolrPluginUtils.removeNulls(new SimpleOrderedMap<Object>(arr));
|
||||
}
|
||||
|
||||
if (info == null) {
|
||||
info = new SimpleOrderedMap();
|
||||
info = new SimpleOrderedMap<Object>();
|
||||
}
|
||||
if (rb.isDebugResults()) {
|
||||
int idx = info.indexOf("explain",0);
|
||||
|
@ -196,9 +196,11 @@ public class DebugComponent extends SearchComponent
|
|||
|
||||
|
||||
if (source instanceof NamedList && dest instanceof NamedList) {
|
||||
NamedList tmp = new NamedList();
|
||||
NamedList sl = (NamedList)source;
|
||||
NamedList dl = (NamedList)dest;
|
||||
NamedList<Object> tmp = new NamedList<Object>();
|
||||
@SuppressWarnings("unchecked")
|
||||
NamedList<Object> sl = (NamedList<Object>)source;
|
||||
@SuppressWarnings("unchecked")
|
||||
NamedList<Object> dl = (NamedList<Object>)dest;
|
||||
for (int i=0; i<sl.size(); i++) {
|
||||
String skey = sl.getName(i);
|
||||
if (exclude != null && exclude.contains(skey)) continue;
|
||||
|
@ -228,7 +230,7 @@ public class DebugComponent extends SearchComponent
|
|||
}
|
||||
|
||||
// merge unlike elements in a list
|
||||
List t = new ArrayList();
|
||||
List<Object> t = new ArrayList<Object>();
|
||||
t.add(dest);
|
||||
t.add(source);
|
||||
return t;
|
||||
|
|
|
@ -78,7 +78,7 @@ public class FacetComponent extends SearchComponent
|
|||
params,
|
||||
rb );
|
||||
|
||||
NamedList counts = f.getFacetCounts();
|
||||
NamedList<Object> counts = f.getFacetCounts();
|
||||
String[] pivots = params.getParams( FacetParams.FACET_PIVOT );
|
||||
if( pivots != null && pivots.length > 0 ) {
|
||||
NamedList v = pivotHelper.process(rb, params, pivots);
|
||||
|
@ -264,7 +264,9 @@ public class FacetComponent extends SearchComponent
|
|||
int shardNum = rb.getShardNum(srsp.getShard());
|
||||
NamedList facet_counts = (NamedList)srsp.getSolrResponse().getResponse().get("facet_counts");
|
||||
|
||||
fi.addExceptions((List)facet_counts.get("exception"));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> excepts = (List<String>)facet_counts.get("exception");
|
||||
fi.addExceptions(excepts);
|
||||
|
||||
// handle facet queries
|
||||
NamedList facet_queries = (NamedList)facet_counts.get("facet_queries");
|
||||
|
@ -298,7 +300,10 @@ public class FacetComponent extends SearchComponent
|
|||
if (dff.limit <= 0) continue; // no need to check these facets for refinement
|
||||
if (dff.minCount <= 1 && dff.sort.equals(FacetParams.FACET_SORT_INDEX)) continue;
|
||||
|
||||
dff._toRefine = new List[rb.shards.length];
|
||||
@SuppressWarnings("unchecked") // generic array's are anoying
|
||||
List<String>[] tmp = (List<String>[]) new List[rb.shards.length];
|
||||
dff._toRefine = tmp;
|
||||
|
||||
ShardFacetCount[] counts = dff.getCountSorted();
|
||||
int ntop = Math.min(counts.length, dff.offset + dff.limit);
|
||||
long smallestCount = counts.length == 0 ? 0 : counts[ntop-1].count;
|
||||
|
@ -353,8 +358,10 @@ public class FacetComponent extends SearchComponent
|
|||
// int shardNum = rb.getShardNum(srsp.shard);
|
||||
NamedList facet_counts = (NamedList)srsp.getSolrResponse().getResponse().get("facet_counts");
|
||||
NamedList facet_fields = (NamedList)facet_counts.get("facet_fields");
|
||||
|
||||
fi.addExceptions((List)facet_counts.get("exception"));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> excepts = (List<String>)facet_counts.get("exception");
|
||||
fi.addExceptions(excepts);
|
||||
|
||||
if (facet_fields == null) continue; // this can happen when there's an exception
|
||||
|
||||
|
@ -384,23 +391,23 @@ public class FacetComponent extends SearchComponent
|
|||
|
||||
FacetInfo fi = rb._facetInfo;
|
||||
|
||||
NamedList facet_counts = new SimpleOrderedMap();
|
||||
NamedList<Object> facet_counts = new SimpleOrderedMap<Object>();
|
||||
|
||||
if (fi.exceptionList != null) {
|
||||
facet_counts.add("exception",fi.exceptionList);
|
||||
}
|
||||
|
||||
NamedList facet_queries = new SimpleOrderedMap();
|
||||
NamedList<Number> facet_queries = new SimpleOrderedMap<Number>();
|
||||
facet_counts.add("facet_queries",facet_queries);
|
||||
for (QueryFacet qf : fi.queryFacets.values()) {
|
||||
facet_queries.add(qf.getKey(), num(qf.count));
|
||||
}
|
||||
|
||||
NamedList facet_fields = new SimpleOrderedMap();
|
||||
NamedList<Object> facet_fields = new SimpleOrderedMap<Object>();
|
||||
facet_counts.add("facet_fields", facet_fields);
|
||||
|
||||
for (DistribFieldFacet dff : fi.facets.values()) {
|
||||
NamedList fieldCounts = new NamedList(); // order is more important for facets
|
||||
NamedList<Object> fieldCounts = new NamedList<Object>(); // order is more important for facets
|
||||
facet_fields.add(dff.getKey(), fieldCounts);
|
||||
|
||||
ShardFacetCount[] counts;
|
||||
|
@ -486,7 +493,7 @@ public class FacetComponent extends SearchComponent
|
|||
public static class FacetInfo {
|
||||
public LinkedHashMap<String,QueryFacet> queryFacets;
|
||||
public LinkedHashMap<String,DistribFieldFacet> facets;
|
||||
public List exceptionList;
|
||||
public List<String> exceptionList;
|
||||
|
||||
void parse(SolrParams params, ResponseBuilder rb) {
|
||||
queryFacets = new LinkedHashMap<String,QueryFacet>();
|
||||
|
@ -510,9 +517,9 @@ public class FacetComponent extends SearchComponent
|
|||
}
|
||||
}
|
||||
|
||||
public void addExceptions(List exceptions) {
|
||||
public void addExceptions(List<String> exceptions) {
|
||||
if (exceptions == null) return;
|
||||
if (exceptionList == null) exceptionList = new ArrayList();
|
||||
if (exceptionList == null) exceptionList = new ArrayList<String>();
|
||||
exceptionList.addAll(exceptions);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class TermsComponent extends SearchComponent {
|
|||
|
||||
String[] fields = params.getParams(TermsParams.TERMS_FIELD);
|
||||
|
||||
NamedList termsResult = new SimpleOrderedMap();
|
||||
NamedList<Object> termsResult = new SimpleOrderedMap<Object>();
|
||||
rb.rsp.add("terms", termsResult);
|
||||
|
||||
if (fields == null || fields.length==0) return;
|
||||
|
@ -107,7 +107,7 @@ public class TermsComponent extends SearchComponent {
|
|||
Fields lfields = MultiFields.getFields(sr);
|
||||
|
||||
for (String field : fields) {
|
||||
NamedList fieldTerms = new NamedList();
|
||||
NamedList<Integer> fieldTerms = new NamedList<Integer>();
|
||||
termsResult.add(field, fieldTerms);
|
||||
|
||||
Terms terms = lfields == null ? null : lfields.terms(field);
|
||||
|
@ -273,7 +273,9 @@ public class TermsComponent extends SearchComponent {
|
|||
TermsHelper th = rb._termsHelper;
|
||||
if (th != null) {
|
||||
for (ShardResponse srsp : sreq.responses) {
|
||||
th.parse((NamedList) srsp.getSolrResponse().getResponse().get("terms"));
|
||||
@SuppressWarnings("unchecked")
|
||||
NamedList<Object> terms = (NamedList<Object>) srsp.getSolrResponse().getResponse().get("terms");
|
||||
th.parse(terms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -331,7 +333,7 @@ public class TermsComponent extends SearchComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public void parse(NamedList terms) {
|
||||
public void parse(NamedList<Object> terms) {
|
||||
// exit if there is no terms
|
||||
if (terms == null) {
|
||||
return;
|
||||
|
@ -364,7 +366,7 @@ public class TermsComponent extends SearchComponent {
|
|||
}
|
||||
|
||||
public NamedList buildResponse() {
|
||||
NamedList response = new SimpleOrderedMap();
|
||||
NamedList<Object> response = new SimpleOrderedMap<Object>();
|
||||
|
||||
// determine if we are going index or count sort
|
||||
boolean sort = !TermsParams.TERMS_SORT_INDEX.equals(params.get(
|
||||
|
@ -393,7 +395,7 @@ public class TermsComponent extends SearchComponent {
|
|||
|
||||
// loop though each field we want terms from
|
||||
for (String key : fieldmap.keySet()) {
|
||||
NamedList fieldterms = new SimpleOrderedMap();
|
||||
NamedList<Number> fieldterms = new SimpleOrderedMap<Number>();
|
||||
TermsResponse.Term[] data = null;
|
||||
if (sort) {
|
||||
data = getCountSorted(fieldmap.get(key));
|
||||
|
|
|
@ -63,7 +63,7 @@ class PerSegmentSingleValuedFaceting {
|
|||
}
|
||||
|
||||
|
||||
NamedList getFacetCounts(Executor executor) throws IOException {
|
||||
NamedList<Integer> getFacetCounts(Executor executor) throws IOException {
|
||||
|
||||
CompletionService<SegFacet> completionService = new ExecutorCompletionService<SegFacet>(executor);
|
||||
|
||||
|
@ -189,7 +189,7 @@ class PerSegmentSingleValuedFaceting {
|
|||
if (stop) break;
|
||||
}
|
||||
|
||||
NamedList res = collector.getFacetCounts();
|
||||
NamedList<Integer> res = collector.getFacetCounts();
|
||||
|
||||
// convert labels to readable form
|
||||
FieldType ft = searcher.getSchema().getFieldType(fieldName);
|
||||
|
@ -321,7 +321,7 @@ class PerSegmentSingleValuedFaceting {
|
|||
abstract class FacetCollector {
|
||||
/*** return true to stop collection */
|
||||
public abstract boolean collect(BytesRef term, int count);
|
||||
public abstract NamedList getFacetCounts();
|
||||
public abstract NamedList<Integer> getFacetCounts();
|
||||
}
|
||||
|
||||
|
||||
|
@ -355,8 +355,8 @@ class CountSortedFacetCollector extends FacetCollector {
|
|||
}
|
||||
|
||||
@Override
|
||||
public NamedList getFacetCounts() {
|
||||
NamedList res = new NamedList();
|
||||
public NamedList<Integer> getFacetCounts() {
|
||||
NamedList<Integer> res = new NamedList<Integer>();
|
||||
int off=offset;
|
||||
int lim=limit>=0 ? limit : Integer.MAX_VALUE;
|
||||
// now select the right page from the results
|
||||
|
@ -374,7 +374,7 @@ class IndexSortedFacetCollector extends FacetCollector {
|
|||
int offset;
|
||||
int limit;
|
||||
final int mincount;
|
||||
final NamedList res = new NamedList();
|
||||
final NamedList<Integer> res = new NamedList<Integer>();
|
||||
|
||||
|
||||
public IndexSortedFacetCollector(int offset, int limit, int mincount) {
|
||||
|
@ -403,7 +403,7 @@ class IndexSortedFacetCollector extends FacetCollector {
|
|||
}
|
||||
|
||||
@Override
|
||||
public NamedList getFacetCounts() {
|
||||
public NamedList<Integer> getFacetCounts() {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class SimpleFacets {
|
|||
protected SolrQueryRequest req;
|
||||
protected ResponseBuilder rb;
|
||||
|
||||
protected SimpleOrderedMap facetResponse;
|
||||
protected SimpleOrderedMap<Object> facetResponse;
|
||||
|
||||
// per-facet values
|
||||
SolrParams localParams; // localParams on this particular facet command
|
||||
|
@ -175,13 +175,13 @@ public class SimpleFacets {
|
|||
* @see FacetParams#FACET
|
||||
* @return a NamedList of Facet Count info or null
|
||||
*/
|
||||
public NamedList getFacetCounts() {
|
||||
public NamedList<Object> getFacetCounts() {
|
||||
|
||||
// if someone called this method, benefit of the doubt: assume true
|
||||
if (!params.getBool(FacetParams.FACET,true))
|
||||
return null;
|
||||
|
||||
facetResponse = new SimpleOrderedMap();
|
||||
facetResponse = new SimpleOrderedMap<Object>();
|
||||
try {
|
||||
facetResponse.add("facet_queries", getFacetQueryCounts());
|
||||
facetResponse.add("facet_fields", getFacetFieldCounts());
|
||||
|
@ -196,9 +196,11 @@ public class SimpleFacets {
|
|||
}
|
||||
|
||||
public void addException(String msg, Exception e) {
|
||||
List exceptions = (List)facetResponse.get("exception");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> exceptions = (List<String>)facetResponse.get("exception");
|
||||
|
||||
if (exceptions == null) {
|
||||
exceptions = new ArrayList();
|
||||
exceptions = new ArrayList<String>();
|
||||
facetResponse.add("exception", exceptions);
|
||||
}
|
||||
|
||||
|
@ -212,9 +214,9 @@ public class SimpleFacets {
|
|||
*
|
||||
* @see FacetParams#FACET_QUERY
|
||||
*/
|
||||
public NamedList getFacetQueryCounts() throws IOException,ParseException {
|
||||
public NamedList<Integer> getFacetQueryCounts() throws IOException,ParseException {
|
||||
|
||||
NamedList res = new SimpleOrderedMap();
|
||||
NamedList<Integer> res = new SimpleOrderedMap<Integer>();
|
||||
|
||||
/* Ignore CommonParams.DF - could have init param facet.query assuming
|
||||
* the schema default with query param DF intented to only affect Q.
|
||||
|
@ -246,10 +248,10 @@ public class SimpleFacets {
|
|||
}
|
||||
|
||||
|
||||
public NamedList getTermCounts(String field) throws IOException {
|
||||
public NamedList<Integer> getTermCounts(String field) throws IOException {
|
||||
int offset = params.getFieldInt(field, FacetParams.FACET_OFFSET, 0);
|
||||
int limit = params.getFieldInt(field, FacetParams.FACET_LIMIT, 100);
|
||||
if (limit == 0) return new NamedList();
|
||||
if (limit == 0) return new NamedList<Integer>();
|
||||
Integer mincount = params.getFieldInt(field, FacetParams.FACET_MINCOUNT);
|
||||
if (mincount==null) {
|
||||
Boolean zeros = params.getFieldBool(field, FacetParams.FACET_ZEROS);
|
||||
|
@ -263,7 +265,7 @@ public class SimpleFacets {
|
|||
String prefix = params.getFieldParam(field,FacetParams.FACET_PREFIX);
|
||||
|
||||
|
||||
NamedList counts;
|
||||
NamedList<Integer> counts;
|
||||
SchemaField sf = searcher.getSchema().getField(field);
|
||||
FieldType ft = sf.getType();
|
||||
|
||||
|
@ -335,10 +337,10 @@ public class SimpleFacets {
|
|||
* @see #getFieldMissingCount
|
||||
* @see #getFacetTermEnumCounts
|
||||
*/
|
||||
public NamedList getFacetFieldCounts()
|
||||
public NamedList<Object> getFacetFieldCounts()
|
||||
throws IOException, ParseException {
|
||||
|
||||
NamedList res = new SimpleOrderedMap();
|
||||
NamedList<Object> res = new SimpleOrderedMap<Object>();
|
||||
String[] facetFs = params.getParams(FacetParams.FACET_FIELD);
|
||||
if (null != facetFs) {
|
||||
for (String f : facetFs) {
|
||||
|
@ -361,10 +363,10 @@ public class SimpleFacets {
|
|||
}
|
||||
|
||||
|
||||
private NamedList getListedTermCounts(String field, String termList) throws IOException {
|
||||
private NamedList<Integer> getListedTermCounts(String field, String termList) throws IOException {
|
||||
FieldType ft = searcher.getSchema().getFieldType(field);
|
||||
List<String> terms = StrUtils.splitSmart(termList, ",", true);
|
||||
NamedList res = new NamedList();
|
||||
NamedList<Integer> res = new NamedList<Integer>();
|
||||
Term t = new Term(field);
|
||||
for (String term : terms) {
|
||||
String internal = ft.toInternal(term);
|
||||
|
@ -394,7 +396,7 @@ public class SimpleFacets {
|
|||
* Use the Lucene FieldCache to get counts for each unique field value in <code>docs</code>.
|
||||
* The field must have at most one indexed token per document.
|
||||
*/
|
||||
public static NamedList getFieldCacheCounts(SolrIndexSearcher searcher, DocSet docs, String fieldName, int offset, int limit, int mincount, boolean missing, String sort, String prefix) throws IOException {
|
||||
public static NamedList<Integer> getFieldCacheCounts(SolrIndexSearcher searcher, DocSet docs, String fieldName, int offset, int limit, int mincount, boolean missing, String sort, String prefix) throws IOException {
|
||||
// TODO: If the number of terms is high compared to docs.size(), and zeros==false,
|
||||
// we should use an alternate strategy to avoid
|
||||
// 1) creating another huge int[] for the counts
|
||||
|
@ -409,7 +411,7 @@ public class SimpleFacets {
|
|||
// trying to pass all the various params around.
|
||||
|
||||
FieldType ft = searcher.getSchema().getFieldType(fieldName);
|
||||
NamedList res = new NamedList();
|
||||
NamedList<Integer> res = new NamedList<Integer>();
|
||||
|
||||
FieldCache.DocTermsIndex si = FieldCache.DEFAULT.getTermsIndex(searcher.getReader(), fieldName);
|
||||
|
||||
|
@ -589,7 +591,7 @@ public class SimpleFacets {
|
|||
* @see FacetParams#FACET_ZEROS
|
||||
* @see FacetParams#FACET_MISSING
|
||||
*/
|
||||
public NamedList getFacetTermEnumCounts(SolrIndexSearcher searcher, DocSet docs, String field, int offset, int limit, int mincount, boolean missing, String sort, String prefix)
|
||||
public NamedList<Integer> getFacetTermEnumCounts(SolrIndexSearcher searcher, DocSet docs, String field, int offset, int limit, int mincount, boolean missing, String sort, String prefix)
|
||||
throws IOException {
|
||||
|
||||
/* :TODO: potential optimization...
|
||||
|
@ -615,7 +617,7 @@ public class SimpleFacets {
|
|||
boolean sortByCount = sort.equals("count") || sort.equals("true");
|
||||
final int maxsize = limit>=0 ? offset+limit : Integer.MAX_VALUE-1;
|
||||
final BoundedTreeSet<CountPair<BytesRef,Integer>> queue = sortByCount ? new BoundedTreeSet<CountPair<BytesRef,Integer>>(maxsize) : null;
|
||||
final NamedList res = new NamedList();
|
||||
final NamedList<Integer> res = new NamedList<Integer>();
|
||||
|
||||
int min=mincount-1; // the smallest value in the top 'N' values
|
||||
int off=offset;
|
||||
|
@ -776,10 +778,10 @@ public class SimpleFacets {
|
|||
* @see FacetParams#FACET_DATE
|
||||
*/
|
||||
|
||||
public NamedList getFacetDateCounts()
|
||||
public NamedList<Object> getFacetDateCounts()
|
||||
throws IOException, ParseException {
|
||||
|
||||
final NamedList resOuter = new SimpleOrderedMap();
|
||||
final NamedList<Object> resOuter = new SimpleOrderedMap<Object>();
|
||||
final String[] fields = params.getParams(FacetParams.FACET_DATE);
|
||||
|
||||
if (null == fields || 0 == fields.length) return resOuter;
|
||||
|
@ -797,7 +799,7 @@ public class SimpleFacets {
|
|||
return resOuter;
|
||||
}
|
||||
|
||||
public void getFacetDateCounts(String dateFacet, NamedList resOuter)
|
||||
public void getFacetDateCounts(String dateFacet, NamedList<Object> resOuter)
|
||||
throws IOException, ParseException {
|
||||
|
||||
final IndexSchema schema = searcher.getSchema();
|
||||
|
@ -806,7 +808,7 @@ public class SimpleFacets {
|
|||
String f = facetValue;
|
||||
|
||||
|
||||
final NamedList resInner = new SimpleOrderedMap();
|
||||
final NamedList<Object> resInner = new SimpleOrderedMap<Object>();
|
||||
resOuter.add(key, resInner);
|
||||
final SchemaField sf = schema.getField(f);
|
||||
if (! (sf.getType() instanceof DateField)) {
|
||||
|
@ -948,8 +950,8 @@ public class SimpleFacets {
|
|||
* @see FacetParams#FACET_RANGE
|
||||
*/
|
||||
|
||||
public NamedList getFacetRangeCounts() {
|
||||
final NamedList resOuter = new SimpleOrderedMap();
|
||||
public NamedList<Object> getFacetRangeCounts() {
|
||||
final NamedList<Object> resOuter = new SimpleOrderedMap<Object>();
|
||||
final String[] fields = params.getParams(FacetParams.FACET_RANGE);
|
||||
|
||||
if (null == fields || 0 == fields.length) return resOuter;
|
||||
|
@ -967,7 +969,7 @@ public class SimpleFacets {
|
|||
return resOuter;
|
||||
}
|
||||
|
||||
void getFacetRangeCounts(String facetRange, NamedList resOuter)
|
||||
void getFacetRangeCounts(String facetRange, NamedList<Object> resOuter)
|
||||
throws IOException, ParseException {
|
||||
|
||||
final IndexSchema schema = searcher.getSchema();
|
||||
|
@ -978,7 +980,7 @@ public class SimpleFacets {
|
|||
final SchemaField sf = schema.getField(f);
|
||||
final FieldType ft = sf.getType();
|
||||
|
||||
RangeEndpointCalculator calc = null;
|
||||
RangeEndpointCalculator<?> calc = null;
|
||||
|
||||
if (ft instanceof TrieField) {
|
||||
final TrieField trie = (TrieField)ft;
|
||||
|
@ -1025,8 +1027,8 @@ public class SimpleFacets {
|
|||
final RangeEndpointCalculator<T> calc) throws IOException {
|
||||
|
||||
final String f = sf.getName();
|
||||
final NamedList res = new SimpleOrderedMap();
|
||||
final NamedList counts = new SimpleOrderedMap();
|
||||
final NamedList<Object> res = new SimpleOrderedMap<Object>();
|
||||
final NamedList<Integer> counts = new SimpleOrderedMap<Integer>();
|
||||
res.add("counts", counts);
|
||||
|
||||
final T start = calc.getValue(required.getFieldParam(f,FacetParams.FACET_RANGE_START));
|
||||
|
@ -1176,8 +1178,9 @@ public class SimpleFacets {
|
|||
return key.hashCode() ^ val.hashCode();
|
||||
}
|
||||
public boolean equals(Object o) {
|
||||
return (o instanceof CountPair)
|
||||
&& (0 == this.compareTo((CountPair<K,V>) o));
|
||||
if (! (o instanceof CountPair)) return false;
|
||||
CountPair<?,?> that = (CountPair<?,?>) o;
|
||||
return (this.key.equals(that.key) && this.val.equals(that.val));
|
||||
}
|
||||
public int compareTo(CountPair<K,V> o) {
|
||||
int vc = o.val.compareTo(val);
|
||||
|
|
|
@ -457,12 +457,12 @@ public class UnInvertedField {
|
|||
|
||||
|
||||
|
||||
public NamedList getCounts(SolrIndexSearcher searcher, DocSet baseDocs, int offset, int limit, Integer mincount, boolean missing, String sort, String prefix) throws IOException {
|
||||
public NamedList<Integer> getCounts(SolrIndexSearcher searcher, DocSet baseDocs, int offset, int limit, Integer mincount, boolean missing, String sort, String prefix) throws IOException {
|
||||
use.incrementAndGet();
|
||||
|
||||
FieldType ft = searcher.getSchema().getFieldType(field);
|
||||
|
||||
NamedList res = new NamedList(); // order is important
|
||||
NamedList<Integer> res = new NamedList<Integer>(); // order is important
|
||||
|
||||
DocSet docs = baseDocs;
|
||||
int baseSize = docs.size();
|
||||
|
|
|
@ -66,12 +66,12 @@ public class SolrQueryResponse {
|
|||
* @see #setAllValues
|
||||
* @see <a href="#returnable_data">Note on Returnable Data</a>
|
||||
*/
|
||||
protected NamedList values = new SimpleOrderedMap();
|
||||
protected NamedList<Object> values = new SimpleOrderedMap<Object>();
|
||||
|
||||
/**
|
||||
* Container for storing information that should be logged by Solr before returning.
|
||||
*/
|
||||
protected NamedList toLog = new SimpleOrderedMap();
|
||||
protected NamedList<Object> toLog = new SimpleOrderedMap<Object>();
|
||||
|
||||
protected Set<String> defaultReturnFields;
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class SolrQueryResponse {
|
|||
* Sets data to be returned in this response
|
||||
* @see <a href="#returnable_data">Note on Returnable Data</a>
|
||||
*/
|
||||
public void setAllValues(NamedList nameValuePairs) {
|
||||
public void setAllValues(NamedList<Object> nameValuePairs) {
|
||||
values=nameValuePairs;
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,8 @@ public class SolrQueryResponse {
|
|||
}
|
||||
|
||||
/** Repsonse header to be logged */
|
||||
public NamedList getResponseHeader() {
|
||||
public NamedList<Object> getResponseHeader() {
|
||||
@SuppressWarnings("unchecked")
|
||||
SimpleOrderedMap<Object> header = (SimpleOrderedMap<Object>) values.get("responseHeader");
|
||||
return header;
|
||||
}
|
||||
|
@ -207,7 +208,7 @@ public class SolrQueryResponse {
|
|||
*
|
||||
* @return things to log
|
||||
*/
|
||||
public NamedList getToLog() {
|
||||
public NamedList<Object> getToLog() {
|
||||
return toLog;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,10 +63,11 @@ public abstract class QParser {
|
|||
if (localParams != null) {
|
||||
String tagStr = localParams.get(CommonParams.TAG);
|
||||
if (tagStr != null) {
|
||||
Map context = req.getContext();
|
||||
Map<String,Collection<Object>> tagMap = (Map<String, Collection<Object>>)req.getContext().get("tags");
|
||||
Map<Object,Object> context = req.getContext();
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<Object,Collection<Object>> tagMap = (Map<Object, Collection<Object>>)req.getContext().get("tags");
|
||||
if (tagMap == null) {
|
||||
tagMap = new HashMap<String,Collection<Object>>();
|
||||
tagMap = new HashMap<Object,Collection<Object>>();
|
||||
context.put("tags", tagMap);
|
||||
}
|
||||
if (tagStr.indexOf(',') >= 0) {
|
||||
|
@ -85,10 +86,10 @@ public abstract class QParser {
|
|||
}
|
||||
|
||||
|
||||
private static void addTag(Map tagMap, Object key, Object val) {
|
||||
Collection lst = (Collection)tagMap.get(key);
|
||||
private static void addTag(Map<Object,Collection<Object>> tagMap, Object key, Object val) {
|
||||
Collection<Object> lst = tagMap.get(key);
|
||||
if (lst == null) {
|
||||
lst = new ArrayList(2);
|
||||
lst = new ArrayList<Object>(2);
|
||||
tagMap.put(key, lst);
|
||||
}
|
||||
lst.add(val);
|
||||
|
|
|
@ -1767,8 +1767,8 @@ public class SolrIndexSearcher extends IndexSearcher implements SolrInfoMBean {
|
|||
return null;
|
||||
}
|
||||
|
||||
public NamedList getStatistics() {
|
||||
NamedList lst = new SimpleOrderedMap();
|
||||
public NamedList<Object> getStatistics() {
|
||||
NamedList<Object> lst = new SimpleOrderedMap<Object>();
|
||||
lst.add("searcherName", name);
|
||||
lst.add("caching", cachingEnabled);
|
||||
lst.add("numDocs", reader.numDocs());
|
||||
|
|
Loading…
Reference in New Issue