Title: CursorIterator design changes · Issue #154 · lmdbjava/lmdbjava · GitHub
Open Graph Title: CursorIterator design changes · Issue #154 · lmdbjava/lmdbjava
X Title: CursorIterator design changes · Issue #154 · lmdbjava/lmdbjava
Description: As discussed in #153, CursorIterator does not reflect the usual Java iterator idiom where an Iterable is able to produce multiple Iterator instances. This restriction exists because LMDB is used to provide the elements through an underly...
Open Graph Description: As discussed in #153, CursorIterator does not reflect the usual Java iterator idiom where an Iterable is able to produce multiple Iterator instances. This restriction exists because LMDB is used to...
X Description: As discussed in #153, CursorIterator does not reflect the usual Java iterator idiom where an Iterable is able to produce multiple Iterator instances. This restriction exists because LMDB is used to...
Opengraph URL: https://github.com/lmdbjava/lmdbjava/issues/154
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CursorIterator design changes","articleBody":"As discussed in #153, `CursorIterator` does not reflect the usual Java iterator idiom where an `Iterable` is able to produce multiple `Iterator` instances. This restriction exists because LMDB is used to provide the elements through an underlying transaction (provided at the time `Dbi.iterate(..)` is invoked) and cursor. Due to the use of these native resources, it is impractical to effectively produce multiple arbitrary `Iterator`s from the same `Iterable`, especially given each `Iterator` would need to be individually `AutoCloseable` to release its associated LMDB cursor.\r\n\r\nIt is difficult to envisage a practical use case for reusing an `Iterable` in the first place, especially given the shared `Txn` and `KeyRange` would result in the same the data for all returned `Iterator`s anyway. Furthermore users with advanced needs are referred to `Dbi.openCursor(..)`, as this permits moving the cursor in any direction and at any time while the `Txn` remains available.\r\n\r\nWhile #153 added a simple guard to prevent acquiring multiple `Iterator` instances, the overall design remains non-idiomatic. Fundamentally `Dbi.iterate(..)` should return a class that implements `Iterable` so that the returned object can be directly and idiomatically used in an enhanced `for` statement. This would mean:\r\n\r\n* Renaming `CursorIterator` to `CursorIterable`\r\n* Implementing the `Iterable` interface on `CursorIterable`\r\n* Removing the `Iterator` interface from `CursorIterable`\r\n* Relocating the `Iterator` methods into the inner class returned from `CursorIterable.iterator()`\r\n\r\nUnfortunately these changes represent a minor breaking change for existing users. Given this is a breaking change, it's a good opportunity to remove the deprecated `IteratorType` as well. The `IteratorType` was [deprecated](https://github.com/lmdbjava/lmdbjava/blob/895fcbd044247da3164d1ee6dd35a0c7bde3dff7/src/main/java/org/lmdbjava/CursorIterator.java#L211) in LmdbJava 0.6.0 ([released July 2017](https://github.com/lmdbjava/lmdbjava/wiki/Change-Log#060-16-jul-2017)) and represents the only deprecated code currently remaining in LmdbJava.","author":{"url":"https://github.com/bp-alex","@type":"Person","name":"bp-alex"},"datePublished":"2020-04-27T01:50:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/154/lmdbjava/issues/154"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4f325b3d-03bf-aae6-d971-48e6f4759d29 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C586:7A5F:16F8889:1ED8833:69706A67 |
| html-safe-nonce | 6ab4e12ac471ce3fb2a0917210441d7be6e134eb7d40d25248ffc830e15434cc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTg2OjdBNUY6MTZGODg4OToxRUQ4ODMzOjY5NzA2QTY3IiwidmlzaXRvcl9pZCI6IjU0Njc1ODQ3MzY0MTYyNjI3NTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fd648c613b236f7bfdfef5ea5044bb21ddf57562a0f9f17b1d8c3d42e1b22940 |
| hovercard-subject-tag | issue:607173645 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/lmdbjava/lmdbjava/154/issue_layout |
| twitter:image | https://opengraph.githubassets.com/11f0398d663801d26a053400b48fd5e941d2239d94603d13460b643a63fcb725/lmdbjava/lmdbjava/issues/154 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/11f0398d663801d26a053400b48fd5e941d2239d94603d13460b643a63fcb725/lmdbjava/lmdbjava/issues/154 |
| og:image:alt | As discussed in #153, CursorIterator does not reflect the usual Java iterator idiom where an Iterable is able to produce multiple Iterator instances. This restriction exists because LMDB is used to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bp-alex |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/lmdbjava/lmdbjava git https://github.com/lmdbjava/lmdbjava.git |
| octolytics-dimension-user_id | 19765602 |
| octolytics-dimension-user_login | lmdbjava |
| octolytics-dimension-repository_id | 60480511 |
| octolytics-dimension-repository_nwo | lmdbjava/lmdbjava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 60480511 |
| octolytics-dimension-repository_network_root_nwo | lmdbjava/lmdbjava |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width