为什么MongoDB/MongoHub将一些浮点值作为Number.POSITIVE_INFINITY导入?
问题描述:
我做了一个集合(从我的本地主机)与MongoDB客户端MongoHub导出,然后导入MongoHub到远程服务器。为什么MongoDB/MongoHub将一些浮点值作为Number.POSITIVE_INFINITY导入?
今天我发现在远程服务器中有142个值(68k)浮点值是Number.POSITIVE_INFINITY
。
它发生在不同的属性名称,例如; byGender.women
本地主机:
"byGender": {
"women": 10.232445707200000129,
"men": 43.622531699299997854
},
远程服务器:
"byGender": {
"women": Number.POSITIVE_INFINITY,
"men": 43.622531699299997854
},
我检查了导出文件和数据是正确的,因此问题应该是在进口。
我给作为被转换为Number.POSITIVE_INFINITY例如其他值:
- 44.202104087999998683
- 19.085516518799998664
- 20.620553158300001684
- 18.124746482399999081
- 1.8338334224999999211
你知道是否有原因?
服务器是Ubuntu的16.04,蒙戈v3.2.7
答
解决做的命令行出口和进口。这可能是一个mongoHub错误。
出口:
mongoexport --db databaseName --collection collectionName --out fileName.json
导入:
mongoimport -d databaseName -c collectionName --type json --file fileName.json