Class TimeSeriesOptions
- Since:
- 4.3
- See Also:
- MongoDB documentation
- Time-series collections
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbucketMaxSpan
(Long bucketMaxSpan, TimeUnit timeUnit) Sets the maximum time span between measurements in a bucket.bucketRounding
(Long bucketRounding, TimeUnit timeUnit) Specifies the time interval that determines the starting timestamp for a new bucket.getBucketMaxSpan
(TimeUnit timeUnit) Returns the maximum time span between measurements in a bucket.getBucketRounding
(TimeUnit timeUnit) Returns the time interval that determines the starting timestamp for a new bucket.Gets the granularity of the time-series data.Gets the name of the meta field.Gets the name of the field holding the time value.granularity
(TimeSeriesGranularity granularity) Sets the granularity of the time-series data.Sets the name of the meta field.toString()
-
Constructor Details
-
TimeSeriesOptions
Construct a new instance.- Parameters:
timeField
- the name of the top-level field to be used for time. Inserted documents must have this field, and the field must be of the BSON datetime type.
-
-
Method Details
-
getTimeField
Gets the name of the field holding the time value.- Returns:
- the name of the field holding the time value.
-
getMetaField
Gets the name of the meta field.- Returns:
- the name of the meta field
- See Also:
-
metaField
Sets the name of the meta field.The name of the field which contains metadata in each time series document. The metadata in the specified field should be data that is used to label a unique series of documents. The metadata should rarely, if ever, change. This field is used to group related data and may be of any BSON type, except for array. This name may not be the same as the
timeField
or "_id".- Parameters:
metaField
- the name of the meta field- Returns:
- this
- See Also:
-
getGranularity
Gets the granularity of the time-series data.- Returns:
- the time-series granularity
- See Also:
-
granularity
Sets the granularity of the time-series data.The default value is
TimeSeriesGranularity.SECONDS
if neitherbucketMaxSpan(Long, TimeUnit)
norbucketRounding(Long, TimeUnit)
is set. If any of these bucketing options are set, the granularity parameter cannot be set.- Parameters:
granularity
- the time-series granularity- Returns:
- this
- See Also:
-
getBucketMaxSpan
Returns the maximum time span between measurements in a bucket.- Parameters:
timeUnit
- the time unit.- Returns:
- time span between measurements, or
null
if not set. - Since:
- 4.10
- See Also:
- Since server release
- 6.3
-
bucketMaxSpan
Sets the maximum time span between measurements in a bucket.The value of
bucketMaxSpan
must be the same asbucketRounding(Long, TimeUnit)
, which also means that the options must either be both set or both unset. If you set thebucketMaxSpan
parameter, you can't set the granularity parameter.- Parameters:
bucketMaxSpan
- time span between measurements. After conversion to seconds usingTimeUnit.convert(long, java.util.concurrent.TimeUnit)
, the value must be >= 1.null
can be provided to unset any previously set value.timeUnit
- the time unit.- Returns:
- this
- Since:
- 4.10
- See Also:
- Since server release
- 6.3
-
getBucketRounding
Returns the time interval that determines the starting timestamp for a new bucket.- Parameters:
timeUnit
- the time unit.- Returns:
- the time interval, or
null
if not set. - Since:
- 4.10
- See Also:
- Since server release
- 6.3
-
bucketRounding
Specifies the time interval that determines the starting timestamp for a new bucket.The value of
bucketRounding
must be the same asbucketMaxSpan(Long, TimeUnit)
, which also means that the options must either be both set or both unset. If you set thebucketRounding
parameter, you can't set the granularity parameter.- Parameters:
bucketRounding
- time interval. After conversion to seconds usingTimeUnit.convert(long, java.util.concurrent.TimeUnit)
, the value must be >= 1.null
can be provided to unset any previously set value.timeUnit
- the time unit.- Returns:
- this
- Since:
- 4.10
- See Also:
- Since server release
- 6.3
-
toString
-