-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chunked encoding for _cat APIs #92022
Chunked encoding for _cat APIs #92022
Conversation
Some of these APIs scale as O(#indices) or O(#shards) so it seems worthwhile to use chunked encoding throughout. Relates elastic#89838
Pinging @elastic/es-distributed (Team:Distributed) |
import java.io.OutputStream; | ||
import java.io.Writer; | ||
|
||
public final class UTF8StreamWriter extends Writer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This claims performance benefits over the JDK's Writer
. It's possible those claims are true, but I don't think this is on a hot enough path to warrant having yet another custom (and wholly untested) implementation of UTF-8 encoding, so I've replaced it with a regular Writer
instead.
currentOutput = null; | ||
return new ReleasableBytesReference(chunkOutput.bytes(), () -> Releasables.closeExpectNoException(chunkOutput)); | ||
} finally { | ||
if (currentOutput != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I don't see any obvious ways to throw exceptions in this area, I'm somewhat dubious about how such an exception would be handled in the networking code (edit: I get it now, but for the sake of safety we have to close currentOutput
if we're not returning)
@elasticmachine update branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great thanks! Just one question on a test.
test/framework/src/main/java/org/elasticsearch/rest/RestResponseUtils.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Some of these APIs scale as O(#indices) or O(#shards) so it seems worthwhile to use chunked encoding throughout.
Relates #89838