Package io.fluxcapacitor.common
Class IndexUtils
java.lang.Object
io.fluxcapacitor.common.IndexUtils
public class IndexUtils extends Object
Use 48 bits of the current time in milliseconds since epoch as the base of the index. The remaining 16 bits (65k) are
used to increment the index if messages are written in the same ms as the last batch.
The index is only able to store 2^47 - 1 ms of time since epoch, i.e. about 4,500 years.
-
Field Summary
Fields Modifier and Type Field Description static ThreadLocal<Clock>clock -
Constructor Summary
Constructors Constructor Description IndexUtils() -
Method Summary
Modifier and Type Method Description static InstantcurrentTime()static longcurrentTimeMillis()static longindexForCurrentTime()static longindexFromMillis(long millisSinceEpoch)static longindexFromTimestamp(Instant timestamp)static longmillisFromIndex(long index)static intoffsetFromIndex(long index)static InstanttimestampFromIndex(long index)
-
Field Details
-
clock
-
-
Constructor Details
-
IndexUtils
public IndexUtils()
-
-
Method Details
-
currentTime
-
currentTimeMillis
public static long currentTimeMillis() -
millisFromIndex
public static long millisFromIndex(long index) -
timestampFromIndex
-
indexFromTimestamp
-
indexFromMillis
public static long indexFromMillis(long millisSinceEpoch) -
indexForCurrentTime
public static long indexForCurrentTime() -
offsetFromIndex
public static int offsetFromIndex(long index)
-