Nanoflakes

object Nanoflakes

Utility methods and constants related to Nanoflakes.

Functions

generatorValue
Link copied to clipboard
common
fun generatorValue(id: Long): Long
Gets the generator ID of a nanoflake.
localGenerator
Link copied to clipboard
common
fun localGenerator(epoch: Long, generatorId: Long): NanoflakeGenerator
Creates a local generator.
sequenceValue
Link copied to clipboard
common
fun sequenceValue(id: Long): Long
Gets the sequence ID of a nanoflake.
timestampValue
Link copied to clipboard
common
fun timestampValue(id: Long): Long
Gets the timestamp of a nanoflake.

Properties

GENERATOR_ID_BITS
Link copied to clipboard
common
const val GENERATOR_ID_BITS: Int = 10
How much of an nanoflake is occupied by the generator ID, in bits.
GENERATOR_ID_SHIFT
Link copied to clipboard
common
const val GENERATOR_ID_SHIFT: Int
The value used for generator id-based shifts.
MAX_GENERATOR_ID
Link copied to clipboard
common
const val MAX_GENERATOR_ID: Long = 1023
The maximum ID possible for a generator.
MAX_SEQUENCE
Link copied to clipboard
common
const val MAX_SEQUENCE: Long = 4095
The max sequence value of a snowflake.
SEQUENCE_BITS
Link copied to clipboard
common
const val SEQUENCE_BITS: Int = 12
How much of an nanoflake is occupied by sequence number, in bits.
TIMESTAMP_BITS
Link copied to clipboard
common
const val TIMESTAMP_BITS: Int = 14
How much of the nanoflake is occupied by the timestamp of the ID, in bits.
TIMESTAMP_SHIFT
Link copied to clipboard
common
const val TIMESTAMP_SHIFT: Int
The value used for timestamp-based shifts.