使用 Berkeley DB、C++ 进行批量读取STL接口
我正在使用 Berkeley DB 4.8 的 C++ STL API,并且我能够对使用 begin() 创建的 db_map 或 db_multimap const 迭代器进行批量检索,但不能对从 find() (或用于多重映射的 lower_bound())创建的迭代器进行批量检索)。
我很欣赏使用 find() 进行单项随机访问会浪费使用批量检索,但我想从 find() 点向前按 btree 顺序访问许多记录,因此批量检索会对我有所帮助。底层 C++ api 似乎允许这样做,STl API 是否可能?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己找到了一个解决方案:
您需要重载 const_iterator lower_bound() 方法以包含 BulkRetrievalOption 参数,就像 begin() 一样。这将像 begin() 一样使用该参数在内部创建迭代器实例,但随后将迭代器移动到所提供的键值的下限。
同样适用于 db_map::find
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