public class FunctionRegistryHolder extends Object implements AutoCloseable
ReadWriteLock
implementation usage.
Holder has number version which indicates remote function registry version number it is in sync with.
Structure example:
JARS built-in -> upper -> upper(VARCHAR-REQUIRED) -> lower -> lower(VARCHAR-REQUIRED) First.jar -> upper -> upper(VARCHAR-OPTIONAL) -> custom_upper -> custom_upper(VARCHAR-REQUIRED) -> custom_upper(VARCHAR-OPTIONAL) Second.jar -> lower -> lower(VARCHAR-OPTIONAL) -> custom_upper -> custom_upper(VARCHAR-REQUIRED) -> custom_upper(VARCHAR-OPTIONAL) FUNCTIONS upper -> upper(VARCHAR-REQUIRED) -> function holder for upper(VARCHAR-REQUIRED) -> upper(VARCHAR-OPTIONAL) -> function holder for upper(VARCHAR-OPTIONAL) lower -> lower(VARCHAR-REQUIRED) -> function holder for lower(VARCHAR-REQUIRED) -> lower(VARCHAR-OPTIONAL) -> function holder for lower(VARCHAR-OPTIONAL) custom_upper -> custom_upper(VARCHAR-REQUIRED) -> function holder for custom_upper(VARCHAR-REQUIRED) -> custom_upper(VARCHAR-OPTIONAL) -> function holder for custom_upper(VARCHAR-OPTIONAL) custom_lower -> custom_lower(VARCHAR-REQUIRED) -> function holder for custom_lower(VARCHAR-REQUIRED) -> custom_lower(VARCHAR-OPTIONAL) -> function holder for custom_lower(VARCHAR-OPTIONAL)where
String
.String
.DrillFuncHolder
initiated for each function.Constructor and Description |
---|
FunctionRegistryHolder() |
Modifier and Type | Method and Description |
---|---|
void |
addJars(Map<String,List<FunctionHolder>> newJars,
int version)
Adds jars to the function registry.
|
void |
close() |
boolean |
containsJar(String jarName)
Checks is jar is present in
jars . |
int |
functionsSize()
Returns quantity of functions stored in
functions . |
org.apache.drill.shaded.guava.com.google.common.collect.ListMultimap<String,DrillFuncHolder> |
getAllFunctionsWithHolders()
Returns list of functions with list of function holders for each functions without version number.
|
org.apache.drill.shaded.guava.com.google.common.collect.ListMultimap<String,DrillFuncHolder> |
getAllFunctionsWithHolders(AtomicInteger version)
Returns list of functions with list of function holders for each functions.
|
org.apache.drill.shaded.guava.com.google.common.collect.ListMultimap<String,String> |
getAllFunctionsWithSignatures()
Returns list of functions with list of function signatures for each functions.
|
List<String> |
getAllJarNames()
Retrieves list of all jars name present in
jars
This is read operation, so several users can get this data. |
Map<String,List<FunctionHolder>> |
getAllJarsWithFunctionHolders()
Retrieves all functions (holders) associated with all the jars
This is read operation, so several users can perform this operation at the same time.
|
List<String> |
getFunctionNamesByJar(String jarName)
Retrieves all function names associated with the jar from
jars . |
List<DrillFuncHolder> |
getHoldersByFunctionName(String functionName)
Returns all function holders associated with function name without version number.
|
List<DrillFuncHolder> |
getHoldersByFunctionName(String functionName,
AtomicInteger version)
Returns all function holders associated with function name.
|
String |
getJarNameByFunctionSignature(String functionName,
String functionSignature)
Looks which jar in
jars contains passed function signature. |
int |
getVersion()
This is read operation, so several users at a time can get this data.
|
void |
removeJar(String jarName)
|
public int getVersion()
public void addJars(Map<String,List<FunctionHolder>> newJars, int version)
jars
and each function will be added using addFunctions(Map, List)
.
Registry version is updated with passed version if all jars were added successfully.
This is write operation, so one user at a time can call perform such action,
others will wait till first user completes his action.newJars
- jars and list of their function holders, each contains function name, signature and holderpublic void removeJar(String jarName)
jars
and all associated with jar functions from functions
This is write operation, so one user at a time can call perform such action,
others will wait till first user completes his action.jarName
- jar name to be removedpublic List<String> getAllJarNames()
jars
This is read operation, so several users can get this data.public Map<String,List<FunctionHolder>> getAllJarsWithFunctionHolders()
public List<String> getFunctionNamesByJar(String jarName)
jars
.
Returns empty list if jar is not registered.
This is a read operation, so several users can perform this operation at the same time.jarName
- jar namepublic org.apache.drill.shaded.guava.com.google.common.collect.ListMultimap<String,DrillFuncHolder> getAllFunctionsWithHolders(AtomicInteger version)
ListMultimap
structure to return data.
If no functions present, will return empty ListMultimap
.
If version holder is not null, updates it with current registry version number.
This is a read operation, so several users can perform this operation at the same time.version
- version holderpublic org.apache.drill.shaded.guava.com.google.common.collect.ListMultimap<String,DrillFuncHolder> getAllFunctionsWithHolders()
public org.apache.drill.shaded.guava.com.google.common.collect.ListMultimap<String,String> getAllFunctionsWithSignatures()
ListMultimap
structure to return data.
If no functions present, will return empty ListMultimap
.
This is a read operation, so several users can perform this operation at the same time.public List<DrillFuncHolder> getHoldersByFunctionName(String functionName, AtomicInteger version)
functionName
- function nameversion
- version holderpublic List<DrillFuncHolder> getHoldersByFunctionName(String functionName)
functionName
- function namepublic boolean containsJar(String jarName)
jars
.
This is a read operation, so several users can perform this operation at the same time.jarName
- jar namepublic int functionsSize()
functions
.
This is a read operation, so several users can perform this operation at the same time.public String getJarNameByFunctionSignature(String functionName, String functionSignature)
jars
contains passed function signature.
First looks by function name and if found checks if such function has passed function signature.
Returns jar name if found matching function signature, else null.
This is a read operation, so several users can perform this operation at the same time.functionName
- function namefunctionSignature
- function signaturepublic void close()
close
in interface AutoCloseable
Copyright © 1970 The Apache Software Foundation. All rights reserved.