Mongodb object id is a byte array which lot of information is packed into the byte array as follows:
http://www.mongodb.org/display/DOCS/Object+IDs#ObjectIDs-TheBSONObjectIdDatatype
ie: given an id 47cc67093475061e3d95369d it contains datetime, machine, id, and inc information. how do they store all these information into the id?
how are they doing this? how does byte packing is happening?
is there an example to represent this?
The time is seconds since Jan-1-1970, which in their example is 1,204,578,057.
For the binary representation, 1204578057 (base 10) is 47cc6709 (base 16). There’s nothing to do. That’s just how it looks to the computer.
To convert that value to a string (for the ObjectId method), just call ToString with “X”:
The structure itself is fully defined here — BSONObjectIDSpecification.
You may also want to research struct layouts here: http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.structlayoutattribute.aspx