-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
GraphClient for the high level REST client and associated tests #32366
Conversation
Pinging @elastic/es-core-infra |
Pinging @elastic/es-search-aggs |
5356df0
to
ea2f8df
Compare
test this please |
* as a weight. | ||
*/ | ||
public class Connection { | ||
Vertex from; |
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.
I think it'd be nice if these were private. We've been trying to be more "standard-java" in the rest client.
return new Connection(vertices.get(fromIndex), vertices.get(toIndex), weight, docCount); | ||
} | ||
|
||
static UnresolvedConnection fromXContent(XContentParser parser) throws IOException { |
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.
I think ObjectParser
would be easier to review but this looks right so I'm fine with it.
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
|
||
builder.startObject("controls"); //=== Start Controls |
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.
I've borrowed a style from dakrone that looks like
builder.startObject("controls");
{
if (sampleSize != ... ) {
builder.field("sample_size", sampleSize);
}
...
}
builder.endObject();
It sort of replaces the need for //=== Start Controls
.
builder.endObject(); //=== End controls | ||
|
||
for (Hop hop : hops) { | ||
if (hop.parentHop != 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.
They look like a chain! Woah!
List<Vertex> vertices = new ArrayList<>(); | ||
List<ShardSearchFailure> failures = new ArrayList<>(); | ||
List<Connection.UnresolvedConnection> unresolvedConnections = new ArrayList<>(); | ||
for (Token token = parser.nextToken(); token != Token.END_OBJECT; token = parser.nextToken()) { |
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 one also looks right when I scan it but'd be easier to review as ObjectParser
.
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.
I may be missing something but isn't ObjectParser more geared towards parsing "request" objects? Requests tend to have existing "Builder" classes with setter methods used by clients to express criteria and ObjectParser relies on registering setter methods.
Response objects tend to be immutable data objects so to accommodate ObjectParser we either end up adding "setter" methods to response objects (ugh) or creating non-public "ResponseBuilder" classes?
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.
ConstructingObjectParser
can mostly get the job done without needing any extra builders. But sometimes builders are easier to understand. The idea with using these parsers is that they are a ton easier to review for correctness, especially that they properly ignore new fields. It isn't required, but it does make it easier to be sure that it is all rigged up right.
11caa1d
to
4891e85
Compare
I have just committed #32596 which changes the location of the xpack clients. Its very likely your tests wont compile now that the xpack portion of |
03fccf1
to
0e54b45
Compare
7a10597
to
809a478
Compare
|
||
|
||
|
||
|
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.
thats a lot of blank lines!
if @nik9000 is good then Im good too. I just did a super quick eyeball and didnt see anything insane. if its got an approval from him... i was out all last week so im still coming back up to speed :) |
809a478
to
9be83b1
Compare
Any other budding reviewers you can suggest, @hub-cap ? |
hey, yea Ill just do a review in the next 24 hrs. Im trying to get the actions fixed up first. Id prefer to get that merged, but if u get an approval first then GOGOGO. |
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.
Left two little picky things but LGTM anyway. Thanks for working through all of my requests!
@@ -2598,6 +2601,35 @@ public void testXPackPutWatch() throws Exception { | |||
request.getEntity().writeTo(bos); | |||
assertThat(bos.toString("UTF-8"), is(body)); | |||
} | |||
|
|||
public void testXPackGraphExplore() throws Exception { |
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.
I think maybe this should be testGraphExplore
now that we're removing the xpack
in lots of places.
this.docCount = docCount; | ||
} | ||
|
||
void readFrom(StreamInput in, Map<VertexId, Vertex> vertices) throws IOException { |
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.
Why not a ctor that takes StreamInput and Map?
9be83b1
to
e7360a8
Compare
Many thanks, @nik9000 |
Documentation yet to be done