PostgreSQL Extension¶
GART is supported as a PostgreSQL Extension. It is possible to operate the GART service through a PostgreSQL front-end such as psql
.
Extension Installation¶
You need to install the PostgreSQL plugin by copying the shared library to the PostgreSQL library directory:
1gart-env$ cd /workspace/gart/apps/pgx/
2gart-env$ make USE_PGXS=1 -j
3gart-env$ sudo make install
To enter commands into PostgreSQL, you need access to the PostgreSQL CLI. You can do this by opening a terminal on Unix-like systems or a command prompt on Windows, and running:
# choose the `ldbc` database
sudo -u postgres psql -d ldbc
# or
psql -U postgres -d ldbc
Extension Configuration¶
After successfully logging in to your database, run the following command to create the gart
extension:
CREATE EXTENSION gart;
The gart
extension has the following configuration options:
1" The path of Kafka home and GART home
2[path]
3KAFKA_HOME=/path/to/kafka
4GART_HOME=/path/to/gart
5
6" The path of the log file and real-time log file
7" Log file is used to record the log of the GART service after the service is started and stopped
8" Real-time log file is used to record the log of the GART service in real time
9[log]
10log_path=/opt/postgresql/tmp.log
11real_time_log_path=/opt/postgresql/gart.log
12
13" The configuration of the GART service, as the arguments of the `gart` script
14[gart]
15db-type=postgresql
16rgmapping-file=/opt/postgresql/rgmapping-ldbc.yaml
17v6d-sock=/path/to/v6d.sock
18etcd-endpoints=127.0.0.1:23760
19etcd-prefix=gart_meta_
20subgraph-num=1
21enable-bulkload=1
Users can modify the configuration file to change the configuration of the GART service. The configuration file can be loaded as follows:
SELECT * FROM gart_set_config('/path/to/config.ini');
Extension Usage¶
Connection Building¶
1-- Pull up the GART service under the current database with the current user
2SELECT * FROM gart_get_connection('password');
3
4-- Get the latest read-only epoch
5SELECT * FROM gart_get_latest_epoch();
6
7-- Exit GART server
8SELECT * FROM gart_release_connection();
RGMapping Definition¶
We go through the SQL/PGQL language for the schema of the graph and the correspondence with the relational data source.
1SELECT *
2FROM gart_define_graph($$
3 CREATE TABLE Person (
4 p_id INT PRIMARY KEY,
5 p_name VARCHAR(100)
6 )
7 $$);
Graph Analytical Processing¶
Graph algorithms:
1-- Initialize the graph server and return the server ID
2SELECT * FROM gart_launch_graph_server('host', port);
3
4-- Retrieve information about the graph server
5SELECT * FROM gart_show_graph_server_info();
6
7-- Terminate the server operation
8SELECT * FROM gart_stop_graph_server(server_id);
9
10-- Execute the Single Source Shortest Path query
11SELECT * FROM gart_run_sssp(server_id, source_node);
Graph traversal:
1SELECT *
2FROM gart_query_by_gremlin($$
3 g.V().count()
4 $$);