开发者

Bulk reads using Berkeley DB, C++ STL interface

I'm using the C++ STL API to Berkeley DB 4.8, and I'm able to use bulk retrieval for a db_map or db_multimap const iterator created 开发者_C百科using begin(), but not one created from find() (or lower_bound() for multimaps).

I appreciate for single item random access uses of find() would be a waste to use bulk retrieval, but I want to access many records in btree order from my find() point forwards, so bulk retrieval would help me. The underlying C++ api appears to allow it, is it possible from the STl API?


I found a solution to this myself:

You need to overload the const_iterator lower_bound() method to include a BulkRetrievalOption argument just like begin(). This will internally create the interator instance using that argument just as begin() does but then move the iterator to the lower bound of the key value supplied.

Same would apply to a db_map::find

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜