Class ICUResourceBundleReader.ResourceCache
- Enclosing class:
ICUResourceBundleReader
Mutable objects must not be cached and then returned to the caller because the cache must not be writable via the returned reference.
Resources are mapped by their resource integers. Empty resources with offset 0 cannot be mapped. Integers need not and should not be cached. Multiple .res items may share resource offsets (genrb eliminates some duplicates).
Large resource objects are usually stored in SoftReferences.
This replaces the previous custom trie structure (ICU-10932, 2014) with ConcurrentHashMap for lock-free concurrent reads. Benchmarking shows CHM uses ~3x less memory than the trie at typical ICU bundle sizes (~221 entries/cache) due to the trie's sparse power-of-2 Level arrays (5% utilization), while providing ~2x better throughput at 32 threads by eliminating the synchronized bottleneck on every resource lookup.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static ObjectdeduplicateItem(Object value, Map<CharBuffer, char[]> charMap, Map<IntBuffer, int[]> intMap, Map<String, String> stringMap) (package private) void(package private) Objectget(int res) (package private) ObjectputIfAbsent(int res, Object item, int size) private static booleanstoreDirectly(int size)
-
Field Details
-
map
-
-
Constructor Details
-
ResourceCache
ResourceCache()
-
-
Method Details
-
storeDirectly
private static boolean storeDirectly(int size) -
get
-
putIfAbsent
-
deduplicateTableArrays
void deduplicateTableArrays() -
deduplicateItem
-