使用 Berkeley DB、C++ 进行批量读取STL接口

发布于 2024-09-10 01:47:52 字数 271 浏览 4 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绝影如岚 2024-09-17 01:47:52

我自己找到了一个解决方案:

您需要重载 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文