当前位置: 动力学知识库 > 问答 > 编程问答 >

mongodb - debug map/reduce, How to get size exceeding document?

问题描述:

I am running a map/reduce job and it fails because the reduce step exceeds the 16 mb limit for bson documents. And I run out of ideas how to debug it.

exception: BSONObj size: 16808001 (0x41780001) is invalid.

Size must be between 0 and 16793600(16MB)

First element: 0: { 531.343: { 2: [ { strength: 121.0, acc: 23.0 } ] } }

My problem is that I don't got access to the document but only the first element of the input. Is there a way to get the complete thing?

My idea was to check the size of the output within the reduce javascript and print the data into the mongo log. But

  1. I found no way to determine the BSON size of something within a map/reduce function
  2. I tried to estimate the size BSON with JSON but it never triggered:

if(JSON.stringify(ret).length > 10000000) {

print('Document of size: ' + JSON.stringify(ret).length);

print(JSON.stringify(ret));

print();

}

return ret;

Any other ideas?

网友答案:

Object.bsonsize({ ...... }) will calculate the BSON size of the document.

Also 10000000/1024/1024 is only ~ 9mb so I'm not sure your test would have caught it.

分享给朋友:
您可能感兴趣的文章:
随机阅读: