|
|
|
|
|
by cogman10
19 days ago
|
|
One of my least proud (most proud?) hacks when working with very large data sets is something like this Map<Integer, Integer> intCache = new HashMap<>();
while (loading) {
Integer feild1 = intCache.computeIfAbsent(getField1(), (i)->i);
}
This is a terrible thing that shouldn't be as useful as it is to us... but it is really useful. We have a bunch of objects that can optionally have Integer values (hence a null is valid) but those int values are frequently the same.This saves a bunch of memory and ultimately GC pressure as a result. Valhalla can't come soon enough for us. |
|