- プロパティ・グラフのグラフ開発者ガイド
- グラフ・サーバー(PGX)の使用
- グラフ分析を使用したアプリケーションの開発
- カスタムPGXグラフ・アルゴリズムの使用
- カスタムPGXアルゴリズムのコンパイルおよび実行
15.6.2 カスタムPGXアルゴリズムのコンパイルおよび実行
カスタムPGXアルゴリズムをコンパイルおよび実行できるようにするには、次の処理を実行する必要があります。
ノート:
PGXアルゴリズムAPIを使用したカスタムPGXアルゴリズムのコンパイルは、Oracle JDK 17ではサポートされていません。conf/pgx.conf
ファイルに次の2つの構成パラメータを設定します。graph_algorithm_language
オプションをJAVA
に設定します。java_home_dir
オプションを、Javaホームへのパスに設定します(<system-java-home-dir>
を使用して、PGXにシステム・プロパティからJavaホームを推測させます)。
{ "graph_algorithm_language": "JAVA", "java_home_dir": "<system-java-home-dir>" }
- セッションを作成します。
- PGXアルゴリズムをコンパイルします。たとえば:
opg4j> var myAlgorithm = session.compileProgram("/path/to/MyAlgorithm.java") myAlgorithm ==> CompiledProgram[name=MyAlgorithm]
import oracle.pgx.algorithm.CompiledProgram; CompiledProgram myAlgorithm = session.compileProgram("/path/to/MyAlgorithm.java");
my_algorithm = session.compile_program("/path/to/MyAlgorithm.java")
- アルゴリズムを実行します。たとえば:
opg4j> var graph =session.readGraphWithProperties("/path/to/bank_graph_analytics.json") graph ==> PgxGraph[name=bank_graph_analytics,N=1000,E=5001,created=1633504705054] opg4j> var property = graph.createVertexProperty(PropertyType.INTEGER) property ==> VertexProperty[name=vertex_prop_integer_9,type=integer,graph=bank_graph_analytics] opg4j> myAlgorithm.run(graph, property) $6 ==> { "success" : true, "canceled" : false, "exception" : null, "returnValue" : 42, "executionTimeMs" : 0 }
import oracle.pgx.algorithm.VertexProperty; PgxGraph graph = session.readGraphWithProperties("/path/to/bank_graph_analytics.json"); VertexProperty property = graph.createVertexProperty(PropertyType.INTEGER); myAlgorithm.run(graph, property);
graph = session.read_graph_with_properties("/path/to/bank_graph_analytics.json") property = graph.create_vertex_property("integer") my_algorithm.run(graph, property) {'success': True, 'canceled': False, 'exception': None, 'return_value': 42, 'execution_time(ms)': 1}
親トピック: カスタムPGXグラフ・アルゴリズムの使用