Package edu.byu.hbll.box.internal.util
Class CursorUtils
java.lang.Object
edu.byu.hbll.box.internal.util.CursorUtils
Utility class for dealing with cursors (the nanoseconds since the epoch).
- Author:
- Charles Draper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic long
Returns the cursor for the given time.static long
Generates a timestamp based long that can be used as cursor in a database.
-
Constructor Details
-
CursorUtils
public CursorUtils()
-
-
Method Details
-
getCursor
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. Calls to nextCursor will always return a larger cursor than previous calls.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
-