File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -489,7 +489,7 @@ func NewDatumRowConverter(
489489 return c , nil
490490}
491491
492- const rowIDBits = 64 - builtinconstants .NodeIDBits
492+ const rowIDBits = 64 - builtinconstants .UniqueIntNodeIDBits
493493
494494// Row inserts kv operations into the current kv batch, and triggers a SendBatch
495495// if necessary.
Original file line number Diff line number Diff line change @@ -76,6 +76,28 @@ const (
7676 CreateSchemaTelemetryJobBuiltinName = "crdb_internal.create_sql_schema_telemetry_job"
7777)
7878
79- // NodeIDBits is the number of bits stored in the lower portion of
80- // GenerateUniqueInt.
81- const NodeIDBits = 15
79+ // A unique int generated by GenerateUniqueInt is a 64-bit integer with
80+ // the following format:
81+ //
82+ // [1 leading zero bit][48 bits for timestamp][15 bits for nodeID]
83+ const (
84+ // UniqueIntLeadingZeroBits is the number of leading zero bits in a unique
85+ // int generated by GenerateUniqueInt.
86+ UniqueIntLeadingZeroBits = 1
87+
88+ // UniqueIntTimestampBits is the number of bits in the timestamp segment
89+ // in a unique int generated by GenerateUniqueInt.
90+ UniqueIntTimestampBits = 48
91+
92+ // UniqueIntNodeIDBits is the number of bits in the node ID segment
93+ // in a unique int generated by GenerateUniqueInt.
94+ UniqueIntNodeIDBits = 15
95+
96+ // UniqueIntNodeIDMask is a bitmask for the node ID in a unique int
97+ // generated by GenerateUniqueInt.
98+ UniqueIntNodeIDMask = 1 << UniqueIntNodeIDBits - 1
99+
100+ // UniqueIntTimestampMask is a bitmask for the timestamp in a unique int
101+ // generated by GenerateUniqueInt.
102+ UniqueIntTimestampMask = (1 << UniqueIntTimestampBits - 1 ) << UniqueIntNodeIDBits
103+ )
Original file line number Diff line number Diff line change @@ -9859,7 +9859,7 @@ func GenerateUniqueInt(instanceID ProcessUniqueID) tree.DInt {
98599859func GenerateUniqueID (instanceID int32 , timestamp uint64 ) tree.DInt {
98609860 // We xor in the instanceID so that instanceIDs larger than 32K will flip bits
98619861 // in the timestamp portion of the final value instead of always setting them.
9862- id := (timestamp << builtinconstants .NodeIDBits ) ^ uint64 (instanceID )
9862+ id := (timestamp << builtinconstants .UniqueIntNodeIDBits ) ^ uint64 (instanceID )
98639863 return tree .DInt (id )
98649864}
98659865
You can’t perform that action at this time.
0 commit comments