Package edu.byu.hbll.box.internal.util
Class CursorUtils
- java.lang.Object
-
- edu.byu.hbll.box.internal.util.CursorUtils
-
public class CursorUtils extends Object
Utility class for dealing with cursors (the nanoseconds since the epoch).- Author:
- Charles Draper
-
-
Constructor Summary
Constructors Constructor Description CursorUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
getCursor(Instant time)
Returns the cursor for the given time.static long
nextCursor()
Generates a timestamp based long that can be used as cursor in a database.
-
-
-
Method Detail
-
getCursor
public static long getCursor(Instant time)
Returns the cursor for the given time. Returns the number of nanoseconds since epoch until the given time.- Parameters:
time
- the given time- Returns:
- the cursor for the given time
-
nextCursor
public static long nextCursor()
Generates a timestamp based long that can be used as cursor in a database. It equals the number of nanoseconds since the epoch.With 63 bits available (64 bit long minus 1 bit for the sign), this strategy should work until approximately the year 2262. There is a slight chance that a distributed box application will create the same cursor. To overcome this, clients that read from this box should use a page size of at least the number of instances of the box application. There is; however, no chance of a single box instance creating identical cursors.
- Returns:
- the next cursor
-
-