Package org.apache.druid.query.lookup
Class ImmutableLookupMap
-
public final class ImmutableLookupMap extends com.google.common.collect.ForwardingMap<String,String>
Similar toMapLookupExtractor
, but immutable, and also reversible without iterating the entire map. Forward lookup,ImmutableLookupMap.ImmutableLookupExtractor.apply(String)
, is implemented using anObject2IntOpenHashMap
with load factorLOAD_FACTOR
. The value of the map is an index intokeys
andForwardingMap.values()
. Reverse lookup,ImmutableLookupMap.ImmutableLookupExtractor.unapply(String)
, is implemented using binary search throughForwardingMap.values()
. Thekeys
andForwardingMap.values()
lists are both sorted by value usingVALUE_COMPARATOR
. Relative toMapLookupExtractor
backed by JavaHashMap
, this map has been observed to have somewhat lower footprint, same performance forImmutableLookupMap.ImmutableLookupExtractor.apply(String)
, and significantly faster forImmutableLookupMap.ImmutableLookupExtractor.unapply(String)
. It should be used whenever the map does not need to be mutated.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ImmutableLookupMap.ImmutableLookupExtractor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LookupExtractor
asLookupExtractor(boolean isOneToOne, Supplier<byte[]> cacheKey)
protected Map<String,String>
delegate()
static ImmutableLookupMap
fromMap(Map<String,String> srcMap)
Create anImmutableLookupMap
from 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, values
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
fromMap
public static ImmutableLookupMap fromMap(Map<String,String> srcMap)
Create anImmutableLookupMap
from a particular map. The provided map will not be stored in the returnedImmutableLookupMap
.
-
asLookupExtractor
public LookupExtractor asLookupExtractor(boolean isOneToOne, Supplier<byte[]> cacheKey)
-
-