RagnarGrootKoerkamp / PTRHash

PTRHash minimal perfect hash function, based of PTHash
33 stars 6 forks source link

Added compile-time support #9

Open yyy33 opened 5 months ago

yyy33 commented 5 months ago

Hello, do you have plans for ptrhash to support create and find at compile time

RagnarGrootKoerkamp commented 5 months ago

Hey! Thanks for your interest in ptrhash :)

I'm not currently planning to support this, but if you have I compelling usecase you may be able to convince me otherwise. Would you mind explaining what you would use it for?

Since the main usecase of ptrhash is for (very) large datasets, I don't think compile time construction makes that much sense, and typically it should be fast to do it at runtime also.

yyy33 commented 5 months ago

Hey! Thanks for your interest in ptrhash :)

I'm not currently planning to support this, but if you have I compelling usecase you may be able to convince me otherwise. Would you mind explaining what you would use it for?

Since the main usecase of ptrhash is for (very) large datasets, I don't think compile time construction makes that much sense, and typically it should be fast to do it at runtime also.

Uh, my use case may be a bit trivial, I want to write a namp, similar to a hashmap, but allowing to add mapping relationships between n data types. So now I need a mapping table (Map<TypeId, ErasedVec) that allows build and lookup at compile time.

RagnarGrootKoerkamp commented 5 months ago

If the lookup is also at compile time, a vector of TypeId with linear search should for sure be fine.

In case you'll also do queries at runtime I could see this being useful. But for now I won't have time to work on this project; maybe in a month or two.