add
RepositoryConnection メソッドを使用したインスタンス化は、SPARQL クエリを使用してモデルを変更してインスタンス化した場合よりも遅いことに気付きました。違いはあるものの、SPARQL update メソッドでさえ、インスタンス化に長い時間がかかります (10,000 トリプレットまで 3.4 分)。複数insert
の の実行 (トリプルごとに 1 つのクエリ) または 1 つの大きなinsert
クエリを実行しても、メソッドのパフォーマンスは変わりません。まだ遅いです。100 万個のトリプルを追加するのに適切な別の方法はありますか、または役立つ特別な構成はありますか?
RepositoryConnection のコード
Repository myRepository = new HTTPRepository(serverURL, repositoryId);
myRepository.initialize();
RepositoryConnection con = myRepository.getConnection();
ValueFactory f = myRepository.getValueFactory();
i = 0;
j = 1000000;
while(i < j)(
URI event = f.createURI(ontologyIRI + "event"+i);
URI hasTimeStamp = f.createURI(ontologyIRI + "hasTimeStamp");
Literal timestamp = f.createLiteral(fields.get(0));
con.add(event, hasTimeStamp, timestamp);
i++
}
SPARQL のコード
Repository myRepository = new HTTPRepository(serverURL, repositoryId);
myRepository.initialize();
RepositoryConnection con = myRepository.getConnection();
i = 0;
j = 1000000;
while(i < j)(
query = "INSERT {";
query += "st:event"+i+" st:hasTimeStamp '"+fields.get(0)+"'^^<http://www.w3.org/2001/XMLSchema#float> .\n"
+ "}"
+ "WHERE { ?x ?y ?z }";
Update update = con.prepareUpdate(QueryLanguage.SPARQL, query);
update.execute();
i++;
}
私が実験を行ったエディションIn Memory
とNative Store
、同期値が0のゴマリポジトリ