简体   繁体   中英

BerkeleyDB: Receiving truncated keys to bt_compare function in python BTREE

I am using BerkeleyDB 6.0 with bsddb3 python drivers. I have a dataset with BTREE access method having keys as strings representing floating point numbers. I have set a compare function to be used in set_bt_compare() .

When I try to use db.set_range(key) function, the keys that the compare function receives are sometimes truncated. for instance,

--------------------------------------------------
'left :1378934633890000.0'
--------------------------------------------------
'right:13789346362'

Here, the right key should be '1378934636286548.8' .

Has anyone seen this problem? have any suggestions as to how to fix it?

Thank you.

Actually it was my fault. I hadn't set the bt_compare method when adding the data. I did that and now there's no truncated data. Just in case anyone else having the same problem, make sure you correctly set the comparison method each time you read/write data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM