4.4.1 Creating a JSON Configuration to Load a Graph
Loading a Graph from the Property Graph Schema Using JSON Configuration
The graph server (PGX) allows the loading of property graphs from Oracle Database using the property graph schema.
You can create a graph configuration file to load the graph. The following shows a sample graph configuration file that uses a keystore to connect to the database. See Store the Database Password in a Keystore for more information on using a keystore.
{
"name": "BANK_ACCOUNTS",
"format": "pg",
"db_engine": "rdbms",
"jdbc_url": "jdbc:oracle:thin:@localhost:1521/orclpdb",
"username":"graphuser",
"keystore_alias":"database1",
"vertex_props": [
{
"name": "ID",
"type": "integer"
},
{
"name": "NAME",
"type": "string"
}
],
"edge_props": [
{
"name": "AMOUNT",
"type": "float"
},
{
"name": "DESCRIPTION",
"type": "string"
}
],
"partition_while_loading": "by_label",
"loading":{
"load_edge_label":true,
"load_vertex_labels": true,
"create_vertex_id_mapping": true,
"create_edge_id_mapping": true
}
}
See API for Loading Graphs into Memory for more information on PgxSession
API
methods for reading graphs into memory.
You can now read the graph into the graph server (PGX) using the
PgxSession
API method as shown:
opg4j> var g = session.readGraphWithProperties("bank_graph.json")
PgxGraph g = session.readGraphWithProperties("bank_graph.json");
g = session.read_graph_with_properties("bank_graph.json")
Loading a Partitioned Graph Using JSON Configuration
In order to load a partitioned graph into the graph server (PGX), you can create a graph configuration file, which contains metadata about the graph to be loaded.
The following shows a sample partitioned graph configuration file:
{
"name": "bank_graph_analytics",
"vertex_providers":[
{
"name":"Accounts",
"format":"rdbms",
"database_table_name":"BANK_NODES",
"key_column":"ID",
"key_type": "integer"
}
],
"edge_providers":[
{
"name":"Transfers",
"format":"rdbms",
"database_table_name":"BANK_EDGES_AMT",
"key_column":"ID",
"source_column":"SRC_ID",
"destination_column":"DEST_ID",
"source_vertex_provider":"Accounts",
"destination_vertex_provider":"Accounts",
"props":[
{
"name":"AMOUNT",
"type":"float"
}
]
}
]
}
See Graph Configuration Options for more details on partitioned graph configuration options.
You can now read the graph into the graph server as shown:
opg4j> var g = session.readGraphWithProperties("bank_graph_analytics.json")
PgxGraph g = session.readGraphWithProperties("bank_graph_analytics.json");
g = session.read_graph_with_properties("bank_graph_analytics.json")