开发者

What's MongoDB hash's size?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜