-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
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
JAVA-4888
JAVA-4888
* @mongodb.driver.manual core/timeseries-collections/ Time-series collections | ||
* @see #getBucketMaxSpan(TimeUnit) | ||
*/ | ||
public TimeSeriesOptions bucketMaxSpan(@Nullable final Long bucketMaxSpan, final TimeUnit timeUnit) { |
There was a problem hiding this comment.
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
There was a problem hiding this 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 >= 1. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
driver-core/src/main/com/mongodb/client/model/TimeSeriesOptions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/TimeSeriesOptions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/TimeSeriesOptions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/TimeSeriesOptions.java
Outdated
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudHelper.java
Show resolved
Hide resolved
- Add tests. - Lower server version because bucket options were backported to 6.3 JAVA-4888
JAVA-4888
driver-core/src/test/functional/com/mongodb/client/model/TimeSeriesOptionsTest.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/TimeSeriesOptions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/TimeSeriesOptions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/TimeSeriesOptions.java
Outdated
Show resolved
Hide resolved
JAVA-4888
This pull request introduces new options,
bucketMaxSpanSeconds
andbucketRoundingSeconds
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