Description Usage Arguments Details Value Note See Also Examples
Call a Java method in the JVM running the Spark driver. The return values are automatically converted to R objects for simple objects. Other values are returned as "jobj" which are references to objects on JVM.
1 | sparkR.callJMethod(x, methodName, ...)
|
x |
object to invoke the method on. Should be a "jobj" created by newJObject. |
methodName |
method name to call. |
... |
parameters to pass to the Java method. |
This is a low level function to access the JVM directly and should only be used for advanced use cases. The arguments and return values that are primitive R types (like integer, numeric, character, lists) are automatically translated to/from Java types (like Integer, Double, String, Array). A full list can be found in serialize.R and deserialize.R in the Apache Spark code base.
the return value of the Java method. Either returned as a R object if it can be deserialized or returned as a "jobj". See details section for more.
sparkR.callJMethod since 2.0.1
sparkR.callJStatic, sparkR.newJObject
1 2 3 4 5 6 7 8 | ## Not run:
sparkR.session() # Need to have a Spark JVM running before calling newJObject
# Create a Java ArrayList and populate it
jarray <- sparkR.newJObject("java.util.ArrayList")
sparkR.callJMethod(jarray, "add", 42L)
sparkR.callJMethod(jarray, "get", 0L) # Will print 42
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.