| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Create Java Objects</title> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| <link rel="stylesheet" type="text/css" href="R.css" /> |
| |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css"> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"></script> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/languages/r.min.js"></script> |
| <script>hljs.initHighlightingOnLoad();</script> |
| </head><body> |
| |
| <table width="100%" summary="page for sparkR.newJObject {SparkR}"><tr><td>sparkR.newJObject {SparkR}</td><td style="text-align: right;">R Documentation</td></tr></table> |
| |
| <h2>Create Java Objects</h2> |
| |
| <h3>Description</h3> |
| |
| <p>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. |
| </p> |
| |
| |
| <h3>Usage</h3> |
| |
| <pre> |
| sparkR.newJObject(x, ...) |
| </pre> |
| |
| |
| <h3>Arguments</h3> |
| |
| <table summary="R argblock"> |
| <tr valign="top"><td><code>x</code></td> |
| <td> |
| <p>fully qualified Java class name.</p> |
| </td></tr> |
| <tr valign="top"><td><code>...</code></td> |
| <td> |
| <p>arguments to be passed to the constructor.</p> |
| </td></tr> |
| </table> |
| |
| |
| <h3>Details</h3> |
| |
| <p>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. |
| </p> |
| |
| |
| <h3>Value</h3> |
| |
| <p>the object created. Either returned as a R object |
| if it can be deserialized or returned as a "jobj". See details section for more. |
| </p> |
| |
| |
| <h3>Note</h3> |
| |
| <p>sparkR.newJObject since 2.0.1 |
| </p> |
| |
| |
| <h3>See Also</h3> |
| |
| <p><a href="sparkR.callJMethod.html">sparkR.callJMethod</a>, <a href="sparkR.callJStatic.html">sparkR.callJStatic</a> |
| </p> |
| |
| |
| <h3>Examples</h3> |
| |
| <pre><code class="r">## Not run: |
| ##D sparkR.session() # Need to have a Spark JVM running before calling newJObject |
| ##D # Create a Java ArrayList and populate it |
| ##D jarray <- sparkR.newJObject("java.util.ArrayList") |
| ##D sparkR.callJMethod(jarray, "add", 42L) |
| ##D sparkR.callJMethod(jarray, "get", 0L) # Will print 42 |
| ## End(Not run) |
| </code></pre> |
| |
| |
| <hr /><div style="text-align: center;">[Package <em>SparkR</em> version 2.3.2 <a href="00Index.html">Index</a>]</div> |
| </body></html> |