News for hackers. Stuff that matters.
Re:Sharding Pinterest: How we scaled our MySQL fleet by uptown on Wednesday August 19, 2015 @02:07PM (#10087326)
Can somebody help me understand this conversion?

Shard ID = (241294492511762325 >> 46) & 0xFFFF = 3429

Type ID = (241294492511762325 >> 36) & 0x3FF = 1

Local ID = (241294492511762325 >> 0) & 0xFFFFFFFFF = 7075733

Re:Sharding Pinterest: How we scaled our MySQL fleet by blyxa on Wednesday August 19, 2015 @02:39PM (#10087539)
bitwise operations.

241294492511762325 >> 46 means shift the binary form of number which is

  0000001101011001010000000001000000000000011010111111011110010101
to the right 46 spaces while replacing with 0s

  0000000000000000000000000000000000000000000000000000110101100101
0xFFFF is hex version of 1111111111111111 (note two missing bits he reserved for gold :D )

& 0xFFFF is doing a AND operation of the bits.

  0000110101100101
  1111111111111111
  ----------------
  0000110101100101
so 0000110101100101 in decimal is 3429
Re:Sharding Pinterest: How we scaled our MySQL fleet by econner on Wednesday August 19, 2015 @02:21PM (#10087407)
These are bit shift operations with a bitmask. Basically the ids are 64-bit and sections are reserved to identify the shard, type, and local id.