Skip to content

Conversation

@benwtrent
Copy link
Member

There are many ways to make the use of data frames simpler through the HLRC.

A step in the right direction is providing fluent builders for each of the more complicated configs.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core

@przemekwitek przemekwitek self-requested a review April 29, 2019 13:44
return Strings.toString(this, true, true);
}

public static Builder builder() {

Choose a reason for hiding this comment

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

Do you think it would make sense to make DataFrameTransformConfig constructor private now that we have "builder()" as a recommended entry point to this class? The same question for other classes...

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a good thought, How about "package private" so that tests can still utilize it?

Choose a reason for hiding this comment

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

Package-private SGTM

return this;
}

public Builder setInterval(long interval) {

Choose a reason for hiding this comment

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

Should this method accept "Duration" instead of "long"?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was trying to make this parallel the DateHistogramAggregationBuilder. Though I should add docs stating what time resolution interval is.

Choose a reason for hiding this comment

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

Yeah, if we talk about usability here, it is usually error-prone if the user has to provide "long" but does not know what the unit is.

Copy link
Member Author

Choose a reason for hiding this comment

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

@przemekwitek I added some docs and a new method that accepts a TimeValue parameter as well.

}

public DateHistogramGroupSource build() {
DateHistogramGroupSource groupSource = new DateHistogramGroupSource(field);

Choose a reason for hiding this comment

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

Introducing Builder is a great opportunity to make the data class itself (here, DateHistogramGroupSource) immutable. Do you plan on making it so or you find such an approach too restrictive?

Copy link
Member Author

Choose a reason for hiding this comment

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

We totally should do this. I will see if I can make them final.

private final Map<String, SingleGroupSource> groups;

public Builder() {
this.groups = new HashMap<>();

Choose a reason for hiding this comment

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

I think you could move initialization to line 184.

return this;
}

public Builder setInterval(double interval) {

Choose a reason for hiding this comment

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

Same question, should we use "Duration" here?

Copy link
Member Author

Choose a reason for hiding this comment

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

that does not make sense here as interval in this case is any arbitrary number. Any numeric field can be grouped via a histogram, not just a time field.

Choose a reason for hiding this comment

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

A, ok. So this was my misunderstanding (I associated "interval" with some time duration).

Copy link

@przemekwitek przemekwitek left a comment

Choose a reason for hiding this comment

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

Added a couple of inline comments.


public DataFrameTransformConfig(final String id,
DataFrameTransformConfig(final String id,
final SourceConfig source,

Choose a reason for hiding this comment

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

Please fix indentation

return Objects.hash(field, interval);
}

public static Builder builder() {

Choose a reason for hiding this comment

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

For some reason, I cannot leave comment in the line 55. Anyway, leaving it here: Please make the constructor package-private

Copy link

@przemekwitek przemekwitek left a comment

Choose a reason for hiding this comment

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

LGTM
I value immutability so I believe this PR is a step in a right direction.

@benwtrent benwtrent merged commit f87a1fd into elastic:master Apr 30, 2019
@benwtrent benwtrent deleted the feature/ml-df-client-improvements branch April 30, 2019 17:45
benwtrent added a commit to benwtrent/elasticsearch that referenced this pull request Apr 30, 2019
…lastic#41638)

* [ML] data frame, adding builder classes for complex config classes

* Addressing PR comments, adding some java docs

* cleaning up constructor

* fixing indentation

* change constructors to be package-private
benwtrent added a commit that referenced this pull request May 1, 2019
…41638) (#41704)

* [ML] data frame, adding builder classes for complex config classes

* Addressing PR comments, adding some java docs

* cleaning up constructor

* fixing indentation

* change constructors to be package-private
akhil10x5 pushed a commit to akhil10x5/elasticsearch that referenced this pull request May 2, 2019
…lastic#41638)

* [ML] data frame, adding builder classes for complex config classes

* Addressing PR comments, adding some java docs

* cleaning up constructor

* fixing indentation

* change constructors to be package-private
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this pull request May 27, 2019
…lastic#41638)

* [ML] data frame, adding builder classes for complex config classes

* Addressing PR comments, adding some java docs

* cleaning up constructor

* fixing indentation

* change constructors to be package-private
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.

4 participants