dsmiley commented on code in PR #4415:
URL: https://github.com/apache/solr/pull/4415#discussion_r3238629314
##########
changelog/unreleased/SOLR-18237-no-buffer.yml:
##########
@@ -0,0 +1,7 @@
+title: Do not copy full data for UTF8 to Java string conversion for
deserializing a collection state
+type: fixed
Review Comment:
users will not perceive this as a fix of a bug. It's "changed". But I'm
skeptical it warrants a changelog at all.
##########
solr/solrj/src/java/org/apache/solr/common/util/Utils.java:
##########
@@ -297,16 +294,10 @@ public static Object fromJSON(
if (utf8 == null || utf8.length == 0 || length == 0) {
return Map.of();
}
- // convert directly from bytes to chars
- // and parse directly from that instead of going through
- // intermediate strings or readers
- CharArr chars = new CharArr();
- ByteUtils.UTF8toUTF16(utf8, offset, length, chars);
- JSONParser parser = new JSONParser(chars.getArray(), chars.getStart(),
chars.length());
- parser.setFlags(
- parser.getFlags()
- | JSONParser.ALLOW_MISSING_COLON_COMMA_BEFORE_OBJECT
- | JSONParser.OPTIONAL_OUTER_BRACES);
+ // convert from bytes to chars on-the-fly and parse directly
+ // from that instead of going through intermediate buffers
+ Reader reader = new InputStreamReader(new ByteArrayInputStream(utf8,
offset, length), UTF_8);
Review Comment:
this is definitely the most natural/clear way to do things instead of
anything else. Maybe it's faster; I trust your judgement.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]