1.8 Using Graph Server Functionality as a Library

The graph functions available with the graph server (PGX) can be used as a library in your application.

After the rpm install of the graph server, all the jar files can be found in /opt/oracle/graph/lib. In this case, the server installation and the client user application are in the same machine.

For such use cases, development and testing can be done using the interactive Java shell or the Python shell in embedded (local) mode. This means a local PGX instance is created and runs in the same JVM as the client. If you start the shell without any parameters it will start a local PGX instance and run in embedded mode.

Starting the Java Shell in Embedded (local) Mode

For such use cases, development and testing can be done using the interactive Java shell in embedded (local) mode. This means a local PGX instance is created and runs in the same JVM as the client. If you start the shell without any parameters it will start a local PGX instance and run in embedded mode.

Starting the Java shell to use the graph server in embedded mode is only supported in graph shell executables available with the Graph Server installation. You can launch the Java shell using the following commands:

cd /opt/oracle/graph
./bin/opg4j

The following shows the response from the graph shell :

opg4j>
The local PGX instance will try to load a PGX configuration file from:
/etc/oracle/graph/pgx.conf

You can change the location of the configuration file by passing the --pgx_conf command-line option followed by the path to the configuration file:

# start local PGX instance with custom config
./bin/opg4j --pgx_conf <path_to_pgx.conf>

Starting the Python Shell in Embedded (local) Mode

The python client can be used in embedded mode, which means that the graph server is running inside the client process as a library.

Note:

For this mode, the Python client and the Graph Server RPM package must be installed on the same machine.
  1. Start the Python shell.
    cd /opt/oracle/graph/
    ./bin/opg4py
  2. When the shell is running, you can see the following prompt on your screen
    Oracle Graph Server Shell 21.2.0
    >>>