9.2 プロパティ・グラフ・データの空間索引の作成

空間データをプロパティ・グラフに追加した後、OPG_APISパッケージ・サブプログラムを使用してSDO_GEOMETRYオブジェクトを作成できます。さらに、頂点(VT$)またはエッジ(VT$)表に関数ベースの空間索引を作成できます。

testという名前のプロパティ・グラフの例を使用して、次の文で、必要なメタデータを追加し、関数ベースの空間索引を作成します。

SQL> -- In the schema that owns the property graph TEST:
SQL> --
SQL> insert into user_sdo_geom_metadata values('TESTVT$',
 'mdsys.opg_apis.get_geometry_from_v_t_cols(v,t)',
 sdo_dim_array(
   sdo_dim_element('Longitude', -180, 180, 0.005),
   sdo_dim_element('Latitude', -90, 90, 0.005)), 8307);

commit;

SQL> -- Create a function-based spatial index
SQL> create index testVTXGEO$
       on testVT$(mdsys.opg_apis.get_geometry_from_v_t_cols(v, t))
       indextype is mdsys.spatial_index_v2
       parameters ('tablespace=USERS')
       parallel 4
       local;

(独自のプロパティ・グラフに空間索引を作成するには、グラフ名のtestを使用するグラフ名に置き換えます)

WKTリテラルがV列で使用されている場合、前述の2つのSQL文で、mdsys.opg_apis.get_geometry_from_v_t_colsmdsys.opg_apis.get_wktgeometry_from_v_t_colsで置き換えます。

前述のSQL空間索引の作成ステップは、oracle.pg.rdbmsパッケージに定義されたOraclePropertyGraphクラスの便利なJavaメソッドに含まれています。

  /**
   * This API creates a default Spatial index on edges. It assumes that
   * the mdsys.opg_apis.get_geometry_from_v_t_cols(v,t) PL/SQL is going to be used
   * to create a function-based Spatial index. In addition, it adds a predefined
   * value into user_sdo_geom_metadata. To customize, please refer to the dev
   * guide for adding a row to user_sdo_geom_metadata and then creating a 
   * Spatial index manually.
   * Note that, a DDL will be executed so expect an implict commit. If you 
   * have changes that do not want to be persisted, run a rollback before calling
   * this method.
   * @param dop degree of parallelism used to create the Spatial index
   */
  public void createDefaultSpatialIndexOnEdges(int dop);

  /**
   * This API creates a default Spatial index on vertices. It assumes that
   * the mdsys.opg_apis.get_geometry_from_v_t_cols(v,t) PL/SQL is going to be used
   * to create a function-based Spatial index. In addition, it adds a predefined
   * value into user_sdo_geom_metadata. To customize, please refer to the dev
   * guide for adding a row to user_sdo_geom_metadata and then creating a 
   * Spatial index manually.
   * Note that a DDL will be executed so expect an implict commit. If you 
   * have changes that do not want to be persisted, run a rollback before calling
   * this method.
   * @param dop degree of parallelism used to create the Spatial index
   */
  public void createDefaultSpatialIndexOnVertices(int dop);