Package org.opensearch.common
Class Rounding
java.lang.Object
org.opensearch.common.Rounding
- All Implemented Interfaces:
org.opensearch.core.common.io.stream.Writeable
@PublicApi(since="1.0.0")
public abstract class Rounding
extends Object
implements org.opensearch.core.common.io.stream.Writeable
A strategy for rounding milliseconds since epoch.
There are two implementations for rounding. The first one requires a date time unit and rounds to the supplied date time unit (i.e. quarter of year, day of month). The second one allows you to specify an interval to round to.
See this blog for some background reading. Its super interesting and the links are a comedy gold mine. If you like time zones. Or hate them.
- Opensearch.api:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder for roundingstatic enum
A Date Time Unitstatic interface
A strategy for rounding milliseconds since epoch.Nested classes/interfaces inherited from interface org.opensearch.core.common.io.stream.Writeable
org.opensearch.core.common.io.stream.Writeable.Reader<V>, org.opensearch.core.common.io.stream.Writeable.WriteableRegistry, org.opensearch.core.common.io.stream.Writeable.Writer<V>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Rounding.Builder
builder
(Rounding.DateTimeUnit unit) static Rounding.Builder
builder
(org.opensearch.common.unit.TimeValue interval) abstract boolean
static OptionalLong
getInterval
(Rounding rounding) Extracts the interval value from theRounding
instanceabstract int
hashCode()
abstract byte
id()
abstract void
innerWriteTo
(org.opensearch.core.common.io.stream.StreamOutput out) final long
nextRoundingValue
(long utcMillis) Deprecated.abstract long
offset()
Deprecated.We're in the process of abstracting offset *into* Rounding so keep any usage to migratory shimsabstract Rounding.Prepared
prepare
(long minUtcMillis, long maxUtcMillis) Prepare to round many times.abstract Rounding.Prepared
Prepare to round many dates over an unknown range.static Rounding
read
(org.opensearch.core.common.io.stream.StreamInput in) final long
round
(long utcMillis) Deprecated.Preferprepare(long, long)
and thenRounding.Prepared.round(long)
abstract Rounding
Strip theoffset
from these bounds.void
writeTo
(org.opensearch.core.common.io.stream.StreamOutput out)
-
Constructor Details
-
Rounding
public Rounding()
-
-
Method Details
-
innerWriteTo
public abstract void innerWriteTo(org.opensearch.core.common.io.stream.StreamOutput out) throws IOException - Throws:
IOException
-
writeTo
- Specified by:
writeTo
in interfaceorg.opensearch.core.common.io.stream.Writeable
- Throws:
IOException
-
id
public abstract byte id() -
prepare
Prepare to round many times. -
prepareForUnknown
Prepare to round many dates over an unknown range. Preferprepare(long, long)
if you can find the range because it'll be much more efficient. -
round
Deprecated.Preferprepare(long, long)
and thenRounding.Prepared.round(long)
Rounds the given value. -
nextRoundingValue
Deprecated.Preferprepare(long, long)
and thenRounding.Prepared.nextRoundingValue(long)
Given the rounded value (which was potentially generated byround(long)
, returns the next rounding value. For example, with interval based rounding, if the interval is 3,nextRoundValue(6) = 9
. -
offset
Deprecated.We're in the process of abstracting offset *into* Rounding so keep any usage to migratory shimsHow "offset" this rounding is from the traditional "start" of the period. -
withoutOffset
Strip theoffset
from these bounds. -
equals
-
hashCode
public abstract int hashCode() -
builder
-
builder
-
read
- Throws:
IOException
-
getInterval
Extracts the interval value from theRounding
instance
-
prepare(long, long)
and thenRounding.Prepared.nextRoundingValue(long)