Zeppelin添加pgx解析器

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.

  1. If you have not already done so, download and install Zeppelin.

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

  3. Follow the official interpreter installation steps.

    1. Unzip the in-memory analyst interpreter package into $ZEPPELIN_HOME/interpreter/pgx.

    2. Edit $ZEPPELIN_HOME/conf/zeppelin-site.xml and add the in-memory analyst Zeppelin interpreter class nameoracle.pgx.zeppelin.PgxInterpreter to the zeppelin.interpreters property field.

    3. Restart Zeppelin.

    4. In the Zeppelin interpreter page, click the +Create button to add a new interpreter of interpreter group pgx.

  4. Configure the new in-memory analyst interpreter.

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

    2. 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 the queryPgql("...") method of the PgxGraph class

  • MapIterable - the object returned by the entries() method of the PgxMap 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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值