回复:[odb-users] how to blob an array of float in mysql with odb 2.4.0?

不明真相 icewill9999 at vip.qq.com
Wed Jun 23 00:22:22 EDT 2021


FYI, I tried another solution you provided in the post [odb-users] Creating BLOBs out of vector/array of doubles? (codesynthesis.com), and the problems remains exactly the same.


Regards,
Wang


------------------ 原始邮件 ------------------
发件人:                                                                                                                        "不明真相"                                                                                    <icewill9999 at vip.qq.com&gt;;
发送时间:&nbsp;2021年6月22日(星期二) 下午3:26
收件人:&nbsp;"odb-users"<odb-users at codesynthesis.com&gt;;

主题:&nbsp;[odb-users] how to blob an array of float in mysql with odb 2.4.0?



Hi, Boris,
&amp;nbsp;I have an array of float values and I need to store them into mysql BLOB column, I defined the mapping as below:
typedef std::vector<unsigned char&amp;gt; buffer; #pragma db value(buffer) type("BLOB")
#pragma db section(extras_)&nbsp;&nbsp;&nbsp; buffer log_data_; // use the section to load the BLOB data
I convert the array of float values into a vector of unsigned char and then store them into the BLOB column. When I read the stored BLOB and convert them back I found only the 64 float values from beginning are correct, which I think is the default size of details::buffer. 
I dug into the odb generated file -odb.cxx, and found the size of buffer was never grown to meet the large size// log_data_&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp; if (t[11UL])&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i.log_data_value.capacity (i.log_data_size);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; grew = true;&nbsp;&nbsp;&nbsp; }so I add the code&nbsp;&nbsp;&nbsp; if(i.log_data_size &amp;gt;256) t[11UL] =1; it's worked, but all the converted values are wrong.
Is it a bug of ODB 2.4.0 or I did something wrong? please guide me with this, thanks.
Best Regards,Wang


More information about the odb-users mailing list