René's URL Explorer Experiment


Title: The new `MDB_UNSIGNEDKEY` DbiFlag should probably be the default behaviour · Issue #249 · lmdbjava/lmdbjava · GitHub

Open Graph Title: The new `MDB_UNSIGNEDKEY` DbiFlag should probably be the default behaviour · Issue #249 · lmdbjava/lmdbjava

X Title: The new `MDB_UNSIGNEDKEY` DbiFlag should probably be the default behaviour · Issue #249 · lmdbjava/lmdbjava

Description: This issue relates to this PR #199 (which addressed this issue #198) and the subsequent PR #237 that added MDB_UNSIGNED_KEY. We have recently upgraded to 0.9.1 (thanks for this release and the fixes in it) and found that a number of our ...

Open Graph Description: This issue relates to this PR #199 (which addressed this issue #198) and the subsequent PR #237 that added MDB_UNSIGNED_KEY. We have recently upgraded to 0.9.1 (thanks for this release and the fixe...

X Description: This issue relates to this PR #199 (which addressed this issue #198) and the subsequent PR #237 that added MDB_UNSIGNED_KEY. We have recently upgraded to 0.9.1 (thanks for this release and the fixe...

Opengraph URL: https://github.com/lmdbjava/lmdbjava/issues/249

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The new `MDB_UNSIGNEDKEY` DbiFlag should probably be the default behaviour","articleBody":"This issue relates to this PR #199 (which addressed this issue #198) and the subsequent PR #237 that added MDB_UNSIGNED_KEY.\n\nWe have recently upgraded to 0.9.1 (thanks for this release and the fixes in it) and found that a number of our tests are failing due to cursor start/stop key comparisons.  Adding the `MDB_UNSIGNEDKEY` DbiFlag fixes them however it feels like the old `compareBuff` comparator ought to be the default rather than ByteBuffer.compareTo.\n\nWhile I appreciate it is preferable to use methods from the JDK rather than hand rolled comparators, this is only the case IF the JDK methods behave in the same way as the existing code, which they don't. As @benalexau pointed out in the PR, `ByteBuffer.compareTo` is signed while `compareBuff` is unsigned.  The latter matches the way LMDB orders its entries while the former does not.\n\nIt is hard to see a case where you would want to use a comparator for the cursor start/stop keys that does not match that used for the iteration order imposed by LMDB's default comparator.  Maybe if you are only dealing with positive signed numbers they would match, but in that case, you would be better using MDB_INTEGER_kEY for the better performance.  There is always the option to use no stop key and to instead use your own code to determine when to break out of the cursor iteration.\n\nThis problem is not just limited to numbers.  As an example, if your key was a UTF16 string and you had keys:\n\n`0x00 0x00`   // a null char\n`0xFF 0xFD`   // a � char\n\nThey would appear in the DB in that order, but the ByteBuffer.compareTo would treat `0xFF 0xFD` as being the lower of the two.\n\nIf `MDB_UNSIGNEDKEY` is not set then it can lead to strange behaviour when using cursors that is highly value dependant, and thus tricky to fix.  A crude performance test between the two ByteBuffer comparators suggests that the JDK is only marginally quicker.\n\nIt may be preferable to return `compareBuff` to being the default (when no callback comparator is used) but to use the JDK comparators by setting a flag, essentially the opposite of what is in 0.9.1.  I.e. the developer is making an explicit choice to get the slight performance gain of the JDK method with the understanding that it comes with risks.  If they know their data fits within the constraints then it is ok.\n\nOne other option is not to use a java based comparator for the cursor start/stop keys and instead call down to this method on LMDB so that you are sure the comparison is being done in the same way as the DB is storing its entries.  I suspect that it would be more costly do make this call but you would at least be sure the comparison matched LMDB's.\n\n```\nint mdb_cmp (\n    MDB_txn *         txn,\n    MDB_dbi           dbi,\n    const MDB_val *   a,\n    const MDB_val *   b \n)\n\nCompare two data items according to a particular database.\n\nThis returns a comparison as if the two data items were keys in the specified database.\n\nParameters\n[in]\ttxn\tA transaction handle returned by mdb_txn_begin()\n[in]\tdbi\tA database handle returned by mdb_dbi_open()\n[in]\ta\tThe first item to compare\n[in]\tb\tThe second item to compare\nReturns\n\u003c 0 if a \u003c b, 0 if a == b, \u003e 0 if a \u003e b\n```\n\nHappy to raise a PR address any changes that are agreed.","author":{"url":"https://github.com/at055612","@type":"Person","name":"at055612"},"datePublished":"2025-03-05T20:00:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":15},"url":"https://github.com/249/lmdbjava/issues/249"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:ba12fd3d-6eec-272a-e7d5-95e69dc2a5a9
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC678:98268:3976B1:4E0539:696F1C66
html-safe-nonce8b642e48c91a575ffd5d376e2f8ace4991d069c11714343cc180a975739b926d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjc4Ojk4MjY4OjM5NzZCMTo0RTA1Mzk6Njk2RjFDNjYiLCJ2aXNpdG9yX2lkIjoiNDIyNzMzNzkyMjM4NzMxOTkxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacff5380ea4a4546c4429148418392d8a52529afe2cae12ce0ff37b9c53f24598b
hovercard-subject-tagissue:2898342984
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/lmdbjava/lmdbjava/249/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a74f7600be8fdbc3904bf6af3ad20b4cfab3d9c11bef2c3000630e6f24bdc365/lmdbjava/lmdbjava/issues/249
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a74f7600be8fdbc3904bf6af3ad20b4cfab3d9c11bef2c3000630e6f24bdc365/lmdbjava/lmdbjava/issues/249
og:image:altThis issue relates to this PR #199 (which addressed this issue #198) and the subsequent PR #237 that added MDB_UNSIGNED_KEY. We have recently upgraded to 0.9.1 (thanks for this release and the fixe...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameat055612
hostnamegithub.com
expected-hostnamegithub.com
Noneb278ad162d35332b6de714dfb005de04386c4d92df6475522bef910f491a35ee
turbo-cache-controlno-preview
go-importgithub.com/lmdbjava/lmdbjava git https://github.com/lmdbjava/lmdbjava.git
octolytics-dimension-user_id19765602
octolytics-dimension-user_loginlmdbjava
octolytics-dimension-repository_id60480511
octolytics-dimension-repository_nwolmdbjava/lmdbjava
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id60480511
octolytics-dimension-repository_network_root_nwolmdbjava/lmdbjava
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release39aed5006635ab6f45e6b77d23e73b08a00272a3
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/lmdbjava/lmdbjava/issues/249#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Flmdbjava%2Flmdbjava%2Fissues%2F249
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Flmdbjava%2Flmdbjava%2Fissues%2F249
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=lmdbjava%2Flmdbjava
Reloadhttps://github.com/lmdbjava/lmdbjava/issues/249
Reloadhttps://github.com/lmdbjava/lmdbjava/issues/249
Reloadhttps://github.com/lmdbjava/lmdbjava/issues/249
lmdbjava https://github.com/lmdbjava
lmdbjavahttps://github.com/lmdbjava/lmdbjava
Notifications https://github.com/login?return_to=%2Flmdbjava%2Flmdbjava
Fork 124 https://github.com/login?return_to=%2Flmdbjava%2Flmdbjava
Star 866 https://github.com/login?return_to=%2Flmdbjava%2Flmdbjava
Code https://github.com/lmdbjava/lmdbjava
Issues 8 https://github.com/lmdbjava/lmdbjava/issues
Pull requests 1 https://github.com/lmdbjava/lmdbjava/pulls
Actions https://github.com/lmdbjava/lmdbjava/actions
Projects 0 https://github.com/lmdbjava/lmdbjava/projects
Wiki https://github.com/lmdbjava/lmdbjava/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/lmdbjava/lmdbjava/security
Please reload this pagehttps://github.com/lmdbjava/lmdbjava/issues/249
Insights https://github.com/lmdbjava/lmdbjava/pulse
Code https://github.com/lmdbjava/lmdbjava
Issues https://github.com/lmdbjava/lmdbjava/issues
Pull requests https://github.com/lmdbjava/lmdbjava/pulls
Actions https://github.com/lmdbjava/lmdbjava/actions
Projects https://github.com/lmdbjava/lmdbjava/projects
Wiki https://github.com/lmdbjava/lmdbjava/wiki
Security https://github.com/lmdbjava/lmdbjava/security
Insights https://github.com/lmdbjava/lmdbjava/pulse
New issuehttps://github.com/login?return_to=https://github.com/lmdbjava/lmdbjava/issues/249
New issuehttps://github.com/login?return_to=https://github.com/lmdbjava/lmdbjava/issues/249
#276https://github.com/lmdbjava/lmdbjava/pull/276
The new MDB_UNSIGNEDKEY DbiFlag should probably be the default behaviourhttps://github.com/lmdbjava/lmdbjava/issues/249#top
#276https://github.com/lmdbjava/lmdbjava/pull/276
https://github.com/at055612
https://github.com/at055612
at055612https://github.com/at055612
on Mar 5, 2025https://github.com/lmdbjava/lmdbjava/issues/249#issue-2898342984
#199https://github.com/lmdbjava/lmdbjava/pull/199
#198https://github.com/lmdbjava/lmdbjava/issues/198
#237https://github.com/lmdbjava/lmdbjava/pull/237
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.