如何在MongoDB文档中存储无符号的long long(uint64_t)值? [英] How to store unsigned long long (uint64_t) values in a MongoDB document?

查看:667
本文介绍了如何在MongoDB文档中存储无符号的long long(uint64_t)值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在MongoDB文档中存储 unsigned long long(uint64_t)类型的数字,我该怎么做?

I want to store numbers of type unsigned long long (uint64_t) in a MongoDB document, how do I do it?

我需要长时间使用无符号,因为我正在使用使用无符号64位整数的Twitter API https://dev.twitter.com/docs/twitter-ids-json-and-snowflake

I need to use unsigned long long because I'm using Twitter API which uses unsigned 64 bit integers https://dev.twitter.com/docs/twitter-ids-json-and-snowflake

无符号64位整数类型的范围需要重新表示8个字节,数据范围为0到18,446,744,073,709,551,615.

The range of the the unsigned 64 bit integral type needs to be represended by 8 bytes and with a data range of 0 to 18,446,744,073,709,551,615.

我正在使用 C ++ MongoDB驱动程序和附加成员 BSONArrayBuilder 类的函数没有对unsigned long long的重载,仅很久很久了.

I'm using the C++ MongoDB driver and the append member function of the BSONArrayBuilder class doesn't have an overload for unsigned long long, only for long long.

这是我尝试调用id为uint64_t类型的arrayBuilder.append(id)时出现的G ++ 4.7.2错误:

Here's the error G++ 4.7.2 spits out when I try to call arrayBuilder.append(id), with an id of type uint64_t:

MongoDB/mongo/db/../bson/bson-inl.h:342:9: error: call of overloaded ‘append(const char*&, long long unsigned int&)’ is ambiguous
MongoDB/mongo/db/../bson/bsonobjbuilder.h:167:25: note: mongo::BSONObjBuilder& mongo::BSONObjBuilder::append(const mongo::StringData&, bool)
MongoDB/mongo/db/../bson/bsonobjbuilder.h:175:25: note: virtual mongo::BSONObjBuilder& mongo::BSONObjBuilder::append(const mongo::StringData&, int)
MongoDB/mongo/db/../bson/bsonobjbuilder.h:183:25: note: mongo::BSONObjBuilder& mongo::BSONObjBuilder::append(const mongo::StringData&, unsigned int)
MongoDB/mongo/db/../bson/bsonobjbuilder.h:188:25: note: virtual mongo::BSONObjBuilder& mongo::BSONObjBuilder::append(const mongo::StringData&, long long int)
MongoDB/mongo/db/../bson/bsonobjbuilder.h:244:25: note: virtual mongo::BSONObjBuilder& mongo::BSONObjBuilder::append(const mongo::StringData&, double)
MongoDB/mongo/db/../bson/bsonobjbuilder.h:324:25: note: mongo::BSONObjBuilder& mongo::BSONObjBuilder::append(const mongo::StringData&, mongo::Date_t)

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆