Class HostUDFWrapper

java.lang.Object
ai.rapids.cudf.HostUDFWrapper

public abstract class HostUDFWrapper extends Object
A wrapper around native host UDF aggregations.

This class is used to create the native handle of a host UDF aggregation and is used as a proxy object to compute hash code and compare two host UDF aggregations for equality.

A new host UDF aggregation implementation must extend this class and override the computeHashCode and isEqual methods for such purposes.

  • Constructor Details

    • HostUDFWrapper

      public HostUDFWrapper()
  • Method Details

    • createUDFInstance

      public abstract long createUDFInstance()
      Create a derived host UDF native instance. The instance created by this function MUST be closed by `closeUDFInstance`

      Typical usage, refer to Aggregation.java:

       long udf = 0;
       try {
           udf = wrapper.createUDFInstance();
           return Aggregation.createHostUDFAgg(udf);
       } finally {
           // a new UDF is cloned in `createHostUDFAgg`, here should close the UDF instance.
           if (udf != 0) {
               HostUDFWrapper.closeUDFInstance(udf);
           }
       }
       
    • closeUDFInstance

      public static void closeUDFInstance(long hostUDFInstance)
      Close the derived UDF instance created by `createUDFInstance`.
      Parameters:
      hostUDFInstance - the UDF instance
    • computeHashCode

      public abstract int computeHashCode()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isEqual

      public abstract boolean isEqual(Object obj)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object