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 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.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRounding.Builderstatic classRounding.DateTimeUnitstatic interfaceRounding.PreparedA strategy for rounding milliseconds since epoch.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.Builderbuilder(Rounding.DateTimeUnit unit)static Rounding.Builderbuilder(org.elasticsearch.common.unit.TimeValue interval)abstract booleanequals(java.lang.Object obj)abstract inthashCode()abstract byteid()abstract voidinnerWriteTo(StreamOutput out)longnextRoundingValue(long utcMillis)Deprecated.abstract longoffset()Deprecated.We're in the process of abstracting offset *into* Rounding so keep any usage to migratory shimsabstract Rounding.Preparedprepare(long minUtcMillis, long maxUtcMillis)Prepare to round many times.abstract Rounding.PreparedprepareForUnknown()Prepare to round many dates over an unknown range.static Roundingread(StreamInput in)longround(long utcMillis)Deprecated.Preferprepare(long, long)and thenRounding.Prepared.round(long)abstract RoundingwithoutOffset()Strip theoffsetfrom these bounds.voidwriteTo(StreamOutput out)Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Rounding
public Rounding()
-
-
Method Details
-
innerWriteTo
- Throws:
java.io.IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput. -
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 public final long round(long utcMillis)Deprecated.Preferprepare(long, long)and thenRounding.Prepared.round(long)Rounds the given value. -
nextRoundingValue
@Deprecated public final long nextRoundingValue(long utcMillis)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 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 theoffsetfrom these bounds. -
equals
public abstract boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public abstract int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
builder
-
builder
-
read
- Throws:
java.io.IOException
-
prepare(long, long)and thenRounding.Prepared.nextRoundingValue(long)