Class PigUdfFinder


  • class PigUdfFinder
    extends java.lang.Object
    Utility class to find the implementation method object for a given Pig UDF class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.google.common.collect.ImmutableMap<java.lang.String,​java.lang.reflect.Method> udfWrapper
      For Pig UDF classes where the "exec" method is declared in parent class, the Calcite enumerable engine will generate incorrect Java code that instantiates an object of the parent class, not object of the actual UDF class.
    • Constructor Summary

      Constructors 
      Constructor Description
      PigUdfFinder()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.reflect.Method findExecMethod​(java.lang.reflect.Method[] methods)
      Finds "exec" method from a given array of methods.
      (package private) java.lang.reflect.Method findPigUdfImplementationMethod​(java.lang.Class clazz)
      Finds the implementation method object for a given Pig UDF class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • udfWrapper

        private final com.google.common.collect.ImmutableMap<java.lang.String,​java.lang.reflect.Method> udfWrapper
        For Pig UDF classes where the "exec" method is declared in parent class, the Calcite enumerable engine will generate incorrect Java code that instantiates an object of the parent class, not object of the actual UDF class. If the parent class is an abstract class, the auto-generated code failed to compile (we can not instantiate an object of an abstract class).

        Workaround is to write a wrapper for such UDFs to instantiate the correct UDF object. See method PigUdfs.bigdecimalsum(org.apache.pig.data.Tuple) as an example and add others if needed.

    • Constructor Detail

      • PigUdfFinder

        PigUdfFinder()
    • Method Detail

      • findPigUdfImplementationMethod

        @Nonnull
        java.lang.reflect.Method findPigUdfImplementationMethod​(java.lang.Class clazz)
        Finds the implementation method object for a given Pig UDF class.
        Parameters:
        clazz - The Pig UDF class
        Throws:
        java.lang.IllegalArgumentException - if not found
      • findExecMethod

        private static java.lang.reflect.Method findExecMethod​(java.lang.reflect.Method[] methods)
        Finds "exec" method from a given array of methods.