Implement a 0(1) mapping from Oid -> meosType#753
Merged
mschoema merged 1 commit intoMobilityDB:masterfrom Feb 1, 2026
Merged
Conversation
mschoema
approved these changes
Feb 1, 2026
Member
|
I'm merging this, but any benchmarks that show performance improvements due to this change? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR enables a 0(1) bidirectional mapping
meosType→ PostgreSQLOidandOid→meosType.There is already a 0(1) mapping from
meosType->Oidprovided by the functionwhich is implemented as an array of size
NO_MEOS_TYPES(currently 63). This array allows us to obtain theOidcorresponding to ameosTypeby accessing an element of the array as followsThe mapping from
Oid->meosTypeprovided by the functionis now implemented as a hash table using the include file
simplehash.h. This hash table allows us to obtain themeosTypecorresponding to anOidby accessing using a hash-table lookup as followsinstead of the previous solution which consists on the following loop
The reason for this solution is that the look up of a
meosTypefrom anOidis needed at every single access of a value of a MEOS template type, i.e.,set,span,spanset, andtemporaltypes, as in the following exampleTherefore, the heavy usage of this function motivates using a hash table.
An alternative solution is to have an Oid-indexed array with 2^32 = 65536 entries since the Oid type is defined as follows
Although this solution is simpler algorithmically, only
NO_MEOS_TYPESout of the 65536 slots are used and thus it wastes memory for unused slots.