Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/17264
  
    I quickly did check performance changes;
    ```
    public class TestGenericUDF extends GenericUDF {
      @Override
      public ObjectInspector initialize(ObjectInspector[] objectInspectors) 
throws UDFArgumentException {
          return PrimitiveObjectInspectorFactory.javaLongObjectInspector;
      }
    
      @Override
      public Object evaluate(DeferredObject[] args) throws HiveException {
          final long a1 = 
PrimitiveObjectInspectorFactory.javaLongObjectInspector.get(args[0].get());
          final long a2 = 
PrimitiveObjectInspectorFactory.javaLongObjectInspector.get(args[1].get());
          final long a3 = 
PrimitiveObjectInspectorFactory.javaLongObjectInspector.get(args[2].get());
          final long a4 = 
PrimitiveObjectInspectorFactory.javaLongObjectInspector.get(args[3].get());
          return a1 + a2 + a3 + a4;
      }
    }
    ```
    
    ```
    $./bin/spark-shell --master local[1]  --conf spark.sql.shuffle.partitions=1 
-v
    
    scala> sql("CREATE TEMPORARY FUNCTION testUdf AS 
'hivemall.ftvec.TestGenericUDF'")
    scala> :paste
    def timer[R](block: => R): R = {
      val t0 = System.nanoTime()
      val result = block
      val t1 = System.nanoTime()
      println("Elapsed time: " + ((t1 - t0 + 0.0) / 1000000000.0)+ "s")
      result
    }
    
    scala> spark.range(3000000).createOrReplaceTempView("t")
    scala> timer { sql("SELECT testUdf(id, id, id, id) FROM 
t").queryExecution.executedPlan.execute().foreach(x => {}) }
    ```
    
    ```
    # performance w/ this patch
    Elapsed time: 1.901269167s
    
    # performance w/o this patch
    Elapsed time: 0.492860666s
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to