Class CacheContext


  • public class CacheContext
    extends java.lang.Object
    Cache related context.
    • Constructor Detail

      • CacheContext

        protected CacheContext()
        Expected to be inherited in PrestoDB or other local cache caller. Subclasses could override the callback methods such as incrementCounter
    • Method Detail

      • defaults

        public static CacheContext defaults()
        Returns:
        the default CacheContext
      • getCacheIdentifier

        @Nullable
        public java.lang.String getCacheIdentifier()
        Returns an string as a hint from computation to indicate the file. Note that, this can be independent and different from Alluxio File ID stored in URIStatus.mInfo, which is assigned and maintained by Alluxio master. In cases like using Alluxio local cache, such Alluxio File ID may not be available.
        Returns:
        the unique string identifier of the entity to cache
      • getHiveCacheContext

        @Nullable
        public HiveCacheContext getHiveCacheContext()
        Returns:
        the hive cache context
      • getCacheQuota

        public CacheQuota getCacheQuota()
        Returns:
        the cache quota
      • getCacheScope

        public CacheScope getCacheScope()
        Returns:
        the cache scope
      • setCacheIdentifier

        public CacheContext setCacheIdentifier​(java.lang.String identifier)
        Parameters:
        identifier - the id to use
        Returns:
        the updated CacheContext
      • setCacheQuota

        public CacheContext setCacheQuota​(CacheQuota cacheQuota)
        Parameters:
        cacheQuota - the cache quota
        Returns:
        the updated CacheContext
      • setCacheScope

        public CacheContext setCacheScope​(CacheScope cacheScope)
        Parameters:
        cacheScope - the cache quota
        Returns:
        the updated CacheContext
      • setHiveCacheContext

        public CacheContext setHiveCacheContext​(HiveCacheContext hiveCacheContext)
        Parameters:
        hiveCacheContext - the hive cache context
        Returns:
        the updated CacheContext
      • isTemporary

        public boolean isTemporary()
        Returns:
        whether the caching data is temporary
      • setTemporary

        public CacheContext setTemporary​(boolean isTemporary)
        Parameters:
        isTemporary - whether the caching data is temporary
        Returns:
        the updated CacheContext
      • incrementCounter

        public void incrementCounter​(java.lang.String name,
                                     long value)
        Increments the counter name by value.

        Default implementation does nothing. Subclass can implement its own tracking mechanism.

        Parameters:
        name - name of the counter
        value - value of the counter
      • incrementCounter

        public void incrementCounter​(java.lang.String name,
                                     CacheContext.StatsUnit unit,
                                     long value)
        Increments the counter name by value.

        Default implementation does nothing. Subclass can implement its own tracking mechanism.

        Parameters:
        name - name of the counter
        unit - unit of the counter
        value - value of the counter
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object