Package org.elasticsearch.common
Class Rounding
java.lang.Object
org.elasticsearch.common.Rounding
- All Implemented Interfaces:
Writeable
public abstract class Rounding extends java.lang.Object implements Writeable
A strategy for rounding date/time based values.
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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Rounding.Builder
static class
Rounding.DateTimeUnit
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Constructor Summary
Constructors Constructor Description Rounding()
-
Method Summary
Modifier and Type Method Description static Rounding.Builder
builder(Rounding.DateTimeUnit unit)
static Rounding.Builder
builder(TimeValue interval)
abstract boolean
equals(java.lang.Object obj)
abstract int
hashCode()
abstract byte
id()
abstract void
innerWriteTo(StreamOutput out)
abstract long
nextRoundingValue(long value)
Given the rounded value (which was potentially generated byround(long)
, returns the next rounding value.abstract long
offset()
Deprecated.We're in the process of abstracting offset *into* Rounding so keep any usage to migratory shimsstatic Rounding
read(StreamInput in)
abstract long
round(long value)
Rounds the given value.abstract Rounding
withoutOffset()
Strip theoffset
from these bounds.void
writeTo(StreamOutput out)
Write this into the StreamOutput.
-
Constructor Details
-
Rounding
public Rounding()
-
-
Method Details
-
innerWriteTo
- Throws:
java.io.IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput. -
id
public abstract byte id() -
round
public abstract long round(long value)Rounds the given value. -
nextRoundingValue
public abstract long nextRoundingValue(long value)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
.- Parameters:
value
- The current rounding value- Returns:
- The next rounding value
-
offset
@Deprecated public abstract long 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
public abstract boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public abstract int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
builder
-
builder
-
read
- Throws:
java.io.IOException
-