What does PyJMultiMethod means and how to call it in Python?

23 прегледа
Пређи на прву непрочитану поруку

Guofeng Zhang

непрочитано,
27. 9. 2020. 04:47:2327.9.20.
– Jep Project
Hi,

I passes spark DataSet<Row> to a python function, but when I call the map method in the python function, I got <class 'NameError'>: No such Method.

The code in Java is as below:

        Interpreter interp = new SharedInterpreter() ;
        interp.exec("import example_df");
        interp.set("df", df);
        interp.exec("x = example_df.callWithDF(df)");

How to solve it?

Thanks,

Guofeng

Ben Steffensmeier

непрочитано,
27. 9. 2020. 12:02:0127.9.20.
– Jep Project
Java allows method overloading, where multiple methods are defined with the same name. The compiler determines which method to call based off the type and number of arguments. Python does not support method overloading, only one method can be defined with a certain name. PyJMultiMethod is used to allow compatibility between the different Python and Java philosophies. When a Java object with overloaded methods is passed to Python then a PyJMultiMethod is created. This is a callable Python object that will examine the type of any arguments passed in to try to pick the best Java method to call. Since PyJMultiMethod implements the __call__ method, you can call it like any other python fucntion. I do not have enough information about your case to know why you would be seeing a NameError.

Ben
Одговори свима
Одговори аутору
Проследи
0 нових порука