Skip to content
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

Is it possible to allocate exact capacity? #57

Open
erickpintor opened this issue Jun 21, 2017 · 1 comment
Open

Is it possible to allocate exact capacity? #57

erickpintor opened this issue Jun 21, 2017 · 1 comment

Comments

@erickpintor
Copy link

I'm using Koloboke Compile to generate a ObjLongMap. I have a file containing 249_229_948 records and I'm using the default constructor with that number as the expected size. I've noticed that the capacity of the final map is substantially higher than the expected size: 498_958_307.

I've tried to play with the HashConfig already but, I wonder if there is a way allocate the exact capacity needed. In my case, the Map will be immutable once it's loaded into memory so, I don't need it to grow at any factor.

@leventov
Copy link
Owner

Seems that you are using @QuadraticHashing. @QuadraticHashing chooses the capacity from a predefined subset of integers, so you couldn't obtain a map with arbitrary capacity, you could only try to obtain a capacity of +- 1% from the exact number that you want, by playing with HashConfig, or with the given expectedSize, using a fixed HashConfig and expectedSize, so that desiredCapacity = expectedSize / targetLoad.

Note that this algorithm is slower than @LinearProbing, which restricts available capacities to powers of two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants