开发者

What's MongoDB hash's size?

开发者 https://www.devze.com 2022-12-18 07:02 出处:网络
I need to know what is 开发者_JAVA技巧size of the hash of MongoDB. Can\'t find it on wikipedia or official site.MongoDB uses 12-byte binary value (an ObjectId) -- it can be converted to 24-byte hex st

I need to know what is 开发者_JAVA技巧size of the hash of MongoDB. Can't find it on wikipedia or official site.


MongoDB uses 12-byte binary value (an ObjectId) -- it can be converted to 24-byte hex string.


An ObjectId, the default value for the _id field, is a 12-byte value; it is not a hash nor a string -- it is stored as binary value. Many drivers will show it as a hex string, so it can be easily printed.

It is comprised of a timestamp (in secs), a host id, process id and counter; this means that it is increasing over time of creation, and encodes the time of creation (insertion).

http://www.mongodb.org/display/DOCS/Object+IDs

Most drivers have helper methods to convert to and from the hex string representation, as well as creating one based on just the parts you are interested in -- i.e. a timestamp you might use for a range query. You can also easily extract the timestamp portion.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号