Class LookupExtractor

    • Constructor Detail

      • LookupExtractor

        public LookupExtractor()
    • Method Detail

      • apply

        @Nullable
        public abstract String apply​(@Nullable
                                     String key)
        Apply a particular lookup methodology to the input string
        Parameters:
        key - The value to apply the lookup to.
        Returns:
        The value for this key, or null when key is `null` or when key cannot have the lookup applied to it and should be treated as missing.
      • applyAll

        public Map<String,​String> applyAll​(Iterable<String> keys)
        Parameters:
        keys - set of keys to apply lookup for each element
        Returns:
        Returns Map whose keys are the contents of keys and whose values are computed on demand using lookup function unapply(String) or empty map if values is `null` User can override this method if there is a better way to perform bulk lookup
      • unapply

        protected abstract List<String> unapply​(@Nullable
                                                String value)
        Reverse lookup from a given value. Used by the default implementation of unapplyAll(Set). Otherwise unused. Implementations that override unapplyAll(Set) may throw UnsupportedOperationException from this method.
        Parameters:
        value - the value to apply the reverse lookup.
        Returns:
        the list of keys that maps to the provided value. In SQL-compatible null handling mode, null keys are omitted.
      • unapplyAll

        @Nullable
        public Iterator<String> unapplyAll​(Set<String> values)
        Reverse lookup from a given set of values.
        Parameters:
        values - set of values to reverse lookup.
        Returns:
        iterator of keys that map to to the provided set of values. May contain duplicate keys. Returns null if this lookup instance does not support reverse lookups. In SQL-compatible null handling mode, null keys are omitted.
      • supportsAsMap

        public abstract boolean supportsAsMap()
        Returns whether this lookup extractor's asMap() will return a valid map.
      • getCacheKey

        public abstract byte[] getCacheKey()
        Create a cache key for use in results caching
        Returns:
        A byte array that can be used to uniquely identify if results of a prior lookup can use the cached values
      • isOneToOne

        public boolean isOneToOne()
      • estimateHeapFootprint

        public long estimateHeapFootprint()
        Estimated heap footprint of this object. Not guaranteed to be accurate. For example, some implementations return zero even though they do use on-heap structures. However, the most common classes, MapLookupExtractor and ImmutableLookupMap, do have reasonable implementations. This API is provided for best-effort memory management and monitoring.