public final class

TimeUUIDUtils

extends Object
java.lang.Object
   ↳ com.netflix.astyanax.util.TimeUUIDUtils

Class Overview

Utilitary class to generate TimeUUID (type 1)

Summary

Public Constructors
TimeUUIDUtils()
Public Methods
static byte[] asByteArray(UUID uuid)
As byte array.
static ByteBuffer asByteBuffer(UUID uuid)
Coverts a java.util.UUID into a ByteBuffer.
static long getMicrosTimeFromUUID(UUID uuid)
static UUID getMicrosTimeUUID(long time)
static long getTimeFromUUID(UUID uuid)
static long getTimeFromUUID(byte[] uuid)
Retrieves the time as long based on the byte[] representation of a UUID.
static UUID getTimeUUID(long time)
Gets a new time uuid based on time.
static UUID getTimeUUID(Clock clock)
Gets a new time uuid using ClockResolution#createClock() as a time generator.
static UUID getUniqueTimeUUIDinMicros()
static UUID getUniqueTimeUUIDinMillis()
Gets a new and unique time uuid in milliseconds.
static UUID toUUID(byte[] uuid)
Returns an instance of uuid.
static UUID uuid(byte[] uuid, int offset)
static UUID uuid(ByteBuffer bb)
Converts a ByteBuffer containing a UUID into a java.util.UUID
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public TimeUUIDUtils ()

Public Methods

public static byte[] asByteArray (UUID uuid)

As byte array. This method is often used in conjunction with @link #getTimeUUID()

Parameters
uuid the uuid
Returns
  • the byte[]

public static ByteBuffer asByteBuffer (UUID uuid)

Coverts a java.util.UUID into a ByteBuffer.

Parameters
uuid a java.util.UUID
Returns
  • a ByteBuffer representaion of the param UUID

public static long getMicrosTimeFromUUID (UUID uuid)

public static UUID getMicrosTimeUUID (long time)

public static long getTimeFromUUID (UUID uuid)

public static long getTimeFromUUID (byte[] uuid)

Retrieves the time as long based on the byte[] representation of a UUID.

Parameters
uuid byte[] uuid representation
Returns
  • a long representing the time

public static UUID getTimeUUID (long time)

Gets a new time uuid based on time. NOTE: this algorithm does not resolve duplicates. To avoid duplicates use getTimeUUID(ClockResolution clock) with an implementaion that provides unique timestamp resolution, like MicrosecondsSyncClockResolution It is useful to use in a TimeUUIDType sorted column family.

Returns
  • the time uuid

public static UUID getTimeUUID (Clock clock)

Gets a new time uuid using ClockResolution#createClock() as a time generator. It is useful to use in a TimeUUIDType sorted column family.

Parameters
clock a ClockResolution
Returns
  • the time uuid

public static UUID getUniqueTimeUUIDinMicros ()

public static UUID getUniqueTimeUUIDinMillis ()

Gets a new and unique time uuid in milliseconds. It is useful to use in a TimeUUIDType sorted column family.

Returns
  • the time uuid

public static UUID toUUID (byte[] uuid)

Returns an instance of uuid. Useful for when you read out of cassandra you are getting a byte[] that needs to be converted into a TimeUUID.

Parameters
uuid the uuid
Returns
  • the java.util.uuid

public static UUID uuid (byte[] uuid, int offset)

public static UUID uuid (ByteBuffer bb)

Converts a ByteBuffer containing a UUID into a java.util.UUID

Parameters
bb a ByteBuffer containing a UUID
Returns
  • a java.util.UUID