-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hashid support #37013
Add hashid support #37013
Conversation
One open question I had was if the |
The code looks good overall but it contains unnecessary copy from temporary object of std::string type. It may also lead to unnecessary allocation if string is larger than around 24 bytes. |
If alphabet is known in compile time, division can be optimized: https://github.com/schoentoon/hashidsxx/blob/master/hashids.cpp#L114 |
Reserve can be used: https://github.com/schoentoon/hashidsxx/blob/master/hashids.cpp#L112 |
@alexey-milovidov thank you for taking a look! So I understand about the unnecessary allocation, are you referring to the std::string created inside the Regarding the alphabet, the default alphabet is known at compile time but the user can pass their own alphabet, is it worth special-casing the case where people use the default? It doesn't look like that string in https://github.com/schoentoon/hashidsxx/blob/master/hashids.cpp#L112 can ever grow past 16 characters so should get SSO right? I did a little profiling and unsurprisingly the vast majority of time is spent in hashid's |
Does anyone have ideas about these few build failures? As far as I can tell they seem to come from:
Is this a flakiness issue, or is there an actual problem elsewhere? |
@mnutt I don't think ENABLE_HASHIDSXX is really necessary here. |
@mnutt and we have additional objective for this issue - we want to add setting |
623cdd9
to
f6156c3
Compare
newline at end of file added
Changelog category:
Changelog entry:
Add support for calculating hashids from unsigned integers.
We use UInt64 ids internally but expose hashids to end users and it would be simpler and faster to have ClickHouse produce them.
This is my first time working in the ClickHouse codebase so I tried to write it based on how other functions are written however I wasn't totally sure if my approach to variadic function argument checking was the best way to to do it, and if there would be any problems with the method it uses to support const/non-const UInt8/UInt16/UInt32/UInt64.
I added some stateless tests, and once everything else looks good I can update the
contrib
docs.