Oracle Big Data Spatial and Graph - technical tips, best practices, and news from the product team

Property Graph in a Box

Alan Wu

I have very good news for those of you who want to play with Oracle Big Data Spatial and Graph 1.0. The most recent Oracle Big Data Lite Virtual Machine (v4.2.0) provides a very convenient environment to help one get started quickly with the Oracle Big Data platform. It comes with the property graph feature installed.

To start, download Oracle Big Data Lite Virtual Machine v4.2.0 from the following page.

It is recommended to use Oracle VM Virtual Box 4.3.28 to import this virtual machine. Once import is done successfully, login as oracle (default password is welcome1). On the desktop, there is a "Start/Stop Services" icon - double clicking that will lead to a console popup with a list of services. Check Oracle NoSQL Database, hit enter, and the built-in Oracle NoSQL Database will start automatically.If you need to shutdown the Oracle NoSQL Database, just repeat this process.

Next, I am going to show you a simple Groovy based script that loads a sample property graph representing a small social network, reads out vertices and edges, writes it out, and finally counts the number of triangles in this network.

Open a Linux terminal in this virtual machine and type in the following:

$ cd /opt/oracle/oracle-spatial-graph/property_graph/dal/groovy
$ ./gremlin-opg-nosql.sh

// Connect to the Oracle NoSQL Database in this virtual box
server = new ArrayList<String>();
cfg = new PgNosqlGraphConfigBuilder()                          \
    .setDbEngine(DbEngine.NOSQL)                               \
    .setName("connections")                                    \
    .setStoreName("kvstore")                                   \
    .setHosts(server)                                          \
    .addEdgeProperty("lbl", PropertyType.STRING, "lbl")        \
    .addEdgeProperty("weight", PropertyType.DOUBLE, "1000000") \

// Note: the above PgNosqlGraphConfigBuilder.setDbEngine is available

// only in Big Data Spatial and Graph v1.0.

// For v1.1 or newer, use updated Java APIs instead. See here for details.

// Get an instance of OraclePropertyGraph
opg = OraclePropertyGraph.getInstance(cfg);

// Use the parallel data loader API to load a
// sample property graph in flat file formatwith a
// degree of parallelism (DOP) 2
opgdl.loadData(opg, vfile, efile, 2);

// read through the vertices

// read through the edges

// You can add vertices/edges, change properties etc. here.
// ...

// Serialize the graph out into a pair of flat files with DOP=2
OraclePropertyGraphUtils.exportFlatFiles(opg, vOutput, eOutput, 2, false);

// Run a built-in analytical function
analyst = opg.getInMemAnalyst();

The last output of the script above should be "22", meaning that there are 22 triangles in this small network.

Note that the same virtual box has Apache HBase installed as well as Oracle NoSQL Database.Once Apache HBase is configured and started, the same script (except the DB connection initialization part) can be used without a change.

Now, do you know how to find out influencers in this graph?

Stay tuned.

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.