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 Details

    • CursorUtils

      public CursorUtils()
  • Method Details

    • 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. 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