From ec78ef785275e4d46c0f133c6b55be1f974b8db2 Mon Sep 17 00:00:00 2001 From: Koen De Groote Date: Fri, 13 Sep 2019 14:42:38 +0200 Subject: [PATCH] Changing keyset() to entryset() and sometines values(). (#868) --- lucene/CHANGES.txt | 2 ++ .../analysis/ja/dict/UserDictionary.java | 6 ++-- .../lucene/search/spans/SpanWeight.java | 4 +-- .../solr/analytics/facet/PivotNode.java | 6 ++-- .../api/collections/CreateCollectionCmd.java | 5 +-- .../org/apache/solr/core/CoreDescriptor.java | 6 ++-- .../handler/admin/CollectionsHandler.java | 5 +-- .../handler/admin/ZookeeperInfoHandler.java | 8 ++--- .../solr/logging/log4j2/Log4j2Watcher.java | 4 +-- .../apache/solr/request/json/RequestUtil.java | 5 +-- .../ManagedSynonymGraphFilterFactory.java | 17 ++++----- .../org/apache/solr/schema/FieldType.java | 35 +++++++++++-------- .../org/apache/solr/search/DisMaxQParser.java | 6 ++-- .../solr/search/ExtendedDismaxQParser.java | 6 ++-- .../solr/search/facet/FacetRequest.java | 10 +++--- .../solr/search/mlt/SimpleMLTQParser.java | 8 ++--- .../processor/AtomicUpdateDocumentMerger.java | 5 +-- .../java/org/apache/solr/util/SolrCLI.java | 5 +-- .../client/solrj/io/stream/KnnStream.java | 10 +++--- .../solrj/io/stream/RandomFacadeStream.java | 4 +-- .../client/solrj/io/stream/RandomStream.java | 10 +++--- .../client/solrj/io/stream/SearchStream.java | 4 +-- 22 files changed, 92 insertions(+), 79 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 4fb5192f678..0a3c9738fe1 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -166,6 +166,8 @@ Other * LUCENE-8758: QuadPrefixTree: removed levelS and levelN fields which weren't used. (Amish Shah) +* LUCENE-8975: Code Cleanup: Use entryset for map iteration wherever possible. + ======================= Lucene 8.2.0 ======================= API Changes diff --git a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/UserDictionary.java b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/UserDictionary.java index 515c1d11663..fef24f948e1 100644 --- a/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/UserDictionary.java +++ b/lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/dict/UserDictionary.java @@ -194,11 +194,11 @@ public final class UserDictionary implements Dictionary { */ private int[][] toIndexArray(Map input) { ArrayList result = new ArrayList<>(); - for (int i : input.keySet()) { - int[] wordIdAndLength = input.get(i); + for (Map.Entry entry : input.entrySet()) { + int[] wordIdAndLength = entry.getValue(); int wordId = wordIdAndLength[0]; // convert length to index - int current = i; + int current = entry.getKey(); for (int j = 1; j < wordIdAndLength.length; j++) { // first entry is wordId offset int[] token = { wordId + j - 1, current, wordIdAndLength[j] }; result.add(token); diff --git a/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java b/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java index c33235f9e1b..c193201613f 100644 --- a/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java +++ b/lucene/core/src/java/org/apache/lucene/search/spans/SpanWeight.java @@ -102,8 +102,8 @@ public abstract class SpanWeight extends Weight { return null; TermStatistics[] termStats = new TermStatistics[termStates.size()]; int termUpTo = 0; - for (Term term : termStates.keySet()) { - TermStatistics termStatistics = searcher.termStatistics(term, termStates.get(term)); + for (Map.Entry entry : termStates.entrySet()) { + TermStatistics termStatistics = searcher.termStatistics(entry.getKey(), entry.getValue()); if (termStatistics != null) { termStats[termUpTo++] = termStatistics; } diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/facet/PivotNode.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/facet/PivotNode.java index ac3a4ba1abd..bec388bf2cc 100644 --- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/facet/PivotNode.java +++ b/solr/contrib/analytics/src/java/org/apache/solr/analytics/facet/PivotNode.java @@ -90,9 +90,9 @@ public abstract class PivotNode extends SortableFacet implements Consumer pivot) throws IOException { output.writeInt(pivot.size()); - for (String pivotValue : pivot.keySet()) { - output.writeUTF(pivotValue); - exportPivotValue(output, pivot.get(pivotValue)); + for (Map.Entry entry : pivot.entrySet()) { + output.writeUTF(entry.getKey()); + exportPivotValue(output, entry.getValue()); } } /** diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java index 708f7da13ea..a38dcbe3f44 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java @@ -160,9 +160,10 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd Map collectionParams = new HashMap<>(); Map collectionProps = message.getProperties(); - for (String propName : collectionProps.keySet()) { + for (Map.Entry entry : collectionProps.entrySet()) { + String propName = entry.getKey(); if (propName.startsWith(ZkController.COLLECTION_PARAM_PREFIX)) { - collectionParams.put(propName.substring(ZkController.COLLECTION_PARAM_PREFIX.length()), (String) collectionProps.get(propName)); + collectionParams.put(propName.substring(ZkController.COLLECTION_PARAM_PREFIX.length()), (String) entry.getValue()); } } diff --git a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java index 8b2ba5d0189..ac5923602b1 100644 --- a/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java +++ b/solr/core/src/java/org/apache/solr/core/CoreDescriptor.java @@ -203,9 +203,9 @@ public class CoreDescriptor { coreProperties.putAll(defaultProperties); coreProperties.put(CORE_NAME, name); - for (String propname : coreProps.keySet()) { - - String propvalue = coreProps.get(propname); + for (Map.Entry entry : coreProps.entrySet()) { + String propname = entry.getKey(); + String propvalue = entry.getValue(); if (isUserDefinedProperty(propname)) originalExtraProperties.put(propname, propvalue); diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java index ee3bde0cb59..445c0c55c19 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java @@ -1060,8 +1060,9 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission copy(req.getParams().required(), m, COLLECTION_PROP); addMapObject(m, RULE); addMapObject(m, SNITCH); - for (String prop : m.keySet()) { - if ("".equals(m.get(prop))) { + for (Map.Entry entry : m.entrySet()) { + String prop = entry.getKey(); + if ("".equals(entry.getValue())) { // set to an empty string is equivalent to removing the property, see SOLR-12507 m.put(prop, null); } diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperInfoHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperInfoHandler.java index 45ef0b90774..98a6e56d433 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperInfoHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/ZookeeperInfoHandler.java @@ -183,12 +183,12 @@ public final class ZookeeperInfoHandler extends RequestHandlerBase { boolean replicaInRecovery = false; Map shards = (Map) collectionState.get("shards"); - for (String shardId : shards.keySet()) { + for (Object o : shards.values()) { boolean hasActive = false; - Map shard = (Map) shards.get(shardId); + Map shard = (Map) o; Map replicas = (Map) shard.get("replicas"); - for (String replicaId : replicas.keySet()) { - Map replicaState = (Map) replicas.get(replicaId); + for (Object value : replicas.values()) { + Map replicaState = (Map) value; Replica.State coreState = Replica.State.getState((String) replicaState.get(ZkStateReader.STATE_PROP)); String nodeName = (String) replicaState.get("node_name"); diff --git a/solr/core/src/java/org/apache/solr/logging/log4j2/Log4j2Watcher.java b/solr/core/src/java/org/apache/solr/logging/log4j2/Log4j2Watcher.java index de79991f0c0..49635035425 100644 --- a/solr/core/src/java/org/apache/solr/logging/log4j2/Log4j2Watcher.java +++ b/solr/core/src/java/org/apache/solr/logging/log4j2/Log4j2Watcher.java @@ -280,8 +280,8 @@ public class Log4j2Watcher extends LogWatcher { Map contextMap = event.getContextMap(); if (contextMap != null) { - for (String key : contextMap.keySet()) - doc.setField(key, contextMap.get(key)); + for (Map.Entry entry : contextMap.entrySet()) + doc.setField(entry.getKey(), entry.getValue()); } if (!doc.containsKey("core")) diff --git a/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java b/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java index 6e7e02a69ed..6370bef7dc4 100644 --- a/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java +++ b/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java @@ -179,13 +179,14 @@ public class RequestUtil { } mergeJSON(json, JSON, jsonS, new ObjectUtil.ConflictHandler()); } - for (String key : newMap.keySet()) { + for (Map.Entry entry : newMap.entrySet()) { + String key = entry.getKey(); // json.nl, json.wrf are existing query parameters if (key.startsWith("json.") && !("json.nl".equals(key) || "json.wrf".equals(key))) { if (json == null) { json = new LinkedHashMap<>(); } - mergeJSON(json, key, newMap.get(key), new ObjectUtil.ConflictHandler()); + mergeJSON(json, key, entry.getValue(), new ObjectUtil.ConflictHandler()); } } diff --git a/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymGraphFilterFactory.java b/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymGraphFilterFactory.java index 80d6a7076a1..6d7c1f57085 100644 --- a/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymGraphFilterFactory.java +++ b/solr/core/src/java/org/apache/solr/rest/schema/analysis/ManagedSynonymGraphFilterFactory.java @@ -137,7 +137,8 @@ public class ManagedSynonymGraphFilterFactory extends BaseManagedTokenFilterFact synonymMappings = new TreeMap<>(); if (managedData != null) { Map storedSyns = (Map)managedData; - for (String key : storedSyns.keySet()) { + for (Map.Entry entry : storedSyns.entrySet()) { + String key = entry.getKey(); String caseKey = applyCaseSetting(ignoreCase, key); CasePreservedSynonymMappings cpsm = synonymMappings.get(caseKey); @@ -148,7 +149,7 @@ public class ManagedSynonymGraphFilterFactory extends BaseManagedTokenFilterFact // give the nature of our JSON parsing solution, we really have // no guarantees on what is in the file - Object mapping = storedSyns.get(key); + Object mapping = entry.getValue(); if (!(mapping instanceof List)) { throw new SolrException(ErrorCode.SERVER_ERROR, "Invalid synonym file format! Expected a list of synonyms for "+key+ @@ -156,7 +157,7 @@ public class ManagedSynonymGraphFilterFactory extends BaseManagedTokenFilterFact } Set sortedVals = new TreeSet<>(); - sortedVals.addAll((List)storedSyns.get(key)); + sortedVals.addAll((List) entry.getValue()); cpsm.mappings.put(key, sortedVals); } } @@ -264,8 +265,8 @@ public class ManagedSynonymGraphFilterFactory extends BaseManagedTokenFilterFact protected Map> getStoredView() { Map> storedView = new TreeMap<>(); for (CasePreservedSynonymMappings cpsm : synonymMappings.values()) { - for (String key : cpsm.mappings.keySet()) { - storedView.put(key, cpsm.mappings.get(key)); + for (Map.Entry> entry : cpsm.mappings.entrySet()) { + storedView.put(entry.getKey(), entry.getValue()); } } return storedView; @@ -361,10 +362,10 @@ public class ManagedSynonymGraphFilterFactory extends BaseManagedTokenFilterFact public void parse(Reader in) throws IOException, ParseException { boolean ignoreCase = synonymManager.getIgnoreCase(); for (CasePreservedSynonymMappings cpsm : synonymManager.synonymMappings.values()) { - for (String term : cpsm.mappings.keySet()) { - for (String mapping : cpsm.mappings.get(term)) { + for (Map.Entry> entry : cpsm.mappings.entrySet()) { + for (String mapping : entry.getValue()) { // apply the case setting to match the behavior of the SynonymMap builder - CharsRef casedTerm = analyze(synonymManager.applyCaseSetting(ignoreCase, term), new CharsRefBuilder()); + CharsRef casedTerm = analyze(synonymManager.applyCaseSetting(ignoreCase, entry.getKey()), new CharsRefBuilder()); CharsRef casedMapping = analyze(synonymManager.applyCaseSetting(ignoreCase, mapping), new CharsRefBuilder()); add(casedTerm, casedMapping, false); } diff --git a/solr/core/src/java/org/apache/solr/schema/FieldType.java b/solr/core/src/java/org/apache/solr/schema/FieldType.java index 3bada275c21..397f80f139d 100644 --- a/solr/core/src/java/org/apache/solr/schema/FieldType.java +++ b/solr/core/src/java/org/apache/solr/schema/FieldType.java @@ -1004,9 +1004,10 @@ public abstract class FieldType extends FieldProperties { if (showDefaults) { Map fieldTypeArgs = getNonFieldPropertyArgs(); if (null != fieldTypeArgs) { - for (String key : fieldTypeArgs.keySet()) { - if ( ! CLASS_NAME.equals(key) && ! TYPE_NAME.equals(key)) { - namedPropertyValues.add(key, fieldTypeArgs.get(key)); + for (Map.Entry entry : fieldTypeArgs.entrySet()) { + String key = entry.getKey(); + if ( ! CLASS_NAME.equals(key) && ! TYPE_NAME.equals(key)) { + namedPropertyValues.add(key, entry.getValue()); } } } @@ -1048,11 +1049,12 @@ public abstract class FieldType extends FieldProperties { fieldProperties.add(propertyName); } - for (String key : args.keySet()) { + for (Map.Entry entry : args.entrySet()) { + String key = entry.getKey(); if (fieldProperties.contains(key)) { - namedPropertyValues.add(key, StrUtils.parseBool(args.get(key))); + namedPropertyValues.add(key, StrUtils.parseBool(entry.getValue())); } else if (!CLASS_NAME.equals(key) && !TYPE_NAME.equals(key)) { - namedPropertyValues.add(key, args.get(key)); + namedPropertyValues.add(key, entry.getValue()); } } } @@ -1114,14 +1116,15 @@ public abstract class FieldType extends FieldProperties { props.add(CLASS_NAME, charFilterFactory.getClassArg()); } if (null != factoryArgs) { - for (String key : factoryArgs.keySet()) { + for (Map.Entry entry : factoryArgs.entrySet()) { + String key = entry.getKey(); if ( ! CLASS_NAME.equals(key)) { if (LUCENE_MATCH_VERSION_PARAM.equals(key)) { if (charFilterFactory.isExplicitLuceneMatchVersion()) { - props.add(key, factoryArgs.get(key)); + props.add(key, entry.getValue()); } } else { - props.add(key, factoryArgs.get(key)); + props.add(key, entry.getValue()); } } } @@ -1138,14 +1141,15 @@ public abstract class FieldType extends FieldProperties { tokenizerProps.add(CLASS_NAME, tokenizerFactory.getClassArg()); } if (null != factoryArgs) { - for (String key : factoryArgs.keySet()) { + for (Map.Entry entry : factoryArgs.entrySet()) { + String key = entry.getKey(); if ( ! CLASS_NAME.equals(key)) { if (LUCENE_MATCH_VERSION_PARAM.equals(key)) { if (tokenizerFactory.isExplicitLuceneMatchVersion()) { - tokenizerProps.add(key, factoryArgs.get(key)); + tokenizerProps.add(key, entry.getValue()); } } else { - tokenizerProps.add(key, factoryArgs.get(key)); + tokenizerProps.add(key, entry.getValue()); } } } @@ -1162,14 +1166,15 @@ public abstract class FieldType extends FieldProperties { props.add(CLASS_NAME, filterFactory.getClassArg()); } if (null != factoryArgs) { - for (String key : factoryArgs.keySet()) { + for (Map.Entry entry : factoryArgs.entrySet()) { + String key = entry.getKey(); if ( ! CLASS_NAME.equals(key)) { if (LUCENE_MATCH_VERSION_PARAM.equals(key)) { if (filterFactory.isExplicitLuceneMatchVersion()) { - props.add(key, factoryArgs.get(key)); + props.add(key, entry.getValue()); } } else { - props.add(key, factoryArgs.get(key)); + props.add(key, entry.getValue()); } } } diff --git a/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java b/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java index fa6100de7f8..04aa77cb855 100644 --- a/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java +++ b/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java @@ -122,9 +122,9 @@ public class DisMaxQParser extends QParser { for (String boostFunc : boostFuncs) { if (null == boostFunc || "".equals(boostFunc)) continue; Map ff = SolrPluginUtils.parseFieldBoosts(boostFunc); - for (String f : ff.keySet()) { - Query fq = subQuery(f, FunctionQParserPlugin.NAME).getQuery(); - Float b = ff.get(f); + for (Map.Entry entry : ff.entrySet()) { + Query fq = subQuery(entry.getKey(), FunctionQParserPlugin.NAME).getQuery(); + Float b = entry.getValue(); if (null != b) { fq = new BoostQuery(fq, b); } diff --git a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java index 95d723e57b6..de5700d9bd2 100644 --- a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java +++ b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java @@ -541,9 +541,9 @@ public class ExtendedDismaxQParser extends QParser { for (String boostFunc : config.boostFuncs) { if(null == boostFunc || "".equals(boostFunc)) continue; Map ff = SolrPluginUtils.parseFieldBoosts(boostFunc); - for (String f : ff.keySet()) { - Query fq = subQuery(f, FunctionQParserPlugin.NAME).getQuery(); - Float b = ff.get(f); + for (Map.Entry entry : ff.entrySet()) { + Query fq = subQuery(entry.getKey(), FunctionQParserPlugin.NAME).getQuery(); + Float b = entry.getValue(); if (null != b && b.floatValue() != 1f) { fq = new BoostQuery(fq, b); } diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java b/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java index fd8ce79273e..566be2e5331 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java +++ b/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java @@ -367,12 +367,12 @@ public abstract class FacetRequest { @Override public String toString() { Map descr = getFacetDescription(); - String s = "facet request: { "; - for (String key : descr.keySet()) { - s += key + ":" + descr.get(key) + ","; + StringBuilder s = new StringBuilder("facet request: { "); + for (Map.Entry entry : descr.entrySet()) { + s.append(entry.getKey()).append(':').append(entry.getValue()).append(','); } - s += "}"; - return s; + s.append('}'); + return s.toString(); } /** 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 451c6210284..c57fb000062 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 @@ -100,10 +100,10 @@ public class SimpleMLTQParser extends QParser { } else { Map fieldDefinitions = req.getSearcher().getSchema().getFields(); ArrayList fields = new ArrayList(); - for (String fieldName : fieldDefinitions.keySet()) { - if (fieldDefinitions.get(fieldName).indexed() && fieldDefinitions.get(fieldName).stored()) - if (fieldDefinitions.get(fieldName).getType().getNumberType() == null) - fields.add(fieldName); + for (Map.Entry entry : fieldDefinitions.entrySet()) { + if (entry.getValue().indexed() && entry.getValue().stored()) + if (entry.getValue().getType().getNumberType() == null) + fields.add(entry.getKey()); } fieldNames = fields.toArray(new String[0]); } diff --git a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java index 79faf2158f3..ea425528b5f 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java +++ b/solr/core/src/java/org/apache/solr/update/processor/AtomicUpdateDocumentMerger.java @@ -195,8 +195,9 @@ public class AtomicUpdateDocumentMerger { } // else it's a atomic update map... Map fieldValueMap = (Map)fieldValue; - for (String op : fieldValueMap.keySet()) { - Object obj = fieldValueMap.get(op); + for (Entry entry : fieldValueMap.entrySet()) { + String op = entry.getKey(); + Object obj = entry.getValue(); if (!op.equals("set") && !op.equals("inc")) { // not a supported in-place update op return Collections.emptySet(); diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.java index e6834abfaba..bcaa9b806ed 100755 --- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java +++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java @@ -3467,8 +3467,9 @@ public class SolrCLI implements CLIO { Map startEnv = new HashMap<>(); Map procEnv = EnvironmentUtils.getProcEnvironment(); if (procEnv != null) { - for (String envVar : procEnv.keySet()) { - String envVarVal = procEnv.get(envVar); + for (Map.Entry entry : procEnv.entrySet()) { + String envVar = entry.getKey(); + String envVarVal = entry.getValue(); if (envVarVal != null && !"EXAMPLE".equals(envVar) && !envVar.startsWith("SOLR_")) { startEnv.put(envVar, envVarVal); } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/KnnStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/KnnStream.java index 64fcd027969..c03db3820d3 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/KnnStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/KnnStream.java @@ -227,8 +227,8 @@ public class KnnStream extends TupleStream implements Expressible { if(documentIterator.hasNext()) { Map map = new HashMap(); SolrDocument doc = documentIterator.next(); - for(String key : doc.keySet()) { - map.put(key, doc.get(key)); + for(Entry entry : doc.entrySet()) { + map.put(entry.getKey(), entry.getValue()); } return new Tuple(map); } else { @@ -241,9 +241,9 @@ public class KnnStream extends TupleStream implements Expressible { private ModifiableSolrParams getParams(Map props) { ModifiableSolrParams params = new ModifiableSolrParams(); - for(String key : props.keySet()) { - String value = props.get(key); - params.add(key, value); + for(Entry entry : props.entrySet()) { + String value = entry.getValue(); + params.add(entry.getKey(), value); } return params; } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/RandomFacadeStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/RandomFacadeStream.java index 5a343eb525a..f9735cef9c4 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/RandomFacadeStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/RandomFacadeStream.java @@ -101,8 +101,8 @@ public class RandomFacadeStream extends TupleStream implements Expressible { private SolrParams toSolrParams(Map props) { ModifiableSolrParams sp = new ModifiableSolrParams(); - for(String key : props.keySet()) { - sp.add(key, props.get(key)); + for(Map.Entry entry : props.entrySet()) { + sp.add(entry.getKey(), entry.getValue()); } return sp; } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/RandomStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/RandomStream.java index 68988a0478c..1a6083b8d9b 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/RandomStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/RandomStream.java @@ -216,8 +216,8 @@ public class RandomStream extends TupleStream implements Expressible { if(documentIterator.hasNext()) { Map map = new HashMap(); SolrDocument doc = documentIterator.next(); - for(String key : doc.keySet()) { - map.put(key, doc.get(key)); + for(Entry entry : doc.entrySet()) { + map.put(entry.getKey(), entry.getValue()); } return new Tuple(map); } else { @@ -230,9 +230,9 @@ public class RandomStream extends TupleStream implements Expressible { private ModifiableSolrParams getParams(Map props) { ModifiableSolrParams params = new ModifiableSolrParams(); - for(String key : props.keySet()) { - String value = props.get(key); - params.add(key, value); + for(Entry entry : props.entrySet()) { + String value = entry.getValue(); + params.add(entry.getKey(), value); } return params; } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SearchStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SearchStream.java index 3643969f23c..24368a0a982 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SearchStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SearchStream.java @@ -210,8 +210,8 @@ public class SearchStream extends TupleStream implements Expressible { if(documentIterator.hasNext()) { Map map = new HashMap(); SolrDocument doc = documentIterator.next(); - for(String key : doc.keySet()) { - map.put(key, doc.get(key)); + for(Entry entry : doc.entrySet()) { + map.put(entry.getKey(), entry.getValue()); } return new Tuple(map); } else {