Message from discussion
BSONObjBuilder decouple
Received: by 10.224.111.140 with SMTP id s12mr8737293qap.5.1352827861366;
Tue, 13 Nov 2012 09:31:01 -0800 (PST)
X-BeenThere: mongodb-user@googlegroups.com
Received: by 10.224.196.9 with SMTP id ee9ls13651834qab.2.gmail; Tue, 13 Nov
2012 09:30:33 -0800 (PST)
Received: by 10.224.220.136 with SMTP id hy8mr384293qab.3.1352827833382;
Tue, 13 Nov 2012 09:30:33 -0800 (PST)
Received: by 10.224.173.148 with SMTP id p20msqaz;
Tue, 13 Nov 2012 09:28:29 -0800 (PST)
Received: by 10.52.97.101 with SMTP id dz5mr4473566vdb.2.1352827709084;
Tue, 13 Nov 2012 09:28:29 -0800 (PST)
Date: Tue, 13 Nov 2012 09:28:28 -0800 (PST)
From: khanalesb <khanal...@gmail.com>
To: mongodb-user@googlegroups.com
Message-Id: <31d1b5e7-214b-4207-8596-a9de2690143e@googlegroups.com>
Subject: BSONObjBuilder decouple
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_856_19890474.1352827708204"
------=_Part_856_19890474.1352827708204
Content-Type: multipart/alternative;
boundary="----=_Part_857_29948503.1352827708205"
------=_Part_857_29948503.1352827708205
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
I am trying to use BSONObjBuilder as a serializer and decouple to avoid
memcopy.
mongo::BSONObjBuilder bldr;
....................
....................
....................
#ifdef X
//THIS WORKS
mongo::BSONObj obj = bldr.obj();
zmq::message_t replyBody( obj.objsize() );
std::memcpy( replyBody.data(), obj.objdata(), obj.objsize() );
#else
//SEG FAILT
int len;
char* buf = bldr.decouple(len);
zmq::message_t replyBody( buf, len, zmqFree );
#endif
Do I have to call anything else before decouple? Can I use it at all?
Thanks.
------=_Part_857_29948503.1352827708205
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
I am trying to use BSONObjBuilder as a serializer and decouple to avoid memcopy. <br><br> mongo::BSONObjBuilder bldr;<br>....................<br>....................<br>
....................<br>
<br>#ifdef X <br>//THIS WORKS<br> mongo::BSONObj obj = bldr.obj();<br> zmq::message_t replyBody( obj.objsize() );<br> std::memcpy( replyBody.data(), obj.objdata(), obj.objsize() );<br>#else<br>//SEG FAILT<br> int len;<br> char* buf = bldr.decouple(len);<br> zmq::message_t replyBody( buf, len, zmqFree );<br>#endif<br><br><br>Do I have to call anything else before decouple? Can I use it at all?<br>Thanks.<br>
------=_Part_857_29948503.1352827708205--
------=_Part_856_19890474.1352827708204--