Skip to content
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

Merged
merged 3 commits into from
Aug 21, 2018

Conversation

markharwood
Copy link
Contributor

Documentation yet to be done

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@markharwood
Copy link
Contributor Author

test this please

* as a weight.
*/
public class Connection {
Vertex from;
Copy link
Member

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 {
Copy link
Member

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
Copy link
Member

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) {
Copy link
Member

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()) {
Copy link
Member

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.

Copy link
Contributor Author

@markharwood markharwood Aug 8, 2018

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?

Copy link
Member

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.

@hub-cap
Copy link
Contributor

hub-cap commented Aug 3, 2018

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 client.xpack().yourCommercialClient() is removed.

@markharwood markharwood force-pushed the fix/29827Graph branch 2 times, most recently from 03fccf1 to 0e54b45 Compare August 7, 2018 11:15
@markharwood markharwood removed the WIP label Aug 8, 2018
@markharwood markharwood force-pushed the fix/29827Graph branch 3 times, most recently from 7a10597 to 809a478 Compare August 14, 2018 12:47
@markharwood
Copy link
Contributor Author

Many thanks for the review, @nik9000 . I've switched the code over to ObjectParser.

Good to go @nik9000 @hub-cap ?





Copy link
Contributor

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!

@hub-cap
Copy link
Contributor

hub-cap commented Aug 14, 2018

if @nik9000 is good then Im good too. I just did a super quick eyeball and didnt see anything insane. :shipit: if its got an approval from him... i was out all last week so im still coming back up to speed :)

@markharwood
Copy link
Contributor Author

Any other budding reviewers you can suggest, @hub-cap ?

@hub-cap
Copy link
Contributor

hub-cap commented Aug 17, 2018

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.

Copy link
Member

@nik9000 nik9000 left a 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 {
Copy link
Member

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 {
Copy link
Member

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?

@markharwood
Copy link
Contributor Author

Many thanks, @nik9000
I addressed your review comments and will push when I get a green result here.

@markharwood markharwood merged commit 38bdf9c into elastic:master Aug 21, 2018
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.

6 participants