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

Make Terms.Bucket an interface rather than an abstract class #24492

Merged
merged 1 commit into from May 5, 2017

Conversation

tlrx
Copy link
Member

@tlrx tlrx commented May 4, 2017

This commit changes the Terms.Bucket abstract class to an interface, so that it's easier for the Java High Level Rest Client to provide its own implementation.

In its current state, the Terms.Bucket abstract class inherits from InternalMultiBucketAggregation.InternalBucket which forces subclasses to implement Writeable and to expose a public getProperty() method that relies on InternalAggregation. This two points make it difficult for the Java High Level Rest Client to implement the Terms and Terms.Bucket correctly. This is also different from other MultiBucketsAggregation like Range which are pure interfaces.

Sadly, changing Terms.Bucket to an interface caused a method clash for the
getBuckets() method in InternalTerms because:

  • InternalTerms implements Terms which declared a List<Terms.Bucket> getBuckets() method
  • InternalTerms extends InternalMultiBucketAggregation which declares a List<? extends InternalBucket> getBuckets() method
    and both overrides the MultiBucketsAggregation List<? extends Bucket> getBuckets() method.

There was no clashes before this change because Terms.Bucket extends InternalBucket and conformed to both declarations. With Terms.Bucket now an interface, this commit changes the getBuckets() method in the Terms interface so that it now returns List<? extends Bucket> instead of List<Terms.Bucket>. I didn't see a better way to do this.

This is a breaking change in the Java API but it's a straightforward change and the Terms multi bucket aggregation interface is also more coherent with the other Range, Histogram, Filters, AdjacencyMatrix etc that all return a List<? extends Bucket>.

This commit changes the Terms.Bucket abstract class to an interface, so
that it's easier for the Java High Level Rest Client to provide its own
implementation.

In its current state, the Terms.Bucket abstract class inherits from
InternalMultiBucketAggregation.InternalBucket which forces subclasses to
implement Writeable and exposes a public getProperty() method that relies
on InternalAggregation. This two points make it difficult for the Java
High Level Rest Client to implement the Terms and Terms.Bucket correctly.
This is also different from other MultiBucketsAggregation like Range
which are pure interfaces.

Changing Terms.Bucket to an interface causes a method clashes for the
`getBuckets()` method in InternalTerms. This is because:
 - InternalTerms implements Terms which declared a
 `List<Terms.Bucket> getBuckets()` method
 - InternalTerms extends InternalMultiBucketAggregation which declares a
 `List<? extends InternalBucket> getBuckets()` method
 - both overrides the MultiBucketsAggregation
 `List<? extends Bucket> getBuckets()` method

 There was no clashes before this change because Terms.Bucket extends
 InternalBucket and conformed to both declaration. With Terms.Bucket now
 an interface, the getBuckets() method in the Terms interface is changed
 to avoid method clash. This is a breaking change in the Java API but
 it's a straightforward change and the Terms multi bucket aggregation
 interface is also more coherent with the other Range, Histogram,
 Filters, AdjacencyMatrix etc that all return a `List<? extends Bucket>`.
@tlrx tlrx requested a review from javanna May 4, 2017 15:19
@javanna javanna changed the title Change Terms.Bucket to an interface Make Terms.Bucket an interface rather than an abstract class May 5, 2017
Copy link
Member

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

LGTM

@javanna javanna added the v5.5.0 label May 5, 2017
@tlrx tlrx merged commit 7bd2abe into elastic:master May 5, 2017
@tlrx
Copy link
Member Author

tlrx commented May 5, 2017

Thanks @javanna !

tlrx added a commit that referenced this pull request May 5, 2017
This commit changes the Terms.Bucket abstract class to an interface, so
that it's easier for the Java High Level Rest Client to provide its own
implementation.

In its current state, the Terms.Bucket abstract class inherits from
InternalMultiBucketAggregation.InternalBucket which forces subclasses to
implement Writeable and exposes a public getProperty() method that relies
on InternalAggregation. This two points make it difficult for the Java
High Level Rest Client to implement the Terms and Terms.Bucket correctly.
This is also different from other MultiBucketsAggregation like Range
which are pure interfaces.

Changing Terms.Bucket to an interface causes a method clashes for the
`getBuckets()` method in InternalTerms. This is because:
 - InternalTerms implements Terms which declared a
 `List<Terms.Bucket> getBuckets()` method
 - InternalTerms extends InternalMultiBucketAggregation which declares a
 `List<? extends InternalBucket> getBuckets()` method
 - both overrides the MultiBucketsAggregation
 `List<? extends Bucket> getBuckets()` method

 There was no clashes before this change because Terms.Bucket extends
 InternalBucket and conformed to both declaration. With Terms.Bucket now
 an interface, the getBuckets() method in the Terms interface is changed
 to avoid method clash. This is a breaking change in the Java API but
 it's a straightforward change and the Terms multi bucket aggregation
 interface is also more coherent with the other Range, Histogram,
 Filters, AdjacencyMatrix etc that all return a `List<? extends Bucket>`.

(cherry picked from commit 7bd2abe)
@tlrx tlrx deleted the terms-bucket-interface branch May 5, 2017 19:45
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request May 6, 2017
* master:
  Fix plugin installation permissions
  Remove unneeded empty string concatentation
  TimeValue#parseTimeValue author is bad, feels bad
  Add workaround so path.data can be set in run task
  Change Terms.Bucket to an interface (elastic#24492)
  Update completion-suggest.asciidoc (elastic#24506)
  Add new ip_range field type
  Expand cross cluster search indices for search requests to the concrete index or to it's aliases (elastic#24502)
  Fixed docs syntax for for-in loop in painless
  [TEST] Reenable disabled tests for _field_caps and _search_shards (elastic#24505)
SGM3 added a commit to SGM3/liferay-portal that referenced this pull request Jul 6, 2017
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.

None yet

3 participants