Class LocalFunctionRegistry

java.lang.Object
org.apache.drill.exec.expr.fn.registry.LocalFunctionRegistry
All Implemented Interfaces:
AutoCloseable

public class LocalFunctionRegistry extends Object implements AutoCloseable
Registry of Drill functions.
  • Field Details

  • Constructor Details

    • LocalFunctionRegistry

      public LocalFunctionRegistry(ScanResult classpathScan)
      Registers all functions present in Drill classpath on start-up. All functions will be marked as built-in. Built-in functions are not allowed to be unregistered. Since local function registry version is based on remote function registry version, initially sync version will be set to DataChangeVersion.UNDEFINED to ensure that upon first check both registries would be synchronized.
  • Method Details

    • getVersion

      public int getVersion()
      Returns:
      remote function registry version number with which local function registry is synced
    • validate

      public List<String> validate(String jarName, ScanResult scanResult)
      Validates all functions, present in jars. Will throw FunctionValidationException if:
      1. Jar with the same name has been already registered.
      2. Conflicting function with the similar signature is found.
      3. Aggregating function is not deterministic.
      Parameters:
      jarName - jar name to be validated
      scanResult - scan of all classes present in jar
      Returns:
      list of validated function signatures
    • register

      public void register(List<JarScan> jars, int version)
      Registers all functions present in jar and updates registry version. If jar name is already registered, all jar related functions will be overridden. To prevent classpath collisions during loading and unloading jars, each jar is shipped with its own class loader.
      Parameters:
      jars - list of jars to be registered
      version - remote function registry version number with which local function registry is synced
    • unregister

      public void unregister(String jarName)
      Removes all function associated with the given jar name. Functions marked as built-in is not allowed to be unregistered. If user attempts to unregister built-in functions, logs warning and does nothing. Jar name is case-sensitive.
      Parameters:
      jarName - jar name to be unregistered
    • getAllJarNames

      public List<String> getAllJarNames()
      Returns list of jar names registered in function registry.
      Returns:
      list of jar names
    • size

      public int size()
      Returns:
      quantity of all registered functions
    • getMethods

      public List<DrillFuncHolder> getMethods(String name, AtomicInteger version)
      Parameters:
      name - function name
      Returns:
      all function holders associated with the function name. Function name is case insensitive.
    • getMethods

      public List<DrillFuncHolder> getMethods(String name)
      Parameters:
      name - function name
      Returns:
      all function holders associated with the function name. Function name is case insensitive.
    • getAllJarsWithFunctionsHolders

      public Map<String,List<FunctionHolder>> getAllJarsWithFunctionsHolders()
      Returns a map of all function holders mapped by source jars
      Returns:
      all functions organized by source jars
    • register

      public void register(DrillOperatorTable operatorTable)
      Registers all functions present in DrillOperatorTable, also sets sync registry version used at the moment of function registration.
      Parameters:
      operatorTable - drill operator table
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable