Using the In-Memory Analyst Zeppelin Interpreter
The in-memory analyst provides an interpreter implementation for Apache Zeppelin. This tutorial topic explains how to install the in-memory analyst interpreter into your local Zeppelin installation and to perform some simple usage operations.
Installing the Interpreter
The following steps were tested with Zeppelin version 0.6.1, and might have to be modified with newer versions.
If you have not already done so, download and install Zeppelin.
Locate the in-memory analyst interpreter package in the ig Data Spatial and Graph installation: /opt/oracle/oracle-spatial-graph/property_graph/pgx/client/pgx-<version>-zeppelin-interpreter.zip
Follow the official interpreter installation steps.
Unzip the in-memory analyst interpreter package into
$ZEPPELIN_HOME/interpreter/pgx
.Edit
$ZEPPELIN_HOME/conf/zeppelin-site.xml
and add the in-memory analyst Zeppelin interpreter classnameoracle.pgx.zeppelin.PgxInterpreter
to thezeppelin.interpreters
property field.Restart Zeppelin.
In the Zeppelin interpreter page, click the +Create button to add a new interpreter of interpreter group
pgx
.
Configure the new in-memory analyst interpreter.
Choose an option for interpreter for note:
Shared: All notes will share the same in-memory analyst session (not recommended).
Scoped: Every note gets its own in-memory analyst session but shares the same process (recommended).
Isolated: Every note gets its own in-memory client shell process. This is the highest level of isolation, but might consume unnecessary resources on the system running the Zeppelin interpreters.
For pgx.baseUrl, specify at least the base URL at which the in-memory analyst server is running, because the in-memory analyst interpreter acts like a client that talks to a remote in-memory analyst server,
Using the Interpreter
If you named the in-memory analyst interpreter pgx
, you can send paragraphs to the in-memory analyst interpreter by starting the paragraphs with the %pgxdirective
, just as with any other interpreter.
The in-memory analyst Zeppelin interpreter evaluates paragraphs in the way that the in-memory analyst shell does, and returns the output. Therefore, any valid in-memory analyst shell script will run in the in-memory analyst interpreter, as in the following example:
$pgx g_brands = session.readGraphWithProperties("/opt/data/exommerce/brand_cat.json") g_brands.getNumVertices() rank = analyst.pagerank(g_brands, 0.001, 0.85, 100) rank.getTopKValues)10)
The following figure shows the results of that query after you click the icon to execute it.
As you can see in the preceding figure, the in-memory analyst Zeppelin interpreter automatically renders the values returned by rank.getTopKValues(10)
as a Zeppelin table, to make it more convenient for you to browse results.
Besides property values (getTopKValues(), getBottomKValues() and getValues()
), the following return types are automatically rendered as table also if they are returned from a paragraph:
PgqlResultSet
- the object returned by thequeryPgql("...")
method of thePgxGraph
classMapIterable
- the object returned by theentries()
method of thePgxMap
class
All other return types and errors are returned as normal strings, just as the in-memory analyst shell does.
For more information about Zeppelin, see the official Zeppelin documentation.