Skip to content

Move indices field from RankEvalSpec to RankEvalRequest#28341

Merged
cbuescher merged 5 commits intoelastic:masterfrom
cbuescher:move-rankeval-indices
Mar 19, 2018
Merged

Move indices field from RankEvalSpec to RankEvalRequest#28341
cbuescher merged 5 commits intoelastic:masterfrom
cbuescher:move-rankeval-indices

Conversation

@cbuescher
Copy link
Copy Markdown
Member

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).

Copy link
Copy Markdown
Contributor

@javanna javanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had not seen this, I left a couple of comments, LGTM though. Wasn't there also a TODO somewhere in the high-level client code that can be resolved once we merge this in?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in.readStringArray()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out.writeStringArray()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct? why skip rest tests? aren't we only changing where indices are set internally?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cbuescher
Copy link
Copy Markdown
Member Author

@javanna thanks for looking into this, I will update the PR shortly

@cbuescher cbuescher self-assigned this Mar 13, 2018
@cbuescher
Copy link
Copy Markdown
Member Author

/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).
@cbuescher cbuescher force-pushed the move-rankeval-indices branch from aa84707 to a34c6d3 Compare March 15, 2018 16:50
indices = new ArrayList<>(indicesSize);
for (int i = 0; i < indicesSize; i++) {
this.indices.add(in.readString());
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I will add a version check here.

out.writeInt(indices.size());
for (String index : indices) {
out.writeString(index);
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cbuescher
Copy link
Copy Markdown
Member Author

@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?

Copy link
Copy Markdown
Contributor

@javanna javanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a small comment

}

public String[] getIndices() {
return Arrays.copyOf(indices, indices.length);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: just return the indices? I think that's what we do everywhere else.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cbuescher
Copy link
Copy Markdown
Member Author

@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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add to the comment readVint vs readInt just to clarify something that may not be clear at first?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
rankingEvaluationSpec.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

@cbuescher cbuescher Mar 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always get this wrong, you seem to know what you are doing better than me! :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np, I just thought about it when you mentioned it.

@cbuescher
Copy link
Copy Markdown
Member Author

@javanna thanks for the review, I changed the comments slightly, will wait for this CI build before merging

@cbuescher
Copy link
Copy Markdown
Member Author

@elasticmachine test this again please

@cbuescher cbuescher merged commit 8053222 into elastic:master Mar 19, 2018
cbuescher pushed a commit that referenced this pull request Mar 19, 2018
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.
@cbuescher cbuescher deleted the move-rankeval-indices branch November 27, 2025 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants