Package org.apache.druid.query.lookup
Class ImmutableLookupMap
public final class ImmutableLookupMap
extends com.google.common.collect.ForwardingMap<String,String>
Similar to
MapLookupExtractor, but immutable, and also reversible without iterating the entire map.
Forward lookup, ImmutableLookupMap.ImmutableLookupExtractor.apply(String), is implemented using an Object2IntOpenHashMap
with load factor LOAD_FACTOR. The value of the map is an index into keys and ForwardingMap.values().
Reverse lookup, ImmutableLookupMap.ImmutableLookupExtractor.unapply(String), is implemented using binary search through
ForwardingMap.values(). The keys and ForwardingMap.values() lists are both sorted by value using VALUE_COMPARATOR.
Relative to MapLookupExtractor backed by Java HashMap, this map has been observed to have
somewhat lower footprint, same performance for ImmutableLookupMap.ImmutableLookupExtractor.apply(String), and significantly
faster for ImmutableLookupMap.ImmutableLookupExtractor.unapply(String). It should be used whenever the map does not need to
be mutated.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.google.common.collect.ForwardingMap
com.google.common.collect.ForwardingMap.StandardEntrySet, com.google.common.collect.ForwardingMap.StandardKeySet, com.google.common.collect.ForwardingMap.StandardValues -
Method Summary
Modifier and TypeMethodDescriptionasLookupExtractor(boolean isOneToOne, Supplier<byte[]> cacheKey) delegate()static ImmutableLookupMapCreate anImmutableLookupMapfrom a particular map.Methods inherited from class com.google.common.collect.ForwardingMap
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToString, valuesMethods inherited from class com.google.common.collect.ForwardingObject
toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Method Details
-
fromMap
Create anImmutableLookupMapfrom a particular map. The provided map will not be stored in the returnedImmutableLookupMap. -
delegate
-
asLookupExtractor
-