sparkR.newJObject: Create Java Objects

Description Usage Arguments Details Value Note See Also Examples

View source: R/jvm.R

Description

Create a new Java object in the JVM running the Spark driver. The return value is automatically converted to an R object for simple objects. Other values are returned as a "jobj" which is a reference to an object on JVM.

Usage

1

Arguments

x

fully qualified Java class name.

...

arguments to be passed to the constructor.

Details

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.

Value

the object created. Either returned as a R object if it can be deserialized or returned as a "jobj". See details section for more.

Note

sparkR.newJObject since 2.0.1

See Also

sparkR.callJMethod, sparkR.callJStatic

Examples

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)

SparkR documentation built on June 3, 2021, 5:05 p.m.