Introduce chunked version of ToXContentObject#92549
Introduce chunked version of ToXContentObject#92549original-brownbear merged 8 commits intoelastic:mainfrom original-brownbear:fragments-for-chunked-to-xcontent
Conversation
Aligning how chunked and normal `ToXContent` work here and simplifying spots where it matters whether or not something is a fragment or not.
|
|
||
| @Override | ||
| public String toString() { | ||
| return "InternalScriptedMetric{" + reduceScript + "}"; |
There was a problem hiding this comment.
Had to do something here since the parent class's toString would call back to toXContent here which would throw if the instance hasn't yet been reduced.
| Map<String, DiskUsage> builder = new HashMap<>(numEntries); | ||
| for (int i = 0; i < numEntries; i++) { | ||
| String key = randomAlphaOfLength(32); | ||
| final int totalBytes = randomIntBetween(0, Integer.MAX_VALUE); |
There was a problem hiding this comment.
Had to fix this to use plausible values, otherwise toString would run into negative byte values which would throw illegal argument ex.
| }"""), xContent.utf8ToString()); | ||
| } | ||
|
|
||
| public void testToString() { |
There was a problem hiding this comment.
Moved to the parent now to deal with this for all the things we serialize
| @Override | ||
| public String toString() { | ||
| if (indexResponses.size() > 0) { | ||
| return "FieldCapabilitiesResponse{unmerged}"; |
There was a problem hiding this comment.
Not great but we shouldn't throw on toString ever so we have to have some breakout here for the un-merged case that doesn't allow toXContent.
|
Jenkins run elasticsearch-ci/part-3 |
|
@DaveCTurner I think this is the direction I'd like to go before we add more stuff around fragments. Seems easiest to just align with |
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
DaveCTurner
left a comment
There was a problem hiding this comment.
Makes sense, yes.
Why not replace org.elasticsearch.common.xcontent.ChunkedToXContent#wrapAsXContentObject with something that returns a ToXContent with the appropriate isFragment value?
|
@DaveCTurner ++ good point, that alley for even more simplifications. See f64ad95 :) |
server/src/main/java/org/elasticsearch/common/xcontent/ChunkedToXContent.java
Outdated
Show resolved
Hide resolved
|
Thanks David! |
Aligning how chunked and normal
ToXContentwork here and simplifying spots where it matters whether or not something is a fragment or not.This fixes broken
toStringfor all kinds of classes and adds a test that makes sure the implementation at least produces a result and doesn't throw.