Move indices field from RankEvalSpec to RankEvalRequest#28341
Move indices field from RankEvalSpec to RankEvalRequest#28341cbuescher merged 5 commits intoelastic:masterfrom
Conversation
There was a problem hiding this comment.
is this correct? why skip rest tests? aren't we only changing where indices are set internally?
There was a problem hiding this comment.
I changed this previously because I changed the place where the indices strings for serialized/deserialized. However, I now think this isn't necessary since even though the location where the string array is writen changes, the overall ordering on the wire shouldn't change, thus there should be nothing breaking here. I removed the version skip changes in the last update.
|
@javanna thanks for looking into this, I will update the PR shortly |
|
/cc @elastic/es-search-aggs |
Currently we store the indices specified in the request URL together with all the other ranking evaluation specification in RankEvalSpec. This is not ideal since e.g. the indices are not rendered to xContent and so cannot be parsed back. Instead we should keep them in RankEvalRequest, like we already also do for other kinds of requests (like SearchRequest).
aa84707 to
a34c6d3
Compare
| indices = new ArrayList<>(indicesSize); | ||
| for (int i = 0; i < indicesSize; i++) { | ||
| this.indices.add(in.readString()); | ||
| } |
There was a problem hiding this comment.
This should me handled by out.writeStringArray(indices) in the request now, and shouldn't change the wire protocol so no version-dependent logic needed here I think.
There was a problem hiding this comment.
I think we are out of luck, I hadn't noticed. readStringArray does readVInt while we were previously doing readInt, same for the write methods. This is odd, it sounds like it would break bw comp on the wire.
There was a problem hiding this comment.
Good point, I will add a version check here.
| out.writeInt(indices.size()); | ||
| for (String index : indices) { | ||
| out.writeString(index); | ||
| } |
There was a problem hiding this comment.
This should me handled by in.readStringArray() in the request now, and shouldn't change the wire protocol so no version-dependent logic needed here I think.
|
@javanna thanks for the review, I pushed an update. Can you take a look again and also check if my above reasoning about not needing a bwc check on the wire makes sense? |
| } | ||
|
|
||
| public String[] getIndices() { | ||
| return Arrays.copyOf(indices, indices.length); |
There was a problem hiding this comment.
nit: just return the indices? I think that's what we do everywhere else.
There was a problem hiding this comment.
I wanted to protect the indices from accidental modifications, but since there is a setter for them, they are mutable anyway, so I changed this like you suggested.
| indices = new ArrayList<>(indicesSize); | ||
| for (int i = 0; i < indicesSize; i++) { | ||
| this.indices.add(in.readString()); | ||
| } |
There was a problem hiding this comment.
I think we are out of luck, I hadn't noticed. readStringArray does readVInt while we were previously doing readInt, same for the write methods. This is odd, it sounds like it would break bw comp on the wire.
|
@javanna I added version checks and made a few more changes in my last updates, can you take another look? |
| if (in.getVersion().onOrAfter(Version.V_6_3_0)) { | ||
| indices = in.readStringArray(); | ||
| } else { | ||
| // older 6.2 format |
There was a problem hiding this comment.
add to the comment readVint vs readInt just to clarify something that may not be clear at first?
There was a problem hiding this comment.
I don't know if this clarifies things a lot since it requires looking into what readStringArray does? At this point I wonder if I should remove the comment completely, the code should explain this by itself and I think we can remove it on master after 6.3 is release (we only try to be bwc with the latest minor release before a major, no?)
There was a problem hiding this comment.
I think the comment may be useful, to clarify why we have this conditional as it looks weird at first. Of course if one looks deeper will also find out why we have it. Up to you
| if (out.getVersion().onOrAfter(Version.V_6_3_0)) { | ||
| out.writeStringArray(indices); | ||
| } else { | ||
| // older 6.2 format |
| public void writeTo(StreamOutput out) throws IOException { | ||
| super.writeTo(out); | ||
| rankingEvaluationSpec.writeTo(out); | ||
| if (out.getVersion().onOrAfter(Version.V_6_3_0)) { |
There was a problem hiding this comment.
on the version conditionals, you may need to first use 7_0_0_alpha1 on master before you backport to 6.x, then you can update the version on master too.
There was a problem hiding this comment.
Given that 6.3 isn't release yet, bwc tests should only run vs. 6.2 if this is merged shortly, or am I missing sth?
There was a problem hiding this comment.
I always get this wrong, you seem to know what you are doing better than me! :)
There was a problem hiding this comment.
np, I just thought about it when you mentioned it.
|
@javanna thanks for the review, I changed the comments slightly, will wait for this CI build before merging |
|
@elasticmachine test this again please |
Currently we store the indices specified in the request URL together with all the other ranking evaluation specification in RankEvalSpec. This is not ideal since e.g. the indices are not rendered to xContent and so cannot be parsed back. Instead we should keep them in RankEvalRequest.
Currently we store the indices specified in the request URL together with all
the other ranking evaluation specification in RankEvalSpec. This is not ideal
since e.g. the indices are not rendered to xContent and so cannot be parsed
back. Instead we should keep them in RankEvalRequest, like we already also do
for other kinds of requests (like SearchRequest).