camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (Confluence)" <conflue...@apache.org>
Subject [CONF] Apache Camel > RCode
Date Thu, 08 Aug 2013 14:01:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/en/2176/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/RCode">RCode</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-changed-lines" >h2. <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">rcode</span>
<span class="diff-added-words"style="background-color: #dfd;">RCode</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br>The rcode component supports
the integration of the statistics environment [R|http://www.r-project.org/] via [Rserve|http://www.rforge.net/Rserve/]
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="RCode-RCode"></a>RCode</h2>

<p>The rcode component supports the integration of the statistics environment <a
href="http://www.r-project.org/" class="external-link" rel="nofollow">R</a> via <a
href="http://www.rforge.net/Rserve/" class="external-link" rel="nofollow">Rserve</a></p>

<h3><a name="RCode-Dependency"></a>Dependency</h3>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;dependency&gt;
  &lt;groupId&gt;org.apache-extras.camel-extra&lt;/groupId&gt;
  &lt;artifactId&gt;camel-rcode&lt;/artifactId&gt;
  &lt;version&gt;2.12.0&lt;/version&gt;
&lt;/dependency&gt;
</pre>
</div></div>

<h3><a name="RCode-URIformat"></a>URI format</h3>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
rcode://host[:port]/operationId[?options]
</pre>
</div></div>

<p>There are several operations available to integrate Java with R. The current component
has implemented the following subset of operations:</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> operationId </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> ASSIGN_CONTENT </td>
<td class='confluenceTd'> Assigns a string value to a symbol in R. The symbol is created
if it does not already exist. An exchange object passed to an endpoint configured with the
assign_content operation must contain an objet of type <em>Entry&lt;String,String&gt;</em>
where the first String denotes the symbol name and the second contains the value. </td>
</tr>
<tr>
<td class='confluenceTd'> ASSIGN_EXPRESSION </td>
<td class='confluenceTd'> Assigns a content of a R Expression (<em>REXP</em>)
to a symbol in R. The assignment of the symbol takes place when passing an object of type
<em>Entry&lt;String,REXP&gt;</em> via the message exchange. </td>
</tr>
<tr>
<td class='confluenceTd'> EVAL </td>
<td class='confluenceTd'> Evaluates a given R command and retrieves the result. The
R command is transported as <em>String</em> object via the exchange. </td>
</tr>
<tr>
<td class='confluenceTd'> PARSE_AND_EVAL </td>
<td class='confluenceTd'> Parses and evaluates a given R command and retrieves the result.
The R command is transported as String object via the exchange. </td>
</tr>
<tr>
<td class='confluenceTd'> VOID_EVAL </td>
<td class='confluenceTd'> Evaluates a given R command, but does not fetch the result.
The R command is passed as <em>String</em> object within the exchange. This operation
is useful for assignments or for plots having a defined file as output. </td>
</tr>
</tbody></table>
</div>


<p>The following example should clarify the component's interaction style:</p>

<p>Configuring an endpoint that evaluates a given R command.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
from("direct:rcode")
  .to("rcode:localhost:6311/eval?user=test&amp;password=test123&amp;bufferSize=4194304")
  .to("mock:test");
</pre>
</div></div>

<p>Sending an R command to the endpoint. For a full list of possible command, please
refer to the <a href="http://cran.r-project.org/doc/manuals/r-release/R-lang.html" class="external-link"
rel="nofollow">R Language Definition</a></p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
ProducerTemplate template;
template.sendBody("direct:rcode", "c &lt;- sqrt(2^2 + 2^2);");
</pre>
</div></div>

<h3><a name="RCode-Options"></a>Options</h3>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> user </td>
<td class='confluenceTd'> String </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> Configures the username to authenticate secured Rserve instances
</td>
</tr>
<tr>
<td class='confluenceTd'> password </td>
<td class='confluenceTd'> String </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> Adds the password to the endpoint to access a secured R environment
</td>
</tr>
<tr>
<td class='confluenceTd'> bufferSize </td>
<td class='confluenceTd'> long </td>
<td class='confluenceTd'> 2097152 </td>
<td class='confluenceTd'> Defines the buffer size for the transport between Rserve and
the rcode component. The lowest possible value is 32KB, the highest value is at 1GB. Both
values are bound to the available RAM. </td>
</tr>
</tbody></table>
</div>


<h3><a name="RCode-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=CAMEL">Stop
watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://cwiki.apache.org/confluence/users/editmyemailsettings.action">Change
email notification preferences</a>
</div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/RCode">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=34013836&revisedVersion=3&originalVersion=2">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/RCode?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message