dsmiley commented on code in PR #3163:
URL: https://github.com/apache/solr/pull/3163#discussion_r1945550364


##########
solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java:
##########
@@ -863,6 +868,26 @@ protected Map<Object, Object> readMap(DataInputInputStream 
dis, int sz) throws I
     return m;
   }
 
+  @SuppressWarnings({"rawtypes", "unchecked"})
+  protected Map<?, Object> 
readMapAsSimpleOrderedMapForStringKeys(DataInputInputStream dis, int sz)
+      throws IOException {
+    Map m = null;
+    for (int i = 0; i < sz; i++) {
+      Object key = readVal(dis);
+
+      if (m == null) {
+        if (key instanceof String) {
+          m = new SimpleOrderedMap<>(sz);
+        } else {
+          m = newMap(sz);
+        }
+      }
+      Object val = readVal(dis);
+      m.put(key, val);
+    }
+    return m;
+  }
+

Review Comment:
   Oh man I didn't think of that!  Let's say we treat keys as a String no 
matter what.  I'm suspicious that our response formats would ever have a map 
whose key isn't a string.  Maybe add an assert if the key isn't already a 
String so that we can more readily identify problems.  (not sure if may read 
CharSequence but we can consider that as a String).



##########
solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java:
##########
@@ -848,9 +848,14 @@ protected Map<Object, Object> newMap(int size) {
     return size < 0 ? new LinkedHashMap<>() : 
CollectionUtil.newLinkedHashMap(size);
   }
 
-  public Map<Object, Object> readMap(DataInputInputStream dis) throws 
IOException {
+  public Map<?, Object> readMap(DataInputInputStream dis) throws IOException {
     int sz = readVInt(dis);
-    return readMap(dis, sz);
+
+    if (EnvUtils.getPropertyAsBool("solr.solrj.javabin.mapAsNamedList", true)) 
{

Review Comment:
   Reading this setting on _every single map decode_ is quite bad for 
performance.  This setting should be a field on the codec, and that which could 
be toggled with a setter (if useful in a test).



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

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

Reply via email to