cpoerschke commented on a change in pull request #169: URL: https://github.com/apache/solr/pull/169#discussion_r652050590
########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ListCacheEvaluator.java ########## @@ -41,35 +39,21 @@ public ListCacheEvaluator(StreamExpression expression, StreamFactory factory) th } @Override - @SuppressWarnings({"unchecked"}) public Object doWork(Object... values) throws IOException { - @SuppressWarnings({"rawtypes"}) - ConcurrentMap objectCache = this.streamContext.getObjectCache(); - @SuppressWarnings({"rawtypes"}) - List list = new ArrayList(); + Map<String, Object> objectCache = this.streamContext.getObjectCache(); Review comment: ```suggestion ConcurrentMap<String, Object> objectCache = this.streamContext.getObjectCache(); ``` This would help with code reading clarity I think. ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ListCacheEvaluator.java ########## @@ -41,35 +39,21 @@ public ListCacheEvaluator(StreamExpression expression, StreamFactory factory) th } @Override - @SuppressWarnings({"unchecked"}) public Object doWork(Object... values) throws IOException { - @SuppressWarnings({"rawtypes"}) - ConcurrentMap objectCache = this.streamContext.getObjectCache(); - @SuppressWarnings({"rawtypes"}) - List list = new ArrayList(); + Map<String, Object> objectCache = this.streamContext.getObjectCache(); + List<String> list = new ArrayList<>(); if(values.length == 0) { - @SuppressWarnings({"rawtypes"}) - ConcurrentHashMap m = (ConcurrentHashMap)objectCache; - @SuppressWarnings({"rawtypes"}) - Enumeration en = m.keys(); - while(en.hasMoreElements()) { - list.add(en.nextElement()); - } + list.addAll(objectCache.keySet()); return list; } else if(values.length == 1) { String space = (String)values[0]; space = space.replace("\"", ""); - @SuppressWarnings({"rawtypes"}) - ConcurrentMap spaceCache = (ConcurrentMap)objectCache.get(space); + Map<?,?> spaceCache = (Map<?,?>)objectCache.get(space); if(spaceCache != null) { - @SuppressWarnings({"rawtypes"}) - ConcurrentHashMap spaceMap = (ConcurrentHashMap)objectCache.get(space); - @SuppressWarnings({"rawtypes"}) - Enumeration en = spaceMap.keys(); - while(en.hasMoreElements()) { - list.add(en.nextElement()); - } + @SuppressWarnings("unchecked") + Map<String,?> spaceMap = (Map<String,?>)objectCache.get(space); Review comment: It's not what the existing code does but would ```suggestion Map<String,?> spaceMap = (Map<String,?>)spaceCache; ``` be equivalent (and clearer) here? And how do we know the map key is a string (though it seems likely given the `Map<Object, Object> Tuple.fields` type)? ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/PutCacheEvaluator.java ########## @@ -37,18 +37,18 @@ public PutCacheEvaluator(StreamExpression expression, StreamFactory factory) thr } @Override - @SuppressWarnings({"unchecked", "rawtypes"}) public Object doWork(Object... values) throws IOException { - ConcurrentMap objectCache = this.streamContext.getObjectCache(); + ConcurrentMap<String, Object> objectCache = this.streamContext.getObjectCache(); if(values.length == 3) { String space = (String)values[0]; String key = (String)values[1]; space = space.replace("\"", ""); key = key.replace("\"", ""); Object value = values[2]; - ConcurrentMap spaceCache = (ConcurrentMap)objectCache.get(space); + @SuppressWarnings("unchecked") + ConcurrentMap<String, Object> spaceCache = (ConcurrentMap<String,Object>)objectCache.get(space); Review comment: Same question as above w.r.t. `ConcurrentMap<String, Object>` vs. `ConcurrentMap<Object, Object>` type. ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ListCacheEvaluator.java ########## @@ -41,35 +39,21 @@ public ListCacheEvaluator(StreamExpression expression, StreamFactory factory) th } @Override - @SuppressWarnings({"unchecked"}) public Object doWork(Object... values) throws IOException { - @SuppressWarnings({"rawtypes"}) - ConcurrentMap objectCache = this.streamContext.getObjectCache(); - @SuppressWarnings({"rawtypes"}) - List list = new ArrayList(); + Map<String, Object> objectCache = this.streamContext.getObjectCache(); + List<String> list = new ArrayList<>(); if(values.length == 0) { - @SuppressWarnings({"rawtypes"}) - ConcurrentHashMap m = (ConcurrentHashMap)objectCache; - @SuppressWarnings({"rawtypes"}) - Enumeration en = m.keys(); - while(en.hasMoreElements()) { - list.add(en.nextElement()); - } + list.addAll(objectCache.keySet()); return list; } else if(values.length == 1) { String space = (String)values[0]; space = space.replace("\"", ""); - @SuppressWarnings({"rawtypes"}) - ConcurrentMap spaceCache = (ConcurrentMap)objectCache.get(space); + Map<?,?> spaceCache = (Map<?,?>)objectCache.get(space); if(spaceCache != null) { - @SuppressWarnings({"rawtypes"}) - ConcurrentHashMap spaceMap = (ConcurrentHashMap)objectCache.get(space); - @SuppressWarnings({"rawtypes"}) - Enumeration en = spaceMap.keys(); - while(en.hasMoreElements()) { - list.add(en.nextElement()); - } Review comment: I'm curious why the hasMoreElements/nextElement approach was used before and if the addAll/keySet approach is equivalent given the concurrent-ness of the map. Though from a quick look the javadocs don't suggest a difference between the two. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org