PGX 20.1.1

PGX Programming Guides

PGX exposes its functionality via asynchronous Java APIs. Each asynchronous method has a synchronous equivalent, which blocks the caller thread until the server produces a response. These APIs may perform one or any combination of:

  1. Complex, non-blocking Java applications on top of PGX
  2. Simple, sequential Java scripts executed by PGX Shell
  3. Performing interactive graph analysis in the PGX Shell

Note: By design, it is transparent to the caller whether the API is talking to a local or remote PGX instance.

Layers of the PGX API

The PGX API is composed of a few different Java interfaces. Each interface provides a distinct layer of abstraction for PGX.

  • The ServerInstance class encapsulates access to a PGX server instance and can be used to create sessions, start and stop the PGX engine, monitor the engine status and perform other administrative tasks. If the instance points to a remote instance, access to the administrative functions requires special authorization on the HTTP level by default.

  • A PgxSession represents an active user currently connected to an instance. Each session gets its own workspace on the server side which can be used to read graphs, create in-memory data structures, hold analysis results and custom algorithms. The PgxSession class provides various methods to create new transient data (currently collections). If a session is idling for too long, the PGX engine will automatically destroy it to ensure no resources are wasted.

  • A PgxGraph represents a client-side handle to the graph data managed by the PGX server. A graph may contain an arbitrary amount of properties of type VertexProperty and/or EdgeProperty. Note: PGX currently only supports non-partitioned graphs, meaning every vertex/edge has the same properties with the same names and types as all the other vertices/edges. The PgxGraph class provides various methods to create new transient data (including maps and collections) as well as graph mutation operations, such as undirecting, sorting and filtering.

  • The Analyst API contains all of the built-in algorithms PGX provides. Analyst objects keep track of all the transient data they created during algorithm invocations to hold analysis results. Once an Analyst gets destroyed, all the results it created get freed on the server-side automatically.

  • The CompiledProgram class encapsulates runtime-compiled custom algorithms (written in Green-Marl) and allows invocation of those algorithms using PGX data objects, such as PgxGraph or VertexProperty, as arguments.

In the JavaDocs, all of the above APIs can be found in the oracle.pgx.api package.