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

Improve Time-Series Bucketing Scalability #1137

Merged
merged 8 commits into from
Jun 15, 2023
Merged

Conversation

vbabanin
Copy link
Member

@vbabanin vbabanin commented Jun 6, 2023

This pull request introduces new options, bucketMaxSpanSeconds and bucketRoundingSeconds to provide the flexibility of bucketing in time-series collections, enabling users to customize bucket boundaries and rounding behavior.

Users can directly set bucketMaxSpanSeconds and bucketRoundingSeconds, ensuring they are equal.
Existing granularity settings remain supported.

JAVA-4888

Introduce customizable bucketMaxSpanSeconds and bucketRoundingSeconds options for Time-Series collections, providing users with more control over bucketing behaviors. These options allow for setting the maximum time difference between timestamps within a bucket and adjusting the rounding precision. Enhancing flexibility in managing Time-Series data.

JAVA-4888
@vbabanin vbabanin self-assigned this Jun 6, 2023
@vbabanin vbabanin marked this pull request as ready for review June 6, 2023 21:38
@vbabanin vbabanin requested review from jyemin, rozza and stIncMale June 6, 2023 22:27
* @mongodb.driver.manual core/timeseries-collections/ Time-series collections
* @see #getBucketMaxSpan(TimeUnit)
*/
public TimeSeriesOptions bucketMaxSpan(@Nullable final Long bucketMaxSpan, final TimeUnit timeUnit) {
Copy link
Member Author

@vbabanin vbabanin Jun 6, 2023

Choose a reason for hiding this comment

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

As for now, TimeUnit is used in order to maintain consistency within the driver since this approach ensures a unified way of handling time intervals throughout the codebase.

There is a task JAVA-4191 for introducing Duration for the API, which will enhance the functionality further

Copy link
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

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

Looks good only a couple of nits - that can be applied to both settings

* </p>
*
* @param bucketMaxSpan time span between measurements. After conversion to seconds using {@link TimeUnit#convert(long, java.util.concurrent.TimeUnit)},
* the value must be &gt;= 1.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Also accepts null so add something to say a null value will unset any previously set value.

* Returns the maximum time span between measurements in a bucket.
*
* @param timeUnit the time unit.
* @return time span between measurements.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: add "or null if not set."

@vbabanin vbabanin requested a review from rozza June 8, 2023 05:35
Copy link
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

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

LGTM!

@jyemin jyemin removed their request for review June 9, 2023 13:42
vbabanin added 2 commits June 14, 2023 11:53
- Add tests.
- Lower server version because bucket options were backported to 6.3

JAVA-4888
JAVA-4888
@vbabanin vbabanin requested a review from stIncMale June 14, 2023 20:08
JAVA-4888
@vbabanin vbabanin requested a review from stIncMale June 15, 2023 01:14
@vbabanin vbabanin merged commit ce6c119 into mongodb:master Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants