magibney commented on PR #1440:
URL: https://github.com/apache/solr/pull/1440#issuecomment-1462597683

   I could be mistaken, but iiuc most normal writes (what we've been 
benchmarking in the related dev@solr discussion) run through 
[here](https://github.com/apache/solr/blob/c99af207c761ec34812ef1cc3054eb2804b7448b/solr/core/src/java/org/apache/solr/response/QueryResponseWriterUtil.java#L51-L73).
   
   I wonder in that case how much of the speedup we've observed from this 
change might simply be related to bypassing the shim `OutputStream` that only 
overrides `write(int byte)`. Put another way: what would be the impact of 
simply overriding `write(byte[] buf, int offset, int length)` on that shim 
`OutputStream`?
   
   `writeStrRaw` is basically equivalent to both the 
`gen.writeRawValue(String)` and `gen.writeRaw(String)` methods. The distinction 
between `writeRawValue()` and `writeRaw()` is I think a bit of an impedance 
mismatch between Solr's `TextWriter` API and the Jackson `JsonGenerator` API -- 
the clue is in the no-op methods for writing separators in `WriterImpl` in this 
PR, and I think the consequence is that because we're no-opping those, we 
should _always_ use `gen.writeRawValue()` from the context of Solr. Related: I 
also note that `gen.writeRawValue(String)` says nothing about wrapping Strings 
in quotes -- in fact the `gen.writeRawValue()` methods don't know the type 
context at all, so I think that may requires a change in the else clause of 
`writeStr()`, to:
   ```java
       public void writeStr(String name, String val, boolean needsEscaping) 
throws IOException {
         if (needsEscaping) {
           gen.writeString(val);
         } else {
           gen.writeRawValue("\"");
           gen.writeRaw(val);
            gen.writeRaw("\"");
        }
       }
   ```


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

Reply via email to