Hi John, This revision is perfect to me. Thank you, John.
2014-05-16 6:46 GMT+08:00 K. John Wu <[email protected]>: > Hi, Zhongbo, > > Thanks for the report of the bug. Looks like I have relied a little > too much on copy-and-paste in this case. I would like to continue to > use memcpy in cases where the internal data type matches the output > data type, and have adopted your suggestion of using std::copy for the > remaining cases. > > The update source code is in SVN as revision 718. Please give it a > try and feel free to let me know if you spot any problems. > > Thanks again. > > John > > > > > On 5/15/14, 3:24 AM, 田忠博(Zhongbo Tian) wrote: > > Hi John and everyone, > > > > My Python extension use ibis::table::getColumnAsXXX API to retrive > > column from a fastbit table as a NumPy array. But the array is filled > > by random numbers at the end while the data is correct at the > > beginning. After examining the code, I found a possible bug in > > mensa.cpp. for example, in this snippet: > > > > array_t<signed char> tmp; > > uint64_t ival = 0; > > uint64_t irow = 0; > > for (ibis::partList::const_iterator it = parts.begin(); > > it != parts.end() && irow < end; ++ it) { > > const ibis::part& dp = **it; > > if (irow + dp.nRows() > begin) { > > const ibis::column* col = dp.getColumn(cn); > > if (col == 0) > > return -3; > > if (col->getValuesArray(&tmp) < 0) > > return -4; > > > > const size_t i0 = (begin > irow ? begin - irow : 0); > > const size_t i1 = (end>=irow+dp.nRows() ? dp.nRows() : > > end-irow) - i0; > > memcpy(vals+ival, tmp.begin()+i0, i1); > > ival += i1; > > } > > irow += dp.nRows(); > > } > > > > The use of memcpy is the root of the issue, memcpy is valid only when > > dest and source have the same width. I guess we should use std::copy > > here. And std::copy can avoid us all the casting troubles. > > Finally, I just do a tiny refactor to remove some duplicate code, and > > the patch is attached as following. > > > > Please review my patch, and merge it if it is the right. > > > > Thank you. > > > > > > _______________________________________________ > > FastBit-users mailing list > > [email protected] > > https://hpcrdm.lbl.gov/cgi-bin/mailman/listinfo/fastbit-users > > > _______________________________________________ > FastBit-users mailing list > [email protected] > https://hpcrdm.lbl.gov/cgi-bin/mailman/listinfo/fastbit-users >
_______________________________________________ FastBit-users mailing list [email protected] https://hpcrdm.lbl.gov/cgi-bin/mailman/listinfo/fastbit-users
