X

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

Persisting Results of Graph Analytics into BDSG Graph Database (Part I)

Alan Wu
Architect

From time to time, I received questions on how to persist analytical results back to the graph database. There are many reasons for doing this, performance, persistence, possibility to build text index, ease of query, to name a few. In two installments, I am going to share with you good practices on persisting results of graph analytics back to BDSG graph database.

Part I: When # of results to be persisted is small

In this case,  one can simply update properties of vertices (and/or edges) on the fly with the newly computed values. As an illustration, the following Java code snippet (running in Groovy) shows a flow of getting an instance of OraclePropertyGraph, executing personalized page rank, selecting the top 50 influencers, and persisting those page rank values back to the relevant vertices in the graph.

opg = OraclePropertyGraph.getInstance(cfg);

...
ppr = analyst.personalizedPagerank(pgxGraph, vertexSet, ... );


it = ppr.getTopKValues(50).iterator(); while (it.hasNext()) {
   entry = it.next(); vid = entry.getKey().getId();

   v = opg.getVertex(vid);

   v.setProperty("pr_value", entry.getValue());
}

Basically, the importance thing here is that we fetch vertex ID (vid) from the result, ask from OraclePropertyGraph for the corresponding vertex object (v), and then update it with the newly computed value. Note that you should only take this approach when the number of results is relatively small. Next installment will talk about how one can save, say whole-graph page rank values or all cluster assignment, back to the graph database.


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.Captcha