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

Eliminate fillArray for ObjObj Map by using FREE=null #30

Closed
frajt opened this issue Nov 24, 2014 · 3 comments
Closed

Eliminate fillArray for ObjObj Map by using FREE=null #30

frajt opened this issue Nov 24, 2014 · 3 comments

Comments

@frajt
Copy link

frajt commented Nov 24, 2014

Hi,

we are using Trove library with some extra modifications where one of them is about null reference being used for the FREE value. The initial array creation and rehashing do not require to fill the array with FREE values (one extra iteration over the complete array is now required).
Additionally it can be cheaper for a garbage collector to see a null reference than many references to a singleton object representing FREE - null should be for free.
Obviously there is some cost in handling key slots where the new NULL object represents null key - could be reduced by noNull case (like you do with noRemoved).

protected static final Object REMOVED = new Object(), FREE = null, NULL = new Object();

Michal

@leventov
Copy link
Owner

Accepted. Planned as a part of this "project": https://github.com/OpenHFT/Koloboke/wiki/Koloboke:-roll-the-collection-implementation-with-features-you-need . Vote for it if you are interested in this feature.

@leventov
Copy link
Owner

The problem with NULL = new Object() (i. e. masking nulls) is that you should anyway do quite many annoying masking/unmasking to support custom equivalences. So it really makes sense only to have special implementation which throws NPE if the key is null and then just assumes all keys are not null. It should be returned if withNullKeyAllowed(false) is configured.

@leventov
Copy link
Owner

This is implemented in Koloboke Compile, it generates implementations that use null as the "free" value, if the implemented type is not annotated with @NullKeyAllowed.

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

No branches or pull requests

2 participants