Package org.apache.drill.exec.expr.fn
Class FunctionImplementationRegistry
java.lang.Object
org.apache.drill.exec.expr.fn.FunctionImplementationRegistry
- All Implemented Interfaces:
AutoCloseable
,FunctionLookupContext
public class FunctionImplementationRegistry
extends Object
implements FunctionLookupContext, AutoCloseable
Registry for functions. Notably, in addition to Drill its functions (in
LocalFunctionRegistry
), other PluggableFunctionRegistry (e.g.,
HiveFunctionRegistry
) is also
registered in this class-
Constructor Summary
ConstructorDescriptionFunctionImplementationRegistry
(DrillConfig config, ScanResult classpathScan) FunctionImplementationRegistry
(DrillConfig config, ScanResult classpathScan, OptionManager optionManager) FunctionImplementationRegistry
(DrillConfig config, ScanResult classpathScan, OptionSet optionManager) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
IfdeleteTmpDir
is set to true, deletes generated temporary directory.findDrillFunction
(FunctionResolver functionResolver, FunctionCall functionCall) First attempts to find the Drill function implementation that matches the name, arg types and return type.findExactMatchingDrillFunction
(String name, List<TypeProtos.MajorType> argTypes, TypeProtos.MajorType returnType) Finds the Drill function implementation that matches the name, arg types and return type.findNonDrillFunction
(FunctionCall functionCall) Find function implementation for givenfunctionCall
in non-Drill function registries such as Hive UDF registry.Retrieve all functions, mapped by source jars (after syncing)boolean
void
register
(DrillOperatorTable operatorTable) Register functions in given operator table.boolean
syncWithRemoteRegistry
(int version) Purpose of this method is to synchronize remote and local function registries if needed and to inform if function registry was changed after given version.validate
(org.apache.hadoop.fs.Path path) Using given local path to jar creates unique class loader for this jar.
-
Constructor Details
-
FunctionImplementationRegistry
-
FunctionImplementationRegistry
-
FunctionImplementationRegistry
public FunctionImplementationRegistry(DrillConfig config, ScanResult classpathScan, OptionManager optionManager) -
FunctionImplementationRegistry
public FunctionImplementationRegistry(DrillConfig config, ScanResult classpathScan, OptionSet optionManager)
-
-
Method Details
-
register
Register functions in given operator table.- Parameters:
operatorTable
- operator table
-
findDrillFunction
public DrillFuncHolder findDrillFunction(FunctionResolver functionResolver, FunctionCall functionCall) First attempts to find the Drill function implementation that matches the name, arg types and return type. If exact function implementation was not found, syncs local function registry with remote function registry if needed and tries to find function implementation one more time but this time using givenfunctionResolver
.- Specified by:
findDrillFunction
in interfaceFunctionLookupContext
- Parameters:
functionResolver
- function resolverfunctionCall
- function call- Returns:
- best matching function holder
-
findExactMatchingDrillFunction
public DrillFuncHolder findExactMatchingDrillFunction(String name, List<TypeProtos.MajorType> argTypes, TypeProtos.MajorType returnType) Finds the Drill function implementation that matches the name, arg types and return type.- Parameters:
name
- function nameargTypes
- input parameters typesreturnType
- function return type- Returns:
- exactly matching function holder
-
findNonDrillFunction
Find function implementation for givenfunctionCall
in non-Drill function registries such as Hive UDF registry. Note: Order of searching is same as order ofPluggableFunctionRegistry
implementations found on classpath.- Specified by:
findNonDrillFunction
in interfaceFunctionLookupContext
- Parameters:
functionCall
- function call- Returns:
- drill function holder
-
isFunctionComplexOutput
-
getLocalFunctionRegistry
-
getRemoteFunctionRegistry
-
validate
Using given local path to jar creates unique class loader for this jar. Class loader is closed to release opened connection to jar when validation is finished. Scan jar content to receive list of all scanned classes and starts validation process against local function registry. Checks if received list of validated function is not empty.- Parameters:
path
- local path to jar we need to validate- Returns:
- list of validated function signatures
- Throws:
IOException
-
syncWithRemoteRegistry
public boolean syncWithRemoteRegistry(int version) Purpose of this method is to synchronize remote and local function registries if needed and to inform if function registry was changed after given version. To make synchronization as much light-weigh as possible, first only versions of both registries are checked without any locking. If synchronization is needed, enters synchronized block to prevent others loading the same jars. The need of synchronization is checked again (double-check lock) before comparing jars. If any missing jars are found, they are downloaded to local udf area, each is wrapped intoJarScan
. Once jar download is finished, all missing jars are registered in one batch. In case if any errors during jars download / registration, these errors are logged. During registration local function registry is updated with remote function registry version it is synced with. When at least one jar of the missing jars failed to download / register, local function registry version are not updated but jars that where successfully downloaded / registered are added to local function registry. If synchronization between remote and local function registry was not needed, checks if given registry version matches latest sync version to inform if function registry was changed after given version.- Parameters:
version
- remote function registry local function registry was based on- Returns:
- true if remote and local function registries were synchronized after given version
-
getAllJarsWithFunctionsHolders
Retrieve all functions, mapped by source jars (after syncing)- Returns:
- Map of source jars and their functionHolders
-
close
public void close()IfdeleteTmpDir
is set to true, deletes generated temporary directory. Otherwise cleans uplocalUdfDir
.- Specified by:
close
in interfaceAutoCloseable
-