fastutil icon indicating copy to clipboard operation
fastutil copied to clipboard

compute method on primitive maps cause boxing/unboxing

Open gity opened this issue 8 years ago • 3 comments

The compute method on the maps require unboxing and boxing since the rely on the standard JDK 8 BiFunction instead of generating primitive type specific a BiFunction for each use case.

For example, Object2LongMap#computeLong

For example compare with Koloboke ObjLongMap#compute

It good that it is solved with Object2LongMap#computeLongIfAbsent, shame about computeLong

gity avatar Aug 18 '17 17:08 gity

The problem here is the parameter space explosion. Having type-specific BiFunctions is totally possible, but would require 8*8*8 = 512 additional classes (or maybe even 9*9*9). Moreover, this would require non-trivial changes to the way the sources are generated (since we need a triple of types instead of a key-value tuple).

If we only add the BiFunctions for this specific use case, we could restrict ourselves to Key x Key -> Value and Key x Value -> Value, I think - potentially, something like Key x Key -> ValueObject and Key x Value -> ValueObject should be added, too. This would still be a lot of classes but less work since one does not have to change the source generation too much.

incaseoftrouble avatar Aug 21 '17 06:08 incaseoftrouble

Right. How does Koloboke do it? Hundreds of function classes?

vigna avatar Aug 21 '17 09:08 vigna

Koloboke API 1.0.0 has a function package with 281 classes in it.

gity avatar Aug 22 '17 08:08 gity