X

The Oracle NoSQL Database Blog covers all things Oracle NoSQL Database. On-Prem, Cloud and more.

  • January 20, 2015

Using R to plot data from NoSql tables

Oracle NoSql tables are relatively new. The communication between those tables and other BigData systems and tools is under construction. There is a package (rkvstore) allowing to get access to Nosql kv data from R but this package does not allow to use tables. This paper presents a way to access R from Java and to work with table data from Nosql using the R package Rserve and shows how to generate a plot of this data. 


RServe

You need to install into R the package Rserve which can be found here and once there Download/Files

To launch the R server just install the Rserve package:

R CMD INSTALL  <path to the Rserve.tar.gz  source package> 

Run R

>library("Rserve")

>Rserve()

R server : gets data from a Java program and returns the result


NoSql Tables

To create and load Nosql tables refer to this post.


Java Code

The main steps of the java programs are:

  • Connect to the kvstore
  • Get data from a table (via an iterator)
  • Create an R session
  • Transform data from the iterator to an R format
  • Assign data to R variables
  • Generate the R elements to make the plot
  • Display the data
  • Disconnect

You can find the java source code for this  blog entry here.

Usage

run java with the following class and arguments

nosql.r.RViewTablesBlog kvstore kvhost:kvport tablename fligthrangebegin fligthrangeend
use -1 for fligthrangebegin fligthrangeend to ignore flight range

add kvclient.jar from NoSql and REngine.jar, RServeEngine.jar from Rserve to the classpath


Results 

R returns an image similar to:

Plot result from R

Enjoy ! 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.