5.5.7.1 Oracle Textを使用したパラレル・テキスト検索
OracleTextAutoIndex
のメソッドgetPartitioned
を呼び出し、Oracle Textへの接続の配列(Connectionオブジェクト)、検索するキー/値ペア、および開始パーティションIDを使用することで、Oracle Textを使用したパラレル・テキスト問合せを使用できます。
次のコード・フラグメントは、Oracle Textを使用して、自動テキスト索引を生成し、パラレル・テキスト問合せを実行します。OracleTextAutoIndex
クラスでのgetPartitioned
メソッドへの呼出し数は、VT$ (またはGE$表)のパーティションの合計数と使用される接続の数によって制御されます。
OraclePropertyGraph opg = OraclePropertyGraph.getInstance(…); String prefOwner = "scott"; String datastore = (String) null; String filter = (String) null; String storage = (String) null; String wordlist = (String) null; String stoplist = (String) null; String lexer = "OPG_AUTO_LEXER"; String options = (String) null; OracleIndexParameters params = OracleTextIndexParameters.buildOracleText(prefOwner, datastore, filter, storage, wordlist, stoplist, lexer, dop, options); opg.setDefaultIndexParameters(indexParams); // Create auto indexing on all existing properties, use wildcard for all opg.createKeyIndex(("*", Vertex.class); // Create the text query object for Oracle Text OracleTextQueryObject otqo = OracleTextQueryObject.getInstance("Smith" /* query body */, 1 /* score */, ScoreRange.POSITIVE /* Score range */, Direction.ASC /* order by direction*/); // Get the Connection object Connection[] conns = new Connection[dop]; for (int idx = 0; idx < conns.length; idx++) { conns[idx] = opg.getOracle().clone().getConnection(); } // Get the auto index object OracleIndex<Vertex> index = ((OracleIndex<Vertex>) opg.getAutoIndex(Vertex.class); // Iterate to cover all the partitions in the index long lCount = 0; for (int split = 0; split < index.getTotalShards(); split += conns.length) { // Gets elements from split to split + conns.length Iterable<Vertex>[] iterAr = index.getPartitioned(conns /* connections */, "name"/* key */, otqo, true /* wildcards */, split /* start split ID */); lCount = countFromIterables(iterAr); /* Consume iterables in parallel */ } // Close the connections for (int idx = 0; idx < conns.length; idx++) { conns[idx].dispose(); } // Count results System.out.println("Vertices found using parallel query: " + lCount);