Class LoadingCacheLookup<T>

java.lang.Object
org.apache.calcite.schema.lookup.LoadingCacheLookup<T>
Type Parameters:
T - Element Type
All Implemented Interfaces:
Lookup<T>

public class LoadingCacheLookup<T> extends Object implements Lookup<T>
This class is using a LoadingCache to speed up lookups, delegated to another Lookup instance.

This class is thread safe. All entries are evicted after one minute. Negative matches are never cached. If a new entry becomes available in the associated Lookup, it's immediately visible outside. If an entry is deleted in the associated Lookup, it takes one minute until it disappears if it was cached in the last minute. Otherwise, it disappears immediately.

  • Constructor Details

    • LoadingCacheLookup

      public LoadingCacheLookup(Lookup<T> delegate, Duration expiration)
      Creates a Lookup object with a `LoadingCache`inside.
      Parameters:
      delegate - The Lookup object, which should be cached
      expiration - The duration after which the entries are evicted from the loading cache.
    • LoadingCacheLookup

      public LoadingCacheLookup(Lookup<T> delegate)
      Creates a Lookup object with a `LoadingCache`inside.

      The expiration is set to 1 minute.

      Parameters:
      delegate - The Lookup object, which should be cached
  • Method Details

    • get

      public @Nullable T get(String name)
      Description copied from interface: Lookup
      Returns a named entity with a given name, or null if not found.
      Specified by:
      get in interface Lookup<T>
      Parameters:
      name - Name
      Returns:
      Entity with the specified name, or null when the entity is not found.
    • getIgnoreCase

      public @Nullable Named<T> getIgnoreCase(String name)
      Description copied from interface: Lookup
      Returns a named entity with a given name ignoring the case, or null if not found.
      Specified by:
      getIgnoreCase in interface Lookup<T>
      Parameters:
      name - Name
      Returns:
      Entity with the specified name (case insensitive), or null when the entity is not found.
    • getNames

      public Set<String> getNames(LikePattern pattern)
      Description copied from interface: Lookup
      Returns the names of the entities in matching pattern. The search is always case sensitive. This is caused by the fact that DatabaseMetaData.getTables(...) doesn't support case insensitive lookups.
      Specified by:
      getNames in interface Lookup<T>
      Returns:
      The names of all entities matching the pattern.