You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the referenced line of code, the start position is calculated using Pageable.getPageSize * Pageable.getPageNumber. The same result is also available through the Pageable.getOffset method.
I know the main difference is Pageable.getOffset returns a long and the startRecord assignment is an int so there will be some Integer overflow issues to worry about (see Potential Concerns).
Reasoning
The reasoning for asking is we are using a custom Pageable that works with limits and offsets (similar to https://stackoverflow.com/a/32763885). Unfortunately there does not seem to be an easy way to alter/override the referenced JestElasticsearchTemplate line without making our own version of the class.
Potential Concerns
My main concerns with the change are:
It would impact current users of the library that use a custom Pageable that doesn't calculate the offset [correctly]. That means this change will have to be communicated clearly in the the release notes.
Potential integer overflow issue during the downcast from long to int. Though, this would be an issue in the current code if pageSize * pageNumber was high enough. Plus that would be well into the Elasticsearch max_result_window territory.
Way Ahead
If you agree with this change, I'd be happy to submit a PR for approval.
The text was updated successfully, but these errors were encountered:
Request
Could the following line of code in
JestElasticsearchTemplate
be changed to usePageable.getOffset
instead?spring-data-jest/spring-data-jest/src/main/java/com/github/vanroy/springdata/jest/JestElasticsearchTemplate.java
Line 1153 in 97428c3
Details
In the referenced line of code, the start position is calculated using
Pageable.getPageSize * Pageable.getPageNumber
. The same result is also available through thePageable.getOffset
method.I know the main difference is
Pageable.getOffset
returns along
and thestartRecord
assignment is anint
so there will be some Integer overflow issues to worry about (see Potential Concerns).Reasoning
The reasoning for asking is we are using a custom
Pageable
that works with limits and offsets (similar to https://stackoverflow.com/a/32763885). Unfortunately there does not seem to be an easy way to alter/override the referencedJestElasticsearchTemplate
line without making our own version of the class.Potential Concerns
My main concerns with the change are:
Pageable
that doesn't calculate the offset [correctly]. That means this change will have to be communicated clearly in the the release notes.long
toint
. Though, this would be an issue in the current code ifpageSize * pageNumber
was high enough. Plus that would be well into the Elasticsearchmax_result_window
territory.Way Ahead
If you agree with this change, I'd be happy to submit a PR for approval.
The text was updated successfully, but these errors were encountered: