C++ 使用C++;
我目前正在从事一个项目,该项目必须使用mongocxx驱动程序将jpg编码的图像解析或转储到mongodb中。将图像编码为std::vector后,当前将该向量存储到mongodb的方法是使用bsoncxx::array::append。e、 gC++ 使用C++;,c++,mongodb,mongo-cxx-driver,C++,Mongodb,Mongo Cxx Driver,我目前正在从事一个项目,该项目必须使用mongocxx驱动程序将jpg编码的图像解析或转储到mongodb中。将图像编码为std::vector后,当前将该向量存储到mongodb的方法是使用bsoncxx::array::append。e、 g bsoncxx::builder::basic::array child; for (const auto &value : encoded_img) child.append(value); 这种方法工作正常,但效率不高:每次我想在
bsoncxx::builder::basic::array child;
for (const auto &value : encoded_img)
child.append(value);
这种方法工作正常,但效率不高:每次我想在mongodb中插入一个编码图像时,我必须使用bsoncxx::array::append,我认为它没有根据名称进行预分配。例如,比如说std::vector,它有一个std::vector::reserve()函数,能够预先分配内存,因此向后推或放置到向量几乎不会花费时间。这个问题有什么解决方案或变通办法吗?谢谢