influxdb/pkg/snowflake
Stuart Carnie d135aecf02 Generate trace logs for a number of significant influx operations
* tsdb Store.Open traces all events related to opening files
    * op.name : tsdb.open
* retention policy shard deletions
    * op.name : retention.delete_check
* all TSM compaction strategies
    * op.name : tsm1.compact_group
* series file compactions
    * op.name : series_partition.compaction
* continuous query execution (if logging enabled)
    * op.name : continuous_querier.execute
* TSI log file compaction
    * op_name: index.tsi.compact_log_file
* TSI level compaction
    * op.name: index.tsi.compact_to_level
2018-02-21 15:08:49 -07:00
..
README.md Generate trace logs for a number of significant influx operations 2018-02-21 15:08:49 -07:00
gen.go Generate trace logs for a number of significant influx operations 2018-02-21 15:08:49 -07:00
gen_test.go Generate trace logs for a number of significant influx operations 2018-02-21 15:08:49 -07:00

README.md

Snowflake ID generator

This is a Go implementation of Twitter Snowflake.

The most useful aspect of these IDs is they are roughly sortable and when generated at roughly the same time, should have values in close proximity to each other.

IDs

Each id will be a 64-bit number represented, structured as follows:

6  6         5         4         3         2         1
3210987654321098765432109876543210987654321098765432109876543210

ttttttttttttttttttttttttttttttttttttttttttmmmmmmmmmmssssssssssss

where

  • s (sequence) is a 12-bit integer that increments if called multiple times for the same millisecond
  • m (machine id) is a 10-bit integer representing the server id
  • t (time) is a 42-bit integer representing the current timestamp in milliseconds the number of milliseconds to have elapsed since 1491696000000 or 2017-04-09T00:00:00Z

String Encoding

The 64-bit unsigned integer is base-63 encoded using the following URL-safe characters, which are ordered according to their ASCII value.

0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~

A binary sort of a list of encoded values will be correctly ordered according to the numerical representation.